Issue17396
Created on 2013-03-11 12:03 by jgosmann, last changed 2019-04-07 08:06 by ncoghlan. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| fix-handling-of-syntax-errors.diff | jgosmann, 2013-03-11 12:03 | Reraise SyntaxError as ImportError if imported module code cannot be compiled | ||
| fix-handling-of-syntax-errors.diff | jgosmann, 2013-05-12 20:18 | Reraise SyntaxError as ImportError if imported module code cannot be compiled | review | |
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 11787 | merged | brandtbucher, 2019-02-08 03:23 | |
| PR 11787 | merged | brandtbucher, 2019-02-08 03:23 | |
| PR 11787 | merged | brandtbucher, 2019-02-08 03:24 | |
| PR 11787 | merged | brandtbucher, 2019-02-08 03:24 | |
| Messages (8) | |||
|---|---|---|---|
| msg183953 - (view) | Author: Jan Gosmann (jgosmann) * | Date: 2013-03-11 12:03 | |
Running modulefinder.ModuleFinder.run_script on a script which has an import statement with a module containing a syntax error will raise a SyntaxError exception. I think, modulefinder should instead continue its analysis and add the module to badmodules. Especially, as there are valid reasons for importing modules with syntax errors like in the following code snippet
if not python3:
from .exec_py2 import exec_
else:
from .exec_py3 import exec_
I attached a patch which changes the code to catch potential SyntaxError exceptions and change them to an ImportError.
|
|||
| msg187938 - (view) | Author: Éric Araujo (eric.araujo) * | Date: 2013-04-27 21:42 | |
Thanks for the report and patch. Could you add a test? I’m not sure where this sits on the bug vs. feature line. |
|||
| msg187941 - (view) | Author: Jan Gosmann (jgosmann) * | Date: 2013-04-27 22:03 | |
Could you point me to some documentation on how to add a test? I have not been involved in Python development so far. |
|||
| msg187960 - (view) | Author: Éric Araujo (eric.araujo) * | Date: 2013-04-28 04:19 | |
Certainly: http://docs.python.org/devguide contains information to get the source code, describes the files layout and explains how to generate a patch. You’ll find existing unit tests in Lib/test/test_modulefinder.py Feel free to ask any question you might have on this bug, or if you prefer on the friendly core-mentorship mailing list (where I am). |
|||
| msg187961 - (view) | Author: Éric Araujo (eric.araujo) * | Date: 2013-04-28 04:20 | |
I would recommend that you base your patch on the default branch, i.e. what will become Python 3.4. If we judge that this is not a new feature but actually a bug fix, the core developer who commits the patch will take care of backporting it to 2.7 and 3.3. |
|||
| msg189059 - (view) | Author: Jan Gosmann (jgosmann) * | Date: 2013-05-12 20:18 | |
Here is an updated patch, also containing a test. |
|||
| msg189060 - (view) | Author: Jan Gosmann (jgosmann) * | Date: 2013-05-12 20:19 | |
It's based on the default branch becoming 3.4. |
|||
| msg339562 - (view) | Author: Nick Coghlan (ncoghlan) * | Date: 2019-04-07 08:06 | |
Fixed for Python 3.8 via the patch for #35936. We won't be backporting that patch as it also migrates modulefinder from the deprecated imp API to support importlib one, and is hence considered overly intrusive for a bug fix release. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2019-04-07 08:06:01 | ncoghlan | set | status: open -> closed versions: + Python 3.8, - Python 3.4, Python 3.5 messages: + msg339562 resolution: fixed |
| 2019-02-08 03:24:32 | brandtbucher | set | pull_requests: + pull_request11784 |
| 2019-02-08 03:24:20 | brandtbucher | set | pull_requests: + pull_request11783 |
| 2019-02-08 03:24:09 | brandtbucher | set | pull_requests: + pull_request11782 |
| 2019-02-08 03:23:58 | brandtbucher | set | pull_requests: + pull_request11781 |
| 2014-09-01 10:28:17 | berker.peksag | set | nosy:
+ berker.peksag stage: patch review type: behavior versions: + Python 3.5 |
| 2013-05-12 20:19:21 | jgosmann | set | messages:
+ msg189060 versions: + Python 3.4, - Python 2.7 |
| 2013-05-12 20:18:17 | jgosmann | set | files:
+ fix-handling-of-syntax-errors.diff messages: + msg189059 |
| 2013-04-28 04:20:51 | eric.araujo | set | nosy:
+ brett.cannon, ncoghlan, eric.snow messages: + msg187961 |
| 2013-04-28 04:19:07 | eric.araujo | set | messages: + msg187960 |
| 2013-04-27 22:06:16 | flox | set | nosy:
+ flox |
| 2013-04-27 22:03:29 | jgosmann | set | messages: + msg187941 |
| 2013-04-27 21:42:02 | eric.araujo | set | nosy:
+ r.david.murray, eric.araujo messages: + msg187938 |
| 2013-03-11 12:03:45 | jgosmann | create | |