[issue29929] Idea: Make __main__ an implied package

Nick Coghlan report at bugs.python.org
Tue Mar 28 05:48:19 EDT 2017


Nick Coghlan added the comment:

A key enabler for actually pursuing this idea would be coming up with a feasible way of emitting a deprecation warning for code that relied on the old implicit relative imports. A reasonable fast check for that would be to:

1. Start populating a private sys._main_path_entry in the sys module in addition to including it in both __main__.__path__ and sys.path

2. During the deprecation period, emit a warning when an import is satisfied from the sys._main_path_entry directory and the fully qualified module name *doesn't* start with "__main__."

3. After the deprecation period, stop populating sys.path[0], stop setting sys._main_path_entry, and stop emitting the deprecation warning

There's still plenty of details to be worked out before this idea could become reality (especially in terms of how it relates to module execution with the -m switch), but both the idea and a managed migration away from the status quo seem like they should be feasible.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29929>
_______________________________________


More information about the Python-bugs-list mailing list