[issue40249] __import__ doesn't honour globals

2020-04-15 Thread Brett Cannon
Brett Cannon added the comment: Algorithm is documented as part of the language reference: https://docs.python.org/3/reference/import.html -- ___ Python tracker ___ _

[issue40249] __import__ doesn't honour globals

2020-04-14 Thread Stefan Seefeld
Stefan Seefeld added the comment: I'm not entirely sure, but have to admit that the sentence "The function imports the module name, potentially using the given globals and locals to determine how to interpret the name in a package context." is a bit obscure. What does "determine how to inter

[issue40249] __import__ doesn't honour globals

2020-04-14 Thread Brett Cannon
Brett Cannon added the comment: How would you propose changing the wording found at https://docs.python.org/3/library/functions.html?highlight=__import__#__import__? -- nosy: +brett.cannon ___ Python tracker __

[issue40249] __import__ doesn't honour globals

2020-04-10 Thread Stefan Seefeld
Stefan Seefeld added the comment: OK, thanks for the clarification. I think this is obscure enough to warrant at least a paragraph or two to clarify the semantics of these arguments. I changed the issue "components" and "type" to reflect that. -- assignee: -> docs@python components:

[issue40249] __import__ doesn't honour globals

2020-04-10 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: globals is only used when level > 0, to resolve relative names like in `import ..foo`. You have to set keys __package__ and __spec__ or __name__ and __path__ in this case. -- nosy: +serhiy.storchaka ___ Python t

[issue40249] __import__ doesn't honour globals

2020-04-10 Thread Stefan Seefeld
New submission from Stefan Seefeld : I'm trying to import custom scripts that expect the presence of certain variables in the global namespace. It seems `__import__('script', globals=dict(foo='bar'))` doesn't have the expected effect of injecting "foo" into the namespace and making it accessib