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
1d6f987f
Commit
1d6f987f
authored
Dec 22, 2011
by
Michael Foord
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
a7f7cd74
29acfa99
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
4 deletions
+25
-4
Lib/inspect.py
Lib/inspect.py
+5
-4
Lib/test/test_inspect.py
Lib/test/test_inspect.py
+17
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/inspect.py
View file @
1d6f987f
...
...
@@ -1186,10 +1186,11 @@ def getattr_static(obj, attr, default=_sentinel):
if
obj
is
klass
:
# for types we check the metaclass too
for
entry
in
_static_getmro
(
type
(
klass
)):
try
:
return
entry
.
__dict__
[
attr
]
except
KeyError
:
pass
if
_shadowed_dict
(
type
(
entry
))
is
_sentinel
:
try
:
return
entry
.
__dict__
[
attr
]
except
KeyError
:
pass
if
default
is
not
_sentinel
:
return
default
raise
AttributeError
(
attr
)
...
...
Lib/test/test_inspect.py
View file @
1d6f987f
...
...
@@ -1088,6 +1088,23 @@ class TestGetattrStatic(unittest.TestCase):
self
.
assertIsNot
(
inspect
.
getattr_static
(
sys
,
"version"
,
sentinel
),
sentinel
)
def
test_metaclass_with_metaclass_with_dict_as_property
(
self
):
class
MetaMeta
(
type
):
@
property
def
__dict__
(
self
):
self
.
executed
=
True
return
dict
(
spam
=
42
)
class
Meta
(
type
,
metaclass
=
MetaMeta
):
executed
=
False
class
Thing
(
metaclass
=
Meta
):
pass
with
self
.
assertRaises
(
AttributeError
):
inspect
.
getattr_static
(
Thing
,
"spam"
)
self
.
assertFalse
(
Thing
.
executed
)
class
TestGetGeneratorState
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
Misc/NEWS
View file @
1d6f987f
...
...
@@ -422,6 +422,9 @@ Library
-
Issue
#
13620
:
Support
for
Chrome
browser
in
webbrowser
.
py
Patch
contributed
by
Arnaud
Calmettes
.
-
Issue
#
11829
:
Fix
code
execution
holes
in
inspect
.
getattr_static
for
metaclasses
with
metaclasses
.
Patch
by
Andreas
St
ü
hrk
.
-
Issue
#
12708
:
Add
starmap
()
and
starmap_async
()
methods
(
similar
to
itertools
.
starmap
())
to
multiprocessing
.
Pool
.
Patch
by
Hynek
Schlawack
.
...
...
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