[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