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
2c05a2e0
Commit
2c05a2e0
authored
Oct 31, 2012
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
do safety checks on __qualname__ assignment
parent
8afa7fa5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
0 deletions
+13
-0
Lib/test/test_descr.py
Lib/test/test_descr.py
+8
-0
Misc/NEWS
Misc/NEWS
+3
-0
Objects/typeobject.c
Objects/typeobject.c
+2
-0
No files found.
Lib/test/test_descr.py
View file @
2c05a2e0
...
...
@@ -4502,6 +4502,14 @@ order (MRO) for bases """
self
.
assertEqual
(
float
.
real
.
__qualname__
,
'float.real'
)
self
.
assertEqual
(
int
.
__add__
.
__qualname__
,
'int.__add__'
)
class
X
:
pass
with
self
.
assertRaises
(
TypeError
):
del
X
.
__qualname__
self
.
assertRaises
(
TypeError
,
type
.
__dict__
[
'__qualname__'
].
__set__
,
str
,
'Oink'
)
def
test_qualname_dict
(
self
):
ns
=
{
'__qualname__'
:
'some.name'
}
tp
=
type
(
'Foo'
,
(),
ns
)
...
...
Misc/NEWS
View file @
2c05a2e0
...
...
@@ -12,6 +12,9 @@ What's New in Python 3.3.1?
Core and Builtins
-----------------
- Fix segfaults on setting __qualname__ on builtin types and attempting to
delete it on any type.
- Issue #16271: Fix strange bugs that resulted from __qualname__ appearing in a
class'
s
__dict__
and
on
type
.
...
...
Objects/typeobject.c
View file @
2c05a2e0
...
...
@@ -311,6 +311,8 @@ type_set_qualname(PyTypeObject *type, PyObject *value, void *context)
{
PyHeapTypeObject
*
et
;
if
(
!
check_set_special_type_attr
(
type
,
value
,
"__qualname__"
))
return
-
1
;
if
(
!
PyUnicode_Check
(
value
))
{
PyErr_Format
(
PyExc_TypeError
,
"can only assign string to %s.__qualname__, not '%s'"
,
...
...
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