[issue2090] __import__ with fromlist=

2012-04-17 Thread Brett Cannon
Brett Cannon added the comment: Importlib does away with this issue. -- resolution: -> out of date stage: -> committed/rejected status: open -> closed ___ Python tracker ___ __

[issue2090] __import__ with fromlist=

2012-03-28 Thread Éric Araujo
Changes by Éric Araujo : -- versions: +Python 3.3 -Python 3.1 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: ht

[issue2090] __import__ with fromlist=

2010-09-20 Thread Éric Araujo
Changes by Éric Araujo : -- versions: +Python 3.2 -Python 2.6 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: ht

[issue2090] __import__ with fromlist=

2010-09-19 Thread Brett Cannon
Brett Cannon added the comment: I replied to the Stack Overflow question. I should also mention that importlib is on PyPI and compatible back to PYthon 2.3. I still plan to get to this some day, but I don't view this as a critical fix, just a nice thing to do for folks. -- _

[issue2090] __import__ with fromlist=

2010-09-19 Thread Aaron Sterling
Changes by Aaron Sterling : -- versions: +Python 2.7, Python 3.1 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue2090] __import__ with fromlist=

2010-09-19 Thread Aaron Sterling
Aaron Sterling added the comment: FWIW, I also get this behavior on 2.6.5 and there are claims that it occurs on 2.6.4 and 3.1.1. see http://stackoverflow.com/questions/3745221/import-calls-init-py-twice/3745273#3745273 -- nosy: +Aaron.Sterling versions: +Python 2.6 -Python 2.7 _

[issue2090] __import__ with fromlist=

2010-08-04 Thread Terry J. Reedy
Changes by Terry J. Reedy : -- versions: -Python 2.5, Python 2.6 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue2090] __import__ with fromlist=

2010-05-20 Thread Brett Cannon
Changes by Brett Cannon : Removed file: http://bugs.python.org/file16936/unnamed ___ Python tracker ___ ___ Python-bugs-list mailing list Unsub

[issue2090] __import__ with fromlist=

2010-05-08 Thread Brett Cannon
Changes by Brett Cannon : -- resolution: wont fix -> status: closed -> open ___ Python tracker ___ ___ Python-bugs-list mailing list U

[issue2090] __import__ with fromlist=

2010-04-18 Thread Brett Cannon
Brett Cannon added the comment: Thanks for the patch, George. I will get it when I can. And this make me even more glad that we removed the file path import from 3.x. -- ___ Python tracker

[issue2090] __import__ with fromlist=

2010-04-18 Thread George Sakkis
George Sakkis added the comment: > On the surface this seems like a potential directory traversal attack > hole, although I couldn't get past 'pkg' by passing '../../../', so I > guess there must be other checks before attempting the import. I rushed to post; it turns out one *can* access pack

[issue2090] __import__ with fromlist=

2010-04-18 Thread George Sakkis
George Sakkis added the comment: FWIW attached is a patch that allows only valid identifiers before calling import_submodule(), and returns silently otherwise (for backwards compatibility). For the record, the reason that empty strings and some combinations of slashes/dots caused the double

[issue2090] __import__ with fromlist=

2010-04-15 Thread George Sakkis
George Sakkis added the comment: More fun findings: dots are special-cased too, but only if they don't appear consecutively (!); ~$ cat pkg/__init__.py print __name__ ~$ python -c "__import__('pkg', fromlist=['.'])" pkg pkg.. ~$ python -c "__import__('pkg', fromlist=['..'])" pkg ~$ python -c

[issue2090] __import__ with fromlist=

2010-04-15 Thread George Sakkis
George Sakkis added the comment: > When you use an empty string in fromlist you are essentially simulating > ``from pkg import`` which makes absolutely no sense, so no one has > cared enough to try to fix this. ``from pkg import __bogus__, 123, @$%`` doesn't make sense either and yet the equi

[issue2090] __import__ with fromlist=

2010-04-15 Thread Brett Cannon
Brett Cannon added the comment: Although now that I think about it, there is a slightly sticky situation of someone using '' or some name with a slash for a key in __dict__. The usage in fromlist would then be "reasonable", but the semantics would be somewhat odd as fromlist is really only ne

[issue2090] __import__ with fromlist=

2010-04-15 Thread Brett Cannon
Brett Cannon added the comment: On Thu, Apr 15, 2010 at 14:56, Éric Araujo wrote: That's fine with me if someone wrote a patch that did that. -- title: __import__ with fromlist=[''] causes double initialization of modules -> __import__ with fromlist= Added file: http://bugs.python.o

