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
8afa7fa5
Commit
8afa7fa5
authored
Oct 30, 2012
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't shadow the __qualname__ descriptor with __qualname__ in the class's __dict__ (closes #16271)
parent
e8ea97ff
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
9 deletions
+11
-9
Lib/test/test_descr.py
Lib/test/test_descr.py
+4
-4
Misc/NEWS
Misc/NEWS
+3
-0
Objects/typeobject.c
Objects/typeobject.c
+4
-5
No files found.
Lib/test/test_descr.py
View file @
8afa7fa5
...
...
@@ -4506,7 +4506,7 @@ order (MRO) for bases """
ns
=
{
'__qualname__'
:
'some.name'
}
tp
=
type
(
'Foo'
,
(),
ns
)
self
.
assertEqual
(
tp
.
__qualname__
,
'some.name'
)
self
.
assert
Equal
(
tp
.
__dict__
[
'__qualname__'
],
'some.name'
)
self
.
assert
NotIn
(
'__qualname__'
,
tp
.
__dict__
)
self
.
assertEqual
(
ns
,
{
'__qualname__'
:
'some.name'
})
ns
=
{
'__qualname__'
:
1
}
...
...
@@ -4564,7 +4564,7 @@ class DictProxyTests(unittest.TestCase):
keys
=
list
(
it
)
keys
.
sort
()
self
.
assertEqual
(
keys
,
[
'__dict__'
,
'__doc__'
,
'__module__'
,
'__
qualname__'
,
'__
weakref__'
,
'meth'
])
'__weakref__'
,
'meth'
])
@
unittest
.
skipIf
(
hasattr
(
sys
,
'gettrace'
)
and
sys
.
gettrace
(),
'trace function introduces __local__'
)
...
...
@@ -4573,7 +4573,7 @@ class DictProxyTests(unittest.TestCase):
it
=
self
.
C
.
__dict__
.
values
()
self
.
assertNotIsInstance
(
it
,
list
)
values
=
list
(
it
)
self
.
assertEqual
(
len
(
values
),
6
)
self
.
assertEqual
(
len
(
values
),
5
)
@
unittest
.
skipIf
(
hasattr
(
sys
,
'gettrace'
)
and
sys
.
gettrace
(),
'trace function introduces __local__'
)
...
...
@@ -4584,7 +4584,7 @@ class DictProxyTests(unittest.TestCase):
keys
=
[
item
[
0
]
for
item
in
it
]
keys
.
sort
()
self
.
assertEqual
(
keys
,
[
'__dict__'
,
'__doc__'
,
'__module__'
,
'__
qualname__'
,
'__
weakref__'
,
'meth'
])
'__weakref__'
,
'meth'
])
def
test_dict_type_with_metaclass
(
self
):
# Testing type of __dict__ when metaclass set...
...
...
Misc/NEWS
View file @
8afa7fa5
...
...
@@ -12,6 +12,9 @@ What's New in Python 3.3.1?
Core and Builtins
-----------------
- Issue #16271: Fix strange bugs that resulted from __qualname__ appearing in a
class'
s
__dict__
and
on
type
.
-
Issue
#
16197
:
Update
winreg
docstrings
and
documentation
to
match
code
.
Patch
by
Zachary
Ware
.
...
...
Objects/typeobject.c
View file @
8afa7fa5
...
...
@@ -2250,11 +2250,10 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
goto
error
;
}
}
else
{
qualname
=
et
->
ht_name
;
}
Py_INCREF
(
qualname
);
et
->
ht_qualname
=
qualname
;
et
->
ht_qualname
=
qualname
?
qualname
:
et
->
ht_name
;
Py_INCREF
(
et
->
ht_qualname
);
if
(
qualname
!=
NULL
&&
PyDict_DelItem
(
dict
,
PyId___qualname__
.
object
)
<
0
)
goto
error
;
/* Set tp_doc to a copy of dict['__doc__'], if the latter is there
and is a string. The __doc__ accessor will first look for tp_doc;
...
...
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