[issue6011] python doesn't build if prefix contains non-ascii characters

Baptiste Carvello report at bugs.python.org
Fri May 13 15:11:58 CEST 2011


Baptiste Carvello <baptiste13z at free.fr> added the comment:

Indeed, I retried with 534a9e274d88 (that was the tip of 3.2 sometime 
yesterday) and my original problem is solved. Thank you.

While I was at it, I ran "make test",  and got 3 unusual skips and 1 
failure.

The skips are test_sax, test_xml_etree and test_xml_etree_c and they are 
skipped on purpose when the example XML filename is not encodable to 
utf8. No problem here.

The failure is for test_distutils. 3 individual tests are failing: 
test_simple_built, test_debug_mode and test_record. The cause of this 
failure is that the "install" command installs a test distribution to a 
path containing sys.prefix. This is not a problem per se, but later 
test_simple_built tries to zip this distribution, and cannot construct a 
valid archive name. A similar problem happens when test_record tries to 
write the distribution's filenames to a record file (and test_debug_mode 
fails because of test_record).

Imho those failures cannot be fixed, so the only possible improvement is 
to skip those tests. The attached trivial patch does just that, but I'm 
not sure if it's worth patching distutils for that.

Cheers,
Baptiste

----------
Added file: http://bugs.python.org/file21992/test_distutils_surrogateescape.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6011>
_______________________________________
-------------- next part --------------
diff --git a/Lib/distutils/tests/test_bdist_dumb.py b/Lib/distutils/tests/test_bdist_dumb.py
--- a/Lib/distutils/tests/test_bdist_dumb.py
+++ b/Lib/distutils/tests/test_bdist_dumb.py
@@ -24,6 +24,12 @@
 except ImportError:
     ZLIB_SUPPORT = False
 
+try:
+    os.path.normpath(sys.prefix).encode("utf8")
+    PREFIX_NOT_UTF8 = False
+except UnicodeEncodeError:
+    PREFIX_NOT_UTF8 = True
+
 
 class BuildDumbTestCase(support.TempdirManager,
                         support.LoggingSilencer,
@@ -42,6 +48,7 @@
         super(BuildDumbTestCase, self).tearDown()
 
     @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
+    @unittest.skipIf(PREFIX_NOT_UTF8, 'prefix is not encodable to utf8')
     def test_simple_built(self):
 
         # let's create a simple package
diff --git a/Lib/distutils/tests/test_install.py b/Lib/distutils/tests/test_install.py
--- a/Lib/distutils/tests/test_install.py
+++ b/Lib/distutils/tests/test_install.py
@@ -16,6 +16,13 @@
 
 from distutils.tests import support
 
+try:
+    os.path.normpath(sys.prefix).encode("utf8")
+    PREFIX_NOT_UTF8 = False
+except UnicodeEncodeError:
+    PREFIX_NOT_UTF8 = True
+
+
 class InstallTestCase(support.TempdirManager,
                       support.EnvironGuard,
                       support.LoggingSilencer,
@@ -166,6 +173,7 @@
         cmd.user = 'user'
         self.assertRaises(DistutilsOptionError, cmd.finalize_options)
 
+    @unittest.skipIf(PREFIX_NOT_UTF8, 'prefix is not encodable to utf8')
     def test_record(self):
 
         install_dir = self.mkdtemp()


More information about the Python-bugs-list mailing list