diff options
author | Charles-François Natali <cf.natali@gmail.com> | 2013-12-15 18:12:07 (GMT) |
---|---|---|
committer | Charles-François Natali <cf.natali@gmail.com> | 2013-12-15 18:12:07 (GMT) |
commit | 325a10277fd32c17788cdf11e3c4db2d648cbc33 (patch) | |
tree | 690a582528ea710c223324eda0710e3f4ba6263e /Lib/idlelib/PyShell.py | |
parent | 46c686fc40a4cababf83f89e5a5bf867a06c647c (diff) | |
parent | c836a28cc1bf6c0dcbcf9c30f47b731943e21b60 (diff) | |
download | cpython-325a10277fd32c17788cdf11e3c4db2d648cbc33.zip cpython-325a10277fd32c17788cdf11e3c4db2d648cbc33.tar.gz cpython-325a10277fd32c17788cdf11e3c4db2d648cbc33.tar.bz2 |
Merge.
Diffstat (limited to 'Lib/idlelib/PyShell.py')
-rwxr-xr-x[-rw-r--r--] | Lib/idlelib/PyShell.py | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py index b2a1f58..6674f4e 100644..100755 --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -1331,8 +1331,11 @@ class PseudoOutputFile(PseudoFile): def write(self, s): if self.closed: raise ValueError("write to closed file") - if not isinstance(s, str): - raise TypeError('must be str, not ' + type(s).__name__) + if type(s) is not str: + if not isinstance(s, str): + raise TypeError('must be str, not ' + type(s).__name__) + # See issue #19481 + s = str.__str__(s) return self.shell.write(s, self.tags) @@ -1531,20 +1534,22 @@ def main(): args.remove(filename) if not args: flist.new() + if enable_shell: shell = flist.open_shell() if not shell: return # couldn't open shell - if macosxSupport.runningAsOSXApp() and flist.dict: # On OSX: when the user has double-clicked on a file that causes # IDLE to be launched the shell window will open just in front of # the file she wants to see. Lower the interpreter window when # there are open files. shell.top.lower() + else: + shell = flist.pyshell - shell = flist.pyshell - # handle remaining options: + # Handle remaining options. If any of these are set, enable_shell + # was set also, so shell must be true to reach here. if debug: shell.open_debugger() if startup: @@ -1552,7 +1557,7 @@ def main(): os.environ.get("PYTHONSTARTUP") if filename and os.path.isfile(filename): shell.interp.execfile(filename) - if shell and cmd or script: + if cmd or script: shell.interp.runcommand("""if 1: import sys as _sys _sys.argv = %r @@ -1563,13 +1568,14 @@ def main(): elif script: shell.interp.prepend_syspath(script) shell.interp.execfile(script) - - # Check for problematic OS X Tk versions and print a warning message - # in the IDLE shell window; this is less intrusive than always opening - # a separate window. - tkversionwarning = macosxSupport.tkVersionWarning(root) - if tkversionwarning: - shell.interp.runcommand(''.join(("print('", tkversionwarning, "')"))) + elif shell: + # If there is a shell window and no cmd or script in progress, + # check for problematic OS X Tk versions and print a warning + # message in the IDLE shell window; this is less intrusive + # than always opening a separate window. + tkversionwarning = macosxSupport.tkVersionWarning(root) + if tkversionwarning: + shell.interp.runcommand("print('%s')" % tkversionwarning) while flist.inversedict: # keep IDLE running while files are open. root.mainloop() |