From: Martin v. Löwis Date: Fri, 4 Jun 2010 19:39:07 +0000 (+0000) Subject: Issue #6470: Drop UNC prefix in FixTk.py X-Git-Tag: v2.7rc1~31 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eba67c0eac27cfafb779372ef82de09aefcca262;p=python Issue #6470: Drop UNC prefix in FixTk.py Patch by Christop Gohlke and Amaury Forgeot d'Arc. --- diff --git a/Lib/lib-tk/FixTk.py b/Lib/lib-tk/FixTk.py index 0d0966cf8e..49960c74ca 100644 --- a/Lib/lib-tk/FixTk.py +++ b/Lib/lib-tk/FixTk.py @@ -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") diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py index 7057979dfe..1b3c1cc833 100644 --- a/Lib/test/test_tcl.py +++ b/Lib/test/test_tcl.py @@ -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) diff --git a/Misc/NEWS b/Misc/NEWS index 3a5a4498c0..0af21571d9 100644 --- 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.