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
e380e098
Commit
e380e098
authored
Mar 17, 2014
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Plain Diff
merge 3.4
parents
6373ba51
df813791
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
9 deletions
+16
-9
Lib/test/test_descr.py
Lib/test/test_descr.py
+8
-0
Objects/typeobject.c
Objects/typeobject.c
+8
-9
No files found.
Lib/test/test_descr.py
View file @
e380e098
...
...
@@ -4414,6 +4414,14 @@ order (MRO) for bases """
self
.
assertRaises
(
TypeError
,
case
,
1
,
2
,
3
)
self
.
assertRaises
(
TypeError
,
case
,
1
,
2
,
foo
=
3
)
def
test_subclassing_does_not_duplicate_dict_descriptors
(
self
):
class
Base
:
pass
class
Sub
(
Base
):
pass
self
.
assertIn
(
"__dict__"
,
Base
.
__dict__
)
self
.
assertNotIn
(
"__dict__"
,
Sub
.
__dict__
)
class
DictProxyTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
Objects/typeobject.c
View file @
e380e098
...
...
@@ -2472,12 +2472,6 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
type
->
tp_dictoffset
=
slotoffset
;
slotoffset
+=
sizeof
(
PyObject
*
);
}
else
if
(
!
type
->
tp_dictoffset
)
{
type
->
tp_dictoffset
=
base
->
tp_dictoffset
;
}
if
(
type
->
tp_dictoffset
)
{
et
->
ht_cached_keys
=
_PyDict_NewKeysForClass
();
}
if
(
add_weak
)
{
assert
(
!
base
->
tp_itemsize
);
type
->
tp_weaklistoffset
=
slotoffset
;
...
...
@@ -2527,6 +2521,10 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
/* Put the proper slots in place */
fixup_slot_dispatchers
(
type
);
if
(
type
->
tp_dictoffset
)
{
et
->
ht_cached_keys
=
_PyDict_NewKeysForClass
();
}
Py_DECREF
(
dict
);
return
(
PyObject
*
)
type
;
...
...
@@ -2643,9 +2641,6 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
type
->
tp_doc
=
tp_doc
;
}
}
if
(
type
->
tp_dictoffset
)
{
res
->
ht_cached_keys
=
_PyDict_NewKeysForClass
();
}
if
(
type
->
tp_dealloc
==
NULL
)
{
/* It's a heap type, so needs the heap types' dealloc.
subtype_dealloc will call the base type's tp_dealloc, if
...
...
@@ -2656,6 +2651,10 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
if
(
PyType_Ready
(
type
)
<
0
)
goto
fail
;
if
(
type
->
tp_dictoffset
)
{
res
->
ht_cached_keys
=
_PyDict_NewKeysForClass
();
}
/* Set type.__module__ */
s
=
strrchr
(
spec
->
name
,
'.'
);
if
(
s
!=
NULL
)
...
...
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