[issue14285] Traceback wrong on ImportError while executing a package

2015-12-10 Thread Nick Coghlan
Nick Coghlan added the comment: Leaving Python 2.7 alone makes sense to me - runpy is heavily dependent on the import system, so there are going to be limits to the improvements that can be made there. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___

[issue14285] Traceback wrong on ImportError while executing a package

2015-12-10 Thread Martin Panter
Martin Panter added the comment: I committed a slightly modified version to 3.5+. I stopped wrapping the new ImportError, and let the existing find_spec() handler wrap it instead. That way the existing error messages stay the same. However I cannot figure out an easy way to do a similar fix fo

[issue14285] Traceback wrong on ImportError while executing a package

2015-12-10 Thread Roundup Robot
Roundup Robot added the comment: New changeset 3202d143a194 by Martin Panter in branch '3.5': Issue #14285: Do not catch exceptions initializing any ancestor package https://hg.python.org/cpython/rev/3202d143a194 New changeset a526ebcfd31d by Martin Panter in branch 'default': Issue #14285: Merg

[issue14285] Traceback wrong on ImportError while executing a package

2015-12-06 Thread Nick Coghlan
Nick Coghlan added the comment: +1, latest iteration looks good to me. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Uns

[issue14285] Traceback wrong on ImportError while executing a package

2015-12-06 Thread Martin Panter
Martin Panter added the comment: The test suite does check run_module() with some relative names; see test_invalid_names() in test_runpy. But there does not appear to be a test for “python -m .relative”. Changes in init-ancestor.3.patch: * Added a comment explaining the exception handling * A

[issue14285] Traceback wrong on ImportError while executing a package

2015-12-06 Thread Nick Coghlan
Nick Coghlan added the comment: Ah, I think I understand the problem you're getting at now: * if the parent package is missing entirely, we still want to suppress the traceback by throwing the runpy specific exception * if the parent package is present, but one of the modules *that* tries to i

[issue14285] Traceback wrong on ImportError while executing a package

2015-12-05 Thread Martin Panter
Martin Panter added the comment: init-ancestor.2.patch implements the single __import__ with ImportError.name checking -- Added file: http://bugs.python.org/file41254/init-ancestor.2.patch ___ Python tracker _

[issue14285] Traceback wrong on ImportError while executing a package

2015-12-05 Thread Martin Panter
Martin Panter added the comment: Yes, the package is all we need to import. I understand this bug is all about importing the parent package, and not __main__. If you read the original report, it is __init__.py that is trying to import a missing module. -- _

[issue14285] Traceback wrong on ImportError while executing a package

2015-12-05 Thread Nick Coghlan
Nick Coghlan added the comment: That import will only import the parent package (if there is one), not the module itself. Imports from __main__ will still happen during the exec call later on. -- ___ Python tracker

[issue14285] Traceback wrong on ImportError while executing a package

2015-12-04 Thread Martin Panter
Martin Panter added the comment: I think the problem with doing a blind import of the parent package is it would be hard to differentiate between the ImportError when the package (or an ancestor) is missing, versus a user-generated ImportError. Maybe you could inspect the exception as a workar

[issue14285] Traceback wrong on ImportError while executing a package

2015-12-03 Thread Nick Coghlan
Nick Coghlan added the comment: I'm wondering if there might be a simpler option: use rpartition() to strip off any trailing segment (whether that's "__main__" or not), and then always do a plain dynamic import of that package (if any). Something like the following at the start of _get_module_

[issue14285] Traceback wrong on ImportError while executing a package

2015-12-03 Thread Martin Panter
Martin Panter added the comment: Even with my committed fix, tracebacks triggered by initializing a parent package are still suppressed: $ ./python -m hello Traceback (most recent call last): File "/media/disk/home/proj/python/cpython/Lib/runpy.py", line 158, in _run_module_as_main mod_n

[issue14285] Traceback wrong on ImportError while executing a package

2015-12-03 Thread Roundup Robot
Roundup Robot added the comment: New changeset c4e950338e79 by Martin Panter in branch '2.7': Issue #14285: Do not catch ImportError from __init__.py in runpy https://hg.python.org/cpython/rev/c4e950338e79 -- ___ Python tracker

[issue14285] Traceback wrong on ImportError while executing a package

2015-12-02 Thread Roundup Robot
Roundup Robot added the comment: New changeset 784a64a21fd0 by Martin Panter in branch '3.5': Issue #14285: Do not catch __init__.py exceptions in runpy https://hg.python.org/cpython/rev/784a64a21fd0 New changeset 01397c11ebb8 by Martin Panter in branch 'default': Issue #14285: Merge runpy excep

[issue14285] Traceback wrong on ImportError while executing a package

2015-12-02 Thread Nick Coghlan
Nick Coghlan added the comment: Right, while I agree this is a bug fix that makes sense to apply to 2.7 and 3.5, it's also a large enough change to runpy's control flow logic that I'm wary of including it in the final 3.4 binary release. -- ___ Pyth

