[issue8515] idle Run Module (F5) does not set __file__ variable

2013-06-30 Thread Roundup Robot

Roundup Robot added the comment:

New changeset a958b7f16a7d by Terry Jan Reedy in branch '2.7':
Issue #8515: Set __file__ when run file in IDLE. Backport 2c276d0553ff by
http://hg.python.org/cpython/rev/a958b7f16a7d

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8515
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8515] idle Run Module (F5) does not set __file__ variable

2012-04-05 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 2c276d0553ff by Andrew Svetlov in branch 'default':
Issue #8515: Set __file__ when run file in IDLE.
http://hg.python.org/cpython/rev/2c276d0553ff

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8515
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8515] idle Run Module (F5) does not set __file__ variable

2012-04-05 Thread Andrew Svetlov

Andrew Svetlov andrew.svet...@gmail.com added the comment:

Thanks to all.
Bruce Frederiksen, you are mentioned in Misc/ACK

Tal Einat, if you want to make a patch which will use `execfile` instead of 
current approach — you are welcome. Please file new issue.

--
assignee:  - asvetlov
resolution:  - fixed
stage:  - committed/rejected
status: open - closed
versions:  -Python 2.7, Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8515
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8515] idle Run Module (F5) does not set __file__ variable

2012-03-31 Thread Andrew Svetlov

Changes by Andrew Svetlov andrew.svet...@gmail.com:


--
nosy: +asvetlov

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8515
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8515] idle Run Module (F5) does not set __file__ variable

2011-12-08 Thread Roger Serwy

Roger Serwy roger.se...@gmail.com added the comment:

I've encountered this bug several times myself. I applied this patch and it 
corrects the issue.

--
nosy: +serwy
versions: +Python 2.7, Python 3.2, Python 3.3 -Python 2.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8515
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8515] idle Run Module (F5) does not set __file__ variable

2010-06-11 Thread Bruce Frederiksen

Bruce Frederiksen dangy...@gmail.com added the comment:

No, IDLE compiles the module (with the 'compile' built-in using the 'exec'
option) and then does an 'exec' on the code (in PyShell.py).  It has several
lines of code that it runs before this exec to prepare the environment that
the code is run in.  It appears to be an oversight that the __file__
variable is not being set as a part of this preparation code to match the
behavior of the python CLI.  The patch that I included only changes one line
of this preparation code to also set the __file__ variable and that fixes
the problem.  If you examine the IDLE code in the immediate vicinity of my
patch you will see this.

I have several use cases where I'm relying on the __file__ variable in my
module so that it can find other non .py files that it needs in the same
directory that it's in.  This works under all combinations of uses from the
CLI, but fails in IDLE using Run Module.

The language reference
manualhttp://docs.python.org/reference/datamodel.html?highlight=__file__states
under Module:

Predefined (writable) attributes: __name__ is the module’s name; __doc__ is
 the module’s documentation string, or None if unavailable; __file__ is the
 pathname of the file from which the module was loaded, if it was loaded from
 a file. The __file__ attribute is not present for C modules that are
 statically linked into the interpreter; for extension modules loaded
 dynamically from a shared library, it is the pathname of the shared library
 file.


The python CLI honors this definition in all cases, but IDLE/Run Module does
not.

On Fri, Jun 11, 2010 at 11:11 AM, Tal Einat rep...@bugs.python.org wrote:


 Tal Einat talei...@users.sourceforge.net added the comment:

 I believe IDLE runs modules via execfile(), so I would expect the behavior
 to be similar, and execfile() does not set __file__. Doing Run Module is
 also IMO equivalent to doing execfile(), so this behavior retains
 consistency.

 However, I would expect __file__ to be set when running IDLE -r script,
 but I get name '__file__' is not defined (with Python 2.6.2). This is
 inconsistent and should be fixed.

 --
 nosy: +taleinat

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue8515
 ___


