[ python-Bugs-1010370 ] sys.ps1 not protected in EditorWindow.py
SourceForge.net
noreply at sourceforge.net
Tue Aug 17 19:10:13 CEST 2004
Bugs item #1010370, was opened at 2004-08-16 15:15
Message generated for change (Comment added) made by d_florek
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1010370&group_id=5470
Category: IDLE
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Dave Florek (d_florek)
Assigned to: Kurt B. Kaiser (kbk)
Summary: sys.ps1 not protected in EditorWindow.py
Initial Comment:
Python 2.3.4 on
Linux <host> 2.4.19-xfs-p3-929 #1 SMP Thu Oct 24
11:29:34 PDT 2002 i686 unknown
(RedHat 7.3, patched)
Auto-indenting fails (and dumps errors to the shell)
when idle is started as a file editor. I've wrapped
original lines 987 and 1057 of EditorWindow.py
(last_line_of_prompt = sys.ps1.split('\n')[-1]) with
if self.context_use_ps1:
last_line_of_prompt = sys.ps1.split('\n')[-1]
else:
last_line_of_prompt = '>>> '
This seems to fix it (might want to double-check other
attempts to access sys.ps1 and make sure they're
likewise protected).
FYI, the errors I got (other than incorrect line
numbers -- I was tracking down a different problem
when I stumbled across this) are:
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/local/lib/python2.3/lib-tk/Tkinter.py",
line 1345, in __call__
return self.func(*args)
File
"/work/florek/dev/python2.3/idlelib/EditorWindow.py",
line 1069, in newline_and_indent_event
last_line_of_prompt = sys.ps1.split('\n')[-1]
AttributeError: 'module' object has no attribute 'ps1'
----------------------------------------------------------------------
>Comment By: Dave Florek (d_florek)
Date: 2004-08-17 10:10
Message:
Logged In: YES
user_id=1105316
We have a Tk-based app that integrates IDLE as the default
text editor for python "scriptlets". We create a new
idlelib.FileList attached to the parent gui, and then
on-demand from a button do a
editor = self.parentGui.flist.open(file)
editor.set_close_hook(lambda self=self:
self.parentGui.close_idle(self))
self.editor = editor
the close_idle callback, among other things, calls
flist.close_edit(widget.editor)
I'll look at idle.py and PyShell.py for more ideas, but it
seems to me if there's a valid "context" flag that indicates
whether IDLE is acting as a Python shell interface or as a
text-editor, then that flag should be used in this
particular case, since there won't be a prompt when acting
as a text-editor, and then there's no need to ensure that
sys.ps1 is currently defined.
Thanks,
Dave
----------------------------------------------------------------------
Comment By: Kurt B. Kaiser (kbk)
Date: 2004-08-16 23:36
Message:
Logged In: YES
user_id=149084
When IDLE starts via PyShell.main() sys.ps1 is set
to '>>>' at line 1273. How are you "starting idle as a
file editor?" It may be started either with the idle script
(probably in /usr/bin/ if IDLE was installed from the rpm)
or by calling ../../python ./PyShell.py from .../Lib/idlelib.
Also, take a look at idle.py, it's pretty flexible.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1010370&group_id=5470
More information about the Python-bugs-list
mailing list