Blob Blame History Raw
From 4955ebd4e8bfb01be582cdd7c0e9eb4155488ea6 Mon Sep 17 00:00:00 2001
From: Adam Williamson <adamw@happyassassin.net>
Date: Sat, 22 Feb 2020 04:53:46 -0800
Subject: [PATCH] Fix error printing in bailout for Python < 2.7 (#1651)

Ironically, the code that tries to print an error message when
we're running on Python < 2.7 can only work on Python 2.7 or
higher! Prior to 2.7, the curly-braces style of string formatting
required all fields to be explicitly numbered; you have to use
{0}, you cannot use {}. So if you actually try to run virtualenv
on Python 2.6, you get an error when trying to print the error!
This should fix that, and print the right error...

Signed-off-by: Adam Williamson <awilliam@redhat.com>
---
 docs/changelog/1651.bugfix.rst | 1 +
 virtualenv.py                  | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 100644 docs/changelog/1651.bugfix.rst

diff --git a/docs/changelog/1651.bugfix.rst b/docs/changelog/1651.bugfix.rst
new file mode 100644
index 000000000..26dd9c6ac
--- /dev/null
+++ b/docs/changelog/1651.bugfix.rst
@@ -0,0 +1 @@
+fix error printing in bailout for Python < 2.7 - by ``AdamWill`
diff --git a/virtualenv.py b/virtualenv.py
index 000d50a99..5968059b2 100755
--- a/virtualenv.py
+++ b/virtualenv.py
@@ -50,7 +50,7 @@
 virtualenv_version = __version__  # legacy
 DEBUG = os.environ.get("_VIRTUALENV_DEBUG", None) == "1"
 if sys.version_info < (2, 7):
-    print("ERROR: {}".format(sys.exc_info()[1]))
+    print("ERROR: {0}".format(sys.exc_info()[1]))
     print("ERROR: this script requires Python 2.7 or greater.")
     sys.exit(101)