Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1fd06f1e
Commit
1fd06f1e
authored
Jan 24, 2019
by
Rémi Lapeyre
Committed by
Miss Islington (bot)
Jan 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-35717: Fix KeyError exception raised when using enums and compile (GH-11523)
https://bugs.python.org/issue17467
parent
5c8f5376
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
1 deletion
+13
-1
Lib/enum.py
Lib/enum.py
+1
-1
Lib/test/test_enum.py
Lib/test/test_enum.py
+9
-0
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS.d/next/Library/2019-01-11-17-56-15.bpo-35717.6TDTB_.rst
...S.d/next/Library/2019-01-11-17-56-15.bpo-35717.6TDTB_.rst
+2
-0
No files found.
Lib/enum.py
View file @
1fd06f1e
...
...
@@ -419,7 +419,7 @@ class EnumMeta(type):
if
module
is
None
:
try
:
module
=
sys
.
_getframe
(
2
).
f_globals
[
'__name__'
]
except
(
AttributeError
,
ValueError
)
as
exc
:
except
(
AttributeError
,
ValueError
,
KeyError
)
as
exc
:
pass
if
module
is
None
:
_make_class_unpicklable
(
enum_class
)
...
...
Lib/test/test_enum.py
View file @
1fd06f1e
...
...
@@ -1858,6 +1858,15 @@ class TestEnum(unittest.TestCase):
REVERT_ALL
=
"REVERT_ALL"
RETRY
=
"RETRY"
def
test_empty_globals
(
self
):
# bpo-35717: sys._getframe(2).f_globals['__name__'] fails with KeyError
# when using compile and exec because f_globals is empty
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
)
class
TestOrder
(
unittest
.
TestCase
):
...
...
Misc/ACKS
View file @
1fd06f1e
...
...
@@ -906,6 +906,7 @@ Glenn Langford
Andrew Langmead
Wolfgang Langner
Detlef Lannert
Rémi Lapeyre
Soren Larsen
Amos Latteier
Piers Lauder
...
...
Misc/NEWS.d/next/Library/2019-01-11-17-56-15.bpo-35717.6TDTB_.rst
0 → 100644
View file @
1fd06f1e
Fix KeyError exception raised when using enums and compile. Patch
contributed by Rémi Lapeyre.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment