]> granicus.if.org Git - python/commitdiff
Issue #6470: Drop UNC prefix in FixTk.py
authorMartin v. Löwis <martin@v.loewis.de>
Fri, 4 Jun 2010 19:39:07 +0000 (19:39 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Fri, 4 Jun 2010 19:39:07 +0000 (19:39 +0000)
Patch by Christop Gohlke and Amaury Forgeot d'Arc.

Lib/lib-tk/FixTk.py
Lib/test/test_tcl.py
Misc/NEWS

index 0d0966cf8e1176efd875bd2b7253ee125664d76e..49960c74ca80282f1ec9337c3d64b5db89776ed4 100644 (file)
@@ -42,6 +42,8 @@ else:
         # Ignore leading \\?\
         if s.startswith("\\\\?\\"):
             s = s[4:]
+        if s.startswith("UNC"):
+            s = "\\" + s[3:]
         return s
 
 prefix = os.path.join(sys.prefix,"tcl")
index 7057979dfe8d3b01cfe6b3ea5faf3aaf6e5e33c1..1b3c1cc833209dd229b1b2c20310dd3cad941c9d 100644 (file)
@@ -127,6 +127,31 @@ class TclTest(unittest.TestCase):
         tcl = self.interp
         self.assertRaises(TclError,tcl.eval,'package require DNE')
 
+    def testLoadWithUNC(self):
+        import sys
+        if sys.platform != 'win32':
+            return
+
+        # Build a UNC path from the regular path.
+        # Something like
+        #   \\%COMPUTERNAME%\c$\python27\python.exe
+
+        fullname = os.path.abspath(sys.executable)
+        if fullname[1] != ':':
+            return
+        unc_name = r'\\%s\%s$\%s' % (os.environ['COMPUTERNAME'],
+                                    fullname[0],
+                                    fullname[3:])
+
+        with test_support.EnvironmentVarGuard() as env:
+            env.unset("TCL_LIBRARY")
+            f = os.popen('%s -c "import Tkinter; print Tkinter"' % (unc_name,))
+
+        self.assert_('Tkinter.py' in f.read())
+        # exit code must be zero
+        self.assertEqual(f.close(), None)
+
+
 
 def test_main():
     test_support.run_unittest(TclTest, TkinterTest)
index 3a5a4498c0583b121ad21e91b1c5e1f698684287..0af21571d9f448e224f3204c56e04f8398cda9f2 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -46,6 +46,8 @@ C-API
 Library
 -------
 
+- Issue #6470: Drop UNC prefix in FixTk.
+
 - Issue #5610: feedparser no longer eats extra characters at the end of
   a body part if the body part ends with a \r\n.