[Jython-checkins] jython: Preserve case of temporary directory path. Partly addresses #2307.

jeff.allen jython-checkins at python.org
Thu Apr 9 09:28:35 CEST 2015


https://hg.python.org/jython/rev/e6ca8b2cf467
changeset:   7650:e6ca8b2cf467
user:        Jeff Allen <ja.py at farowl.co.uk>
date:        Mon Apr 06 14:59:39 2015 +0100
summary:
  Preserve case of temporary directory path. Partly addresses #2307.

Module tempfile now returns temporary directory in proper case.
(See also CPython issue 14255)

files:
  Lib/tempfile.py                    |   2 +-
  Lib/test/test_tempfile.py          |  16 ++++++++++++++++
  Lib/test/test_zipimport_support.py |   9 ++++++---
  3 files changed, 23 insertions(+), 4 deletions(-)


diff --git a/Lib/tempfile.py b/Lib/tempfile.py
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -192,7 +192,7 @@
 
     for dir in dirlist:
         if dir != _os.curdir:
-            dir = _os.path.normcase(_os.path.abspath(dir))
+            dir = _os.path.abspath(dir) # See CPython Issue 14255
         # Try only a few names per directory.
         for seq in xrange(100):
             name = namer.next()
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -393,6 +393,22 @@
 
         self.assert_(a is b)
 
+    def test_case_sensitive(self):
+        # gettempdir should not flatten its case
+        # even on a case-insensitive file system
+        # See CPython Issue 14255 (back-ported for Jython)
+        case_sensitive_tempdir = tempfile.mkdtemp("-Temp")
+        _tempdir, tempfile.tempdir = tempfile.tempdir, None
+        try:
+            with test_support.EnvironmentVarGuard() as env:
+                # Fake the first env var which is checked as a candidate
+                env["TMPDIR"] = case_sensitive_tempdir
+                self.assertEqual(tempfile.gettempdir(), case_sensitive_tempdir)
+        finally:
+            tempfile.tempdir = _tempdir
+            test_support.rmdir(case_sensitive_tempdir)
+
+
 test_classes.append(test_gettempdir)
 
 
diff --git a/Lib/test/test_zipimport_support.py b/Lib/test/test_zipimport_support.py
--- a/Lib/test/test_zipimport_support.py
+++ b/Lib/test/test_zipimport_support.py
@@ -231,7 +231,6 @@
                 print data
             self.assertIn(expected, data)
 
-    @unittest.skipIf(is_jython, "FIXME: not working on Jython")
     def test_pdb_issue4201(self):
         test_src = textwrap.dedent("""\
                     def f():
@@ -245,13 +244,17 @@
             p = spawn_python(script_name)
             p.stdin.write('l\n')
             data = kill_python(p)
-            self.assertIn(script_name, data)
+            # bdb/pdb applies normcase to its filename before displaying
+            # See CPython Issue 14255 (back-ported for Jython)
+            self.assertIn(os.path.normcase(script_name.encode('utf-8')), data)
             zip_name, run_name = make_zip_script(d, "test_zip",
                                                 script_name, '__main__.py')
             p = spawn_python(zip_name)
             p.stdin.write('l\n')
             data = kill_python(p)
-            self.assertIn(run_name, data)
+            # bdb/pdb applies normcase to its filename before displaying
+            # See CPython Issue 14255 (back-ported for Jython)
+            self.assertIn(os.path.normcase(run_name.encode('utf-8')), data)
 
 
 def test_main():

-- 
Repository URL: https://hg.python.org/jython


More information about the Jython-checkins mailing list