[issue25493] warnings.warn: wrong stacklevel causes import of local file "sys"

2015-12-09 Thread John Mark Vandenberg
John Mark Vandenberg added the comment: It seems like there is already sufficient detection of invalid stack levels in warnings.warn, and one of the code paths does `module = ""` and later another does `filename = module`, so `filename` can be intentionally junk data, which will be passed to

[issue25493] warnings.warn: wrong stacklevel causes import of local file "sys"

2015-11-12 Thread Christoph Reiter
Christoph Reiter added the comment: To add some info why we hit that bug: https://bugs.python.org/issue24305 changed the warning stacklevel needed for import warnings from 8 to 2. As a result any code doing import warnings will likely hit that edge case when run with 3.5 and openafs

[issue25493] warnings.warn: wrong stacklevel causes import of local file "sys"

2015-10-30 Thread Brett Cannon
Brett Cannon added the comment: So I'm going to close this as "won't fix" because linecache is horribly over-engineered and I'm afraid trying to fix this will break code that actually worked previously. This is obviously an odd edge case that I think we can live with. -- resolution:

[issue25493] warnings.warn: wrong stacklevel causes import of local file "sys"

2015-10-27 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis : -- nosy: +Arfrever ___ Python tracker ___

[issue25493] warnings.warn: wrong stacklevel causes import of local file "sys"

2015-10-27 Thread R. David Murray
Changes by R. David Murray : -- nosy: +brett.cannon ___ Python tracker ___ ___

[issue25493] warnings.warn: wrong stacklevel causes import of local file "sys"

2015-10-27 Thread Brett Cannon
Brett Cannon added the comment: I'll have to dig into this to figure out what's going on, but since the sys module is built into Python it makes it so import won't accidentally import some file named sys. the real question is who thinks the 'sys' file should be considered. --

[issue25493] warnings.warn: wrong stacklevel causes import of local file "sys"

2015-10-27 Thread Michael Laß
New submission from Michael Laß: When there is a file called "sys" in the local directory of a python script and warning.warn is called with an invalid stacklevel, python tries to import that file and throws an error like the following: >>> import warnings >>> warnings.warn("foo", Warning,

[issue25493] warnings.warn: wrong stacklevel causes import of local file "sys"

2015-10-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The "sys" file is not imported. It is read by linecache. warnings.warn() tries to determine the file name by looking at __file__ in module's globals. If it fails, it falls back to the module name. Definitely it fails also for builtin modules, binary

[issue25493] warnings.warn: wrong stacklevel causes import of local file "sys"

2015-10-27 Thread R. David Murray
R. David Murray added the comment: Hmm. I remember fixing problems with linecache and inspect. I wonder if this is a variation on that? I don't remember the issue number. -- nosy: +r.david.murray ___ Python tracker