[issue14285] Traceback wrong on ImportError while executing a package

2015-12-02 Thread Martin Panter
Martin Panter added the comment: Thanks for the review Nick. You removed Python 3.4 from the versions; do you think it is not worth the risk committing in 3.4? I understand the deadline for the final release of 3.4 is the end of this week. -- ___ Py

[issue14285] Traceback wrong on ImportError while executing a package

2015-12-01 Thread Nick Coghlan
Nick Coghlan added the comment: Martin, your patch looks good to me, and is at the very least an improvement over the status quo (which clearly traps exceptions that it shouldn't), so I'd say go ahead and apply it. Thanks for digging into this and figuring out a clean solution. -- ver

[issue14285] Traceback wrong on ImportError while executing a package

2015-12-01 Thread Martin Panter
Changes by Martin Panter : Added file: http://bugs.python.org/file41205/internal-error.patch ___ Python tracker ___ ___ Python-bugs-list maili

[issue14285] Traceback wrong on ImportError while executing a package

2015-12-01 Thread Martin Panter
Martin Panter added the comment: Now I have a deeper understanding I think this can be handled separately to Issue 16217. This patch pulls together my previous two patches, and adds a fix. There are two aspects of my fix: 1. Import the package before calling find_spec() on the __main__ submod

[issue14285] Traceback wrong on ImportError while executing a package

2015-11-30 Thread Martin Panter
Martin Panter added the comment: I suspect a proper solution of this bug would also help with Issue 16217 (provide only the relevant traceback for exceptions from user code). -- ___ Python tracker

[issue14285] Traceback wrong on ImportError while executing a package

2015-03-11 Thread Martin Panter
Martin Panter added the comment: Posting finding-spec.patch which just has another test I wrote. It tests if AttributeError/ValueError/TypeError gets wrapped in the “finding spec” ImportError, though I’m not sure if this is a bug or a feature, hence I kept it separate. And again I’m not sure o

[issue14285] Traceback wrong on ImportError while executing a package

2015-03-11 Thread Martin Panter
Martin Panter added the comment: The patches at Issue 19771 should remove the part of the message that incorrectly says “. . . is a package and cannot be directly executed”. However that still leaves the problem of the suppressed traceback. I am posting runpy-traceback.patch here which adds so

[issue14285] Traceback wrong on ImportError while executing a package

2015-03-10 Thread Martin Panter
Martin Panter added the comment: Closely related: Issue 19771, which seems to be complaining about a the error message when __main__.py generates an ImportError. -- ___ Python tracker _

[issue14285] Traceback wrong on ImportError while executing a package

2015-02-21 Thread Martin Panter
Martin Panter added the comment: The relevant code is in the _get_module_details() function at Lib/runpy.py:101. There are a few of things going on: 1. The code is calling importlib.util.find_spec(".__main__"), and handles various kinds of exceptions by wrapping them in an ImportError, adding

[issue14285] Traceback wrong on ImportError while executing a package

2014-09-16 Thread Rob Agar
Rob Agar added the comment: The message also needs to include the file and line number of the ImportError. -- ___ Python tracker ___ _

[issue14285] Traceback wrong on ImportError while executing a package

2014-09-16 Thread Rob Agar
Changes by Rob Agar : -- nosy: +robagar ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org

[issue14285] Traceback wrong on ImportError while executing a package

2014-07-17 Thread Berker Peksag
Changes by Berker Peksag : -- nosy: +eric.snow ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyt

[issue14285] Traceback wrong on ImportError while executing a package

2014-07-17 Thread Martin Panter
Martin Panter added the comment: A file called “package/__main__.py” is executed as a script by “python -m package”. See . I’ve came across this issue myself. You don’t even need the __main__.py file to be doing anything special, as long as th

[issue14285] Traceback wrong on ImportError while executing a package

2014-07-16 Thread Mark Lawrence
Mark Lawrence added the comment: I've no idea what having a file called __main__.py is likely to do so can someone comment please. -- nosy: +BreamoreBoy ___ Python tracker ___ _

[issue14285] Traceback wrong on ImportError while executing a package

2013-02-01 Thread Brett Cannon
Changes by Brett Cannon : -- nosy: -brett.cannon ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.p

[issue14285] Traceback wrong on ImportError while executing a package

2012-03-13 Thread Éric Araujo
Changes by Éric Araujo : -- nosy: +brett.cannon, eric.araujo, ncoghlan ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubs

[issue14285] Traceback wrong on ImportError while executing a package

2012-03-12 Thread Marc Schlaich
New submission from Marc Schlaich : It is very simple to reproduce this error. There is an executable package: package/ __init__.py __main__.py The __init__ imports a missing module: import missing_module And the __main__ imports from it: from . import missing_module Now I