Issue35717
Created on 2019-01-11 15:08 by vstinner, last changed 2019-01-30 17:38 by vstinner. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 11523 | merged | serhiy.storchaka, 2019-01-11 17:36 | |
| PR 11669 | merged | miss-islington, 2019-01-24 19:43 | |
| PR 11669 | merged | miss-islington, 2019-01-24 19:43 | |
| PR 11669 | merged | miss-islington, 2019-01-24 19:43 | |
| Messages (11) | |||
|---|---|---|---|
| msg333474 - (view) | Author: STINNER Victor (vstinner) * | Date: 2019-01-11 15:08 | |
sys._getframe(2) fails in the following example:
code = "from enum import Enum; Enum('Animal', 'ANT BEE CAT DOG')"
code = compile(code, "<string>", "exec")
global_ns = {}
local_ls = {}
exec(code, global_ns, local_ls)
Error with Python 3.7.2 (Fedora 29):
Traceback (most recent call last):
File "x.py", line 5, in <module>
exec(code, global_ns, local_ls)
File "<string>", line 1, in <module>
File "/usr/lib64/python3.7/enum.py", line 311, in __call__
return cls._create_(value, names, module=module, qualname=qualname, type=type, start=start)
File "/usr/lib64/python3.7/enum.py", line 429, in _create_
module = sys._getframe(2).f_globals['__name__']
KeyError: '__name__'
|
|||
| msg333475 - (view) | Author: STINNER Victor (vstinner) * | Date: 2019-01-11 15:08 | |
The bug has been reported in my perf project: https://github.com/vstinner/perf/issues/49 |
|||
| msg333477 - (view) | Author: Ethan Furman (ethan.furman) * | Date: 2019-01-11 15:19 | |
Looks like the following code:
if module is None:
try:
module = sys._getframe(2).f_globals['__name__']
except (AttributeError, ValueError) as exc:
pass
needs to have `KeyError` added to the `except` line.
|
|||
| msg333485 - (view) | Author: Ethan Furman (ethan.furman) * | Date: 2019-01-11 16:50 | |
Marking this as "easy". It needs a test showing the failing behavior, then the fix. |
|||
| msg333486 - (view) | Author: Rémi Lapeyre (remi.lapeyre) * | Date: 2019-01-11 17:08 | |
Hi, PR https://github.com/python/cpython/pull/11521 should fix the issue. |
|||
| msg333489 - (view) | Author: STINNER Victor (vstinner) * | Date: 2019-01-11 17:16 | |
> Hi, PR https://github.com/python/cpython/pull/11521 should fix the issue. It's PR 11523. |
|||
| msg333490 - (view) | Author: Ethan Furman (ethan.furman) * | Date: 2019-01-11 17:16 | |
That PR does not go with this issue. ;) |
|||
| msg333492 - (view) | Author: STINNER Victor (vstinner) * | Date: 2019-01-11 17:20 | |
> That PR does not go with this issue. ;) It does. You removed the link to PR 11523 which is a fix for this issue. |
|||
| msg334318 - (view) | Author: miss-islington (miss-islington) | Date: 2019-01-24 19:43 | |
New changeset 1fd06f1eca80dcbf3a916133919482a8327f3da4 by Miss Islington (bot) (Rémi Lapeyre) in branch 'master': bpo-35717: Fix KeyError exception raised when using enums and compile (GH-11523) https://github.com/python/cpython/commit/1fd06f1eca80dcbf3a916133919482a8327f3da4 |
|||
| msg334580 - (view) | Author: STINNER Victor (vstinner) * | Date: 2019-01-30 17:36 | |
New changeset 1c79891026c57046f5ac596080ea60c515e0560a by Victor Stinner (Miss Islington (bot)) in branch '3.7': bpo-35717: Fix KeyError exception raised when using enums and compile (GH-11523) (GH-11669) https://github.com/python/cpython/commit/1c79891026c57046f5ac596080ea60c515e0560a |
|||
| msg334581 - (view) | Author: STINNER Victor (vstinner) * | Date: 2019-01-30 17:38 | |
I was confused with PR, so here you have: * master: https://github.com/python/cpython/pull/11523 * 3.7: https://github.com/python/cpython/pull/11669 Both are merged, so I close the issue. Thanks Rémi Lapeyre for the fix! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2019-01-30 17:38:33 | vstinner | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2019-01-30 17:38:01 | vstinner | set | messages: + msg334581 |
| 2019-01-30 17:36:54 | vstinner | set | messages: + msg334580 |
| 2019-01-24 19:43:52 | miss-islington | set | pull_requests: + pull_request11480 |
| 2019-01-24 19:43:43 | miss-islington | set | pull_requests: + pull_request11479 |
| 2019-01-24 19:43:33 | miss-islington | set | pull_requests: + pull_request11478 |
| 2019-01-24 19:43:17 | miss-islington | set | nosy:
+ miss-islington messages: + msg334318 |
| 2019-01-11 21:14:10 | levkivskyi | set | nosy:
+ levkivskyi |
| 2019-01-11 17:36:13 | serhiy.storchaka | set | pull_requests: + pull_request11108 |
| 2019-01-11 17:20:33 | vstinner | set | messages: + msg333492 |
| 2019-01-11 17:16:53 | ethan.furman | set | pull_requests: - pull_request11107 |
| 2019-01-11 17:16:18 | ethan.furman | set | messages: + msg333490 |
| 2019-01-11 17:16:08 | vstinner | set | messages: + msg333489 |
| 2019-01-11 17:08:17 | remi.lapeyre | set | messages: + msg333486 |
| 2019-01-11 17:07:22 | remi.lapeyre | set | keywords:
+ patch stage: test needed -> patch review pull_requests: + pull_request11107 |
| 2019-01-11 16:50:22 | ethan.furman | set | keywords:
+ easy messages: + msg333485 |
| 2019-01-11 16:46:15 | remi.lapeyre | set | nosy:
+ remi.lapeyre |
| 2019-01-11 15:19:35 | ethan.furman | set | assignee: ethan.furman type: behavior messages: + msg333477 stage: test needed |
| 2019-01-11 15:08:42 | vstinner | set | messages: + msg333475 |
| 2019-01-11 15:08:13 | vstinner | create | |