--
Added file: http://bugs.python.org/file17632/unnamed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8515
___No, IDLE compiles the module (with the #39;compile#39; built-in using the 
#39;exec#39; option) and then does an #39;exec#39; on the code (in 
PyShell.py).  It has several lines of code that it runs before this exec to 
prepare the environment that the code is run in.  It appears to be an 
oversight that the __file__ variable is not being set as a part of this 
preparation code to match the behavior of the python CLI.  The patch that I 
included only changes one line of this preparation code to also set the 
__file__ variable and that fixes the problem.  If you examine the IDLE code in 
the immediate vicinity of my patch you will see this.br
brI have several use cases where I#39;m relying on the __file__ variable in 
my module so that it can find other non .py files that it needs in the same 
directory that it#39;s in.  This works under all combinations of uses from 
the CLI, but fails in IDLE using Run Module.br
brThe a 
href=http://docs.python.org/reference/datamodel.html?highlight=__file__;language
 reference manual/a states under quot;Modulequot;:brbrblockquote 
style=margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); 
padding-left: 1ex; class=gmail_quote
Predefined (writable) attributes: tt class=xref docutils literalspan 
class=pre__name__/span/tt is the module’s name;
tt class=xref docutils literalspan class=pre__doc__/span/tt 
is the module’s documentation string, or tt class=xref docutils 
literalspan class=preNone/span/tt if
unavailable; tt class=xref docutils literalspan class=prespan 
class=highlight__file__/span/span/tt is the pathname of the 
file from which the module
was loaded, if it was loaded from a file. The tt class=xref docutils 
literalspan class=prespan class=highlight__file__/span/span/tt
 attribute is not
present for C modules that are statically linked into the interpreter; 
for
extension modules loaded dynamically from a shared library, it is the 
pathname
of the shared library file.br/blockquotebrThe python CLI honors this 
definition in all cases, but IDLE/Run Module does not.brbrdiv 
class=gmail_quoteOn Fri, Jun 11, 2010 at 11:11 AM, Tal Einat span 
dir=ltrlt;a 
href=mailto:rep...@bugs.python.org;rep...@bugs.python.org/agt;/span 
wrote:br
blockquote class=gmail_quote style=margin: 0pt 0pt 0pt 0.8ex; border-left: 
1px solid rgb(204, 204, 204); padding-left: 1ex;br
Tal Einat lt;a 

[issue8515] idle Run Module (F5) does not set __file__ variable

2010-06-11 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


Removed file: http://bugs.python.org/file17632/unnamed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8515
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8515] idle Run Module (F5) does not set __file__ variable

2010-06-11 Thread Tal Einat

Tal Einat talei...@users.sourceforge.net added the comment:

Why doesn't execfile() set __file__? I would be surprised if this is due to an 
oversight by the Python devs. In both execfile and IDLE's Run Module I can't 
think of a reason not to set __file__, but perhaps this was intentional? 
Googling a bit hasn't brought up much.

I am currently of the opinion that both IDLE and execfile() should set __file__ 
(with execfile() perhaps requiring more thinking about edge-cases, since it can 
be passes locals and globals dictionaries).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8515
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8515] idle Run Module (F5) does not set __file__ variable

2010-04-23 Thread Bruce Frederiksen

New submission from Bruce Frederiksen dangy...@gmail.com:

The python CLI always sets the __file__ variable, whether run as:

$ python foobar.py

or

$ python -m foobar

or

$ python
 import foobar   # __file__ set in foobar module

The idle program sets the __file__ variable properly when you do the import 
from the idle shell, but __file__ is not set with the Run Module (F5) command 
from the editor.

I've included a patch file to set __file__, but it doesn't del it after the 
module has run.  But maybe this is OK, because the os.chdir is not undone 
either???

--
components: IDLE
files: idle.patch
keywords: patch
messages: 104066
nosy: dangyogi
severity: normal
status: open
title: idle Run Module (F5) does not set __file__ variable
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file17062/idle.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8515
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com