[issue2090] __import__ with fromlist=[''] causes double initialization of modules

2010-04-15 Thread Éric Araujo
Éric Araujo added the comment: Since ``from pkg import`` makes no sense, would it be okay if __import__ with an empty fromlist or slashes raised an error? -- nosy: +merwok ___ Python tracker __

[issue2090] __import__ with fromlist=[''] causes double initialization of modules

2010-04-15 Thread Raymond Hettinger
Raymond Hettinger added the comment: I concur with Brett. For the most part, we don't care about implementation artifacts and undefined behaviors (as long as it doesn't segfault). -- nosy: +rhettinger ___ Python tracker

[issue2090] __import__ with fromlist=[''] causes double initialization of modules

2010-04-15 Thread Brett Cannon
Brett Cannon added the comment: If you want a justification, think of it as undefined behavior. When you use an empty string in fromlist you are essentially simulating ``from pkg import`` which makes absolutely no sense, so no one has cared enough to try to fix this. It's such a hack that I d

[issue2090] __import__ with fromlist=[''] causes double initialization of modules

2010-04-15 Thread George Sakkis
George Sakkis added the comment: Just bitten by this (through a 3rd party library that uses this pattern) and I'm wondering why it was closed as invalid. Passing a non-empty fromlist string also imports the tail module but without the side effect of double import, so it's not generally harmfu

[issue2090] __import__ with fromlist=[''] causes double initialization of modules

2009-02-02 Thread Brett Cannon
Brett Cannon added the comment: And just some more info, Python 2.7/3.1 have gained the importlib module/package and its import_module function which gives a much saner API than __import__. ___ Python tracker __

[issue2090] __import__ with fromlist=[''] causes double initialization of modules

2009-02-02 Thread Mart Sõmermaa
Mart Sõmermaa added the comment: A pointer for people who keep referring to this bug -- after discussions, the following idiom was selected as the "official" way to import modules by name in 2.x (as seen in latest 2.x docs http://docs.python.org/dev/library/functions.html#__import__ ). --- If

[issue2090] __import__ with fromlist=[''] causes double initialization of modules

2008-11-26 Thread Mart Sõmermaa
Mart Sõmermaa <[EMAIL PROTECTED]> added the comment: See also http://bugs.python.org/issue4438 ___ Python tracker <[EMAIL PROTECTED]> ___ ___ Pyt

[issue2090] __import__ with fromlist=[''] causes double initialization of modules

2008-11-26 Thread Mart Sõmermaa
Mart Sõmermaa <[EMAIL PROTECTED]> added the comment: Just for reference, the simplest workaround is to use: modname = "foo.bar.baz.baq" mod = __import__(modname, {}, {}, [modname.rsplit(".", 1)[-1]]) -- nosy: +mrts ___ Python tracker <[EMAIL PROTECTE

[issue2090] __import__ with fromlist=[''] causes double initialization of modules

2008-03-19 Thread hauser
hauser <[EMAIL PROTECTED]> added the comment: There are quite a few projects that use this solution: http://google.com/codesearch?hl=en&lr=&q=__import__.*%5C%5B%27%27%5C%5D . I would change it even if it is a hack, but I understand your point. -- versions: +Python 2.5 __

[issue2090] __import__ with fromlist=[''] causes double initialization of modules

2008-03-19 Thread Brett Cannon
Brett Cannon <[EMAIL PROTECTED]> added the comment: As you said, it's a hack, so supporting an abuse of the API is not reasonable. You don't have to set the fromlist for the import to work. And if you are doing it to get the tail module, you can write some simple code to use getattr() to walk dow

[issue2090] __import__ with fromlist=[''] causes double initialization of modules

2008-03-18 Thread Sean Reifschneider
Changes by Sean Reifschneider <[EMAIL PROTECTED]>: -- assignee: -> brett.cannon nosy: +brett.cannon priority: -> normal __ Tracker <[EMAIL PROTECTED]> __

[issue2090] __import__ with fromlist=[''] causes double initialization of modules

2008-02-12 Thread hauser
New submission from hauser: This construction: __import__( 'pkg', {}, {}, [''] ) Will cause double initialization of package 'pkg', once with name 'pkg' and second one with name 'pkg.' (trailing dot). Implementation tries to import subpackage of 'pkg' with empty name, and imports the same packa