This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author y-fujii
Recipients y-fujii
Date 2013-04-20.11:57:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1366459067.56.0.563805479218.issue17803@psf.upfronthosting.co.za>
In-reply-to
Content
Calling Tkinter.Tk() with baseName keyword argument throws UnboundLocalError on Python 2.7.4.

A process to reproduce the bug:
>>> import Tkinter
>>> Tkinter.Tk(baseName="test")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1748, in __init__
    if not sys.flags.ignore_environment:
UnboundLocalError: local variable 'sys' referenced before assignment

A patch to fix the bug:
--- Lib/lib-tk/Tkinter.py.orig
+++ Lib/lib-tk/Tkinter.py
@@ -1736,7 +1736,7 @@
         # ensure that self.tk is always _something_.
         self.tk = None
         if baseName is None:
-            import sys, os
+            import os
             baseName = os.path.basename(sys.argv[0])
             baseName, ext = os.path.splitext(baseName)
             if ext not in ('.py', '.pyc', '.pyo'):
History
Date User Action Args
2013-04-20 11:57:47y-fujiisetrecipients: + y-fujii
2013-04-20 11:57:47y-fujiisetmessageid: <1366459067.56.0.563805479218.issue17803@psf.upfronthosting.co.za>
2013-04-20 11:57:47y-fujiilinkissue17803 messages
2013-04-20 11:57:47y-fujiicreate