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
a699a2d0
Commit
a699a2d0
authored
Dec 18, 2011
by
Michael Foord
Browse files
Options
Browse Files
Download
Plain Diff
Merge 3.2
parents
8f23be71
a51623b1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
4 deletions
+14
-4
Lib/inspect.py
Lib/inspect.py
+6
-4
Lib/test/test_inspect.py
Lib/test/test_inspect.py
+5
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/inspect.py
View file @
a699a2d0
...
...
@@ -1109,7 +1109,7 @@ def _check_instance(obj, attr):
def
_check_class
(
klass
,
attr
):
for
entry
in
_static_getmro
(
klass
):
if
not
_shadowed_dict
(
type
(
entry
))
:
if
_shadowed_dict
(
type
(
entry
))
is
_sentinel
:
try
:
return
entry
.
__dict__
[
attr
]
except
KeyError
:
...
...
@@ -1134,8 +1134,8 @@ def _shadowed_dict(klass):
if
not
(
type
(
class_dict
)
is
types
.
GetSetDescriptorType
and
class_dict
.
__name__
==
"__dict__"
and
class_dict
.
__objclass__
is
entry
):
return
True
return
False
return
class_dict
return
_sentinel
def
getattr_static
(
obj
,
attr
,
default
=
_sentinel
):
"""Retrieve attributes without triggering dynamic lookup via the
...
...
@@ -1151,7 +1151,9 @@ def getattr_static(obj, attr, default=_sentinel):
instance_result
=
_sentinel
if
not
_is_type
(
obj
):
klass
=
type
(
obj
)
if
not
_shadowed_dict
(
klass
):
dict_attr
=
_shadowed_dict
(
klass
)
if
(
dict_attr
is
_sentinel
or
type
(
dict_attr
)
is
types
.
MemberDescriptorType
):
instance_result
=
_check_instance
(
obj
,
attr
)
else
:
klass
=
obj
...
...
Lib/test/test_inspect.py
View file @
a699a2d0
...
...
@@ -1004,6 +1004,11 @@ class TestGetattrStatic(unittest.TestCase):
self
.
assertEqual
(
inspect
.
getattr_static
(
instance
,
"spam"
),
42
)
self
.
assertFalse
(
Thing
.
executed
)
def
test_module
(
self
):
sentinel
=
object
()
self
.
assertIsNot
(
inspect
.
getattr_static
(
sys
,
"version"
,
sentinel
),
sentinel
)
class
TestGetGeneratorState
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
Misc/NEWS
View file @
a699a2d0
...
...
@@ -419,6 +419,9 @@ Core and Builtins
Library
-------
-
Issue
#
11813
:
Fix
inspect
.
getattr_static
for
modules
.
Patch
by
Andreas
St
ü
hrk
.
-
Issue
#
7502
:
Fix
equality
comparison
for
DocTestCase
instances
.
Patch
by
C
é
dric
Krier
.
...
...
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