[Patches] [ python-Patches-719777 ] Remove __file__ after running
$PYTHONSTARTUP
SourceForge.net
noreply at sourceforge.net
Thu Oct 21 05:01:23 CEST 2004
Patches item #719777, was opened at 2003-04-11 12:25
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=719777&group_id=5470
Category: Core (C code)
Group: Python 2.3
>Status: Closed
>Resolution: Duplicate
Priority: 3
Submitted By: Fred L. Drake, Jr. (fdrake)
Assigned to: Neal Norwitz (nnorwitz)
Summary: Remove __file__ after running $PYTHONSTARTUP
Initial Comment:
When the file named by PYTHONSTARTUP is executed, an
__file__ is left behind in __main__ even though it
doesn't apply to commands run in the interactive
interpreter. This causes confusing output when
warnings are generated. For example, running CVS
Python with -Wall:
>>> raise 'foo'
/home/fdrake/env/python/INIT.py:1:
PendingDeprecationWarning: raising a string exception
is deprecated
# INIT.py
Traceback (most recent call last):
File "<stdin>", line 1, in ?
foo
Clearly, the deprecation warning is not generated
because of anything in the file named.
This patch causes the __file__ entry in the __main__
module to be removed after the PYTHONSTARTUP file has
been run. __file__ was not added to __main__ in Python
2.2; this is caused by a change to
PyRun_SimpleFileExFlags() in 2.3 (in particular, a
change I made so __file__ would be set while running
PYTHONSTARTUP). It does this simply by causing
PyRun_SimpleFileExFlags() to clean up after itself.
Functions defined in PYTHONSTARTUP that need __file__
after running will simply need to cache the value
somewhere (possibly just under a different name in
__main__'s globals).
----------------------------------------------------------------------
>Comment By: Neal Norwitz (nnorwitz)
Date: 2004-10-20 23:01
Message:
Logged In: YES
user_id=33168
Duplicate of 703779. Fred are you still interested in this
patch? Should we try to get it in 2.4?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=719777&group_id=5470
More information about the Patches
mailing list