Repository: pypa/setuptools

Issue:
ez_setup.py invalid syntax - python 2.4
Originally reported by: **behackett (Bitbucket: [behackett](http://bitbucket.org/behackett), GitHub: [behackett](http://github.com/behackett))**

---

```
#!python

$ sudo python2.4 ez_setup.py 
  File "ez_setup.py", line 176
    finally:
          ^
SyntaxError: invalid syntax
```

Probably just a recent oversight, but you can't combine except and finally in 2.4.

---
- Bitbucket: https://bitbucket.org/pypa/setuptools/issue/72



Discussion:
_Original comment by_ **behackett (Bitbucket: [behackett](http://bitbucket.org/behackett), GitHub: [behackett](http://github.com/behackett))**:

---

Thanks for resolving it so quickly.

_Original comment by_ **jaraco (Bitbucket: [jaraco](http://bitbucket.org/jaraco), GitHub: [jaraco](http://github.com/jaraco))**:

---

Thanks for the report.

_Original comment by_ **jaraco (Bitbucket: [jaraco](http://bitbucket.org/jaraco), GitHub: [jaraco](http://github.com/jaraco))**:

---

Nest try/except/finally for use on Python 2.4. Fixes #72.


Resolving patch:
diff --git a/distutils/command/install.py b/distutils/command/install.py
--- a/distutils/command/install.py
+++ b/distutils/command/install.py
@@ -471,8 +471,13 @@ def finalize_unix(self):
                     raise DistutilsOptionError(
                           "must not supply exec-prefix without prefix")
 
-                self.prefix = os.path.normpath(sys.prefix)
-                self.exec_prefix = os.path.normpath(sys.exec_prefix)
+                # Allow Fedora to add components to the prefix
+                _prefix_addition = getattr(sysconfig, '_prefix_addition', "")
+
+                self.prefix = (
+                    os.path.normpath(sys.prefix) + _prefix_addition)
+                self.exec_prefix = (
+                    os.path.normpath(sys.exec_prefix) + _prefix_addition)
 
             else:
                 if self.exec_prefix is None:


Test patch:
diff --git a/distutils/tests/test_unixccompiler.py b/distutils/tests/test_unixccompiler.py
--- a/distutils/tests/test_unixccompiler.py
+++ b/distutils/tests/test_unixccompiler.py
@@ -11,9 +11,12 @@
 from distutils.unixccompiler import UnixCCompiler
 from distutils.util import _clear_cached_macosx_ver
 
-class UnixCCompilerTestCase(unittest.TestCase):
+from . import support
+
+class UnixCCompilerTestCase(support.TempdirManager, unittest.TestCase):
 
     def setUp(self):
+        super().setUp()
         self._backup_platform = sys.platform
         self._backup_get_config_var = sysconfig.get_config_var
         self._backup_get_config_vars = sysconfig.get_config_vars
@@ -23,6 +26,7 @@ def rpath_foo(self):
         self.cc = CompilerWrapper()
 
     def tearDown(self):
+        super().tearDown()
         sys.platform = self._backup_platform
         sysconfig.get_config_var = self._backup_get_config_var
         sysconfig.get_config_vars = self._backup_get_config_vars
@@ -237,6 +241,7 @@ def test_has_function(self):
         # ensure that setting output_dir does not raise
         # FileNotFoundError: [Errno 2] No such file or directory: 'a.out'
         self.cc.output_dir = 'scratch'
+        os.chdir(self.mkdtemp())
         self.cc.has_function('abort', includes=['stdlib.h'])