[issue35358] avoid '-' in importlib.import_module and builtins.__import__

2018-11-30 Thread Guido van Rossum
Guido van Rossum added the comment: Do not change this. I'd rather see it documented that importlib can import any name as long as it doesn't contain a dot, slash or backslash. (Clearly the fact that Django loads it is an additional argument that this should be supported, not forbidden.)

[issue35358] avoid '-' in importlib.import_module and builtins.__import__

2018-11-30 Thread Eric V. Smith
Eric V. Smith added the comment: I dynamically load a lot of modules whose names contain hyphens, or are otherwise non-identifiers (like 3rdparty.py). The suggested change would break a lot of working code. The only thing I can see being possible is to add a warning that no one would

[issue35358] avoid '-' in importlib.import_module and builtins.__import__

2018-11-30 Thread Stéphane Wirtel
Stéphane Wirtel added the comment: hi @serhiy, I understand but today, by error my CI has started to run the tests of an external python package and in the tests, there was a lot of `from my-module import XYZ` but in the django project, they load this module via importlib.import_module or

[issue35358] avoid '-' in importlib.import_module and builtins.__import__

2018-11-30 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: '-' is not special. The import statement requires the module name been an identifier. This is just a requirement of Python syntax. But when pass the module name as a string, there is no such limitation in CPython. This is like an attribute name or keyword

[issue35358] avoid '-' in importlib.import_module and builtins.__import__

2018-11-30 Thread Stéphane Wirtel
New submission from Stéphane Wirtel : maybe related to this issue: https://bugs.python.org/issue18831 we can't import a module where the name contains '-', for example from my-module import my_function but with importlib.import_module we can import this module. import_module does not