Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Boxiang Sun
Pyston
Commits
f250404f
Commit
f250404f
authored
Jan 09, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tp_alloc test and fix the inheritance issues it exposed
parent
8f8ed3f5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
8 deletions
+17
-8
src/capi/typeobject.cpp
src/capi/typeobject.cpp
+3
-5
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+6
-2
test/test_extension/slots_test.c
test/test_extension/slots_test.c
+8
-1
No files found.
src/capi/typeobject.cpp
View file @
f250404f
...
...
@@ -1599,7 +1599,6 @@ extern "C" int PyType_Ready(PyTypeObject* cls) noexcept {
RELEASE_ASSERT
(
cls
->
tp_iternext
==
NULL
,
""
);
RELEASE_ASSERT
(
cls
->
tp_descr_get
==
NULL
,
""
);
RELEASE_ASSERT
(
cls
->
tp_descr_set
==
NULL
,
""
);
RELEASE_ASSERT
(
cls
->
tp_alloc
==
NULL
||
cls
->
tp_alloc
==
PyType_GenericAlloc
,
""
);
RELEASE_ASSERT
(
cls
->
tp_free
==
NULL
||
cls
->
tp_free
==
PyObject_Del
,
""
);
RELEASE_ASSERT
(
cls
->
tp_is_gc
==
NULL
,
""
);
RELEASE_ASSERT
(
cls
->
tp_mro
==
NULL
,
""
);
...
...
@@ -1637,10 +1636,6 @@ extern "C" int PyType_Ready(PyTypeObject* cls) noexcept {
if
(
!
cls
->
tp_new
&&
base
!=
object_cls
)
cls
->
tp_new
=
base
->
tp_new
;
if
(
!
cls
->
tp_alloc
)
{
cls
->
tp_alloc
=
reinterpret_cast
<
decltype
(
cls
->
tp_alloc
)
>
(
PyType_GenericAlloc
);
}
try
{
add_operators
(
cls
);
}
catch
(
Box
*
b
)
{
...
...
@@ -1662,6 +1657,9 @@ extern "C" int PyType_Ready(PyTypeObject* cls) noexcept {
PystonType_Ready
(
cls
);
if
(
cls
->
tp_alloc
==
&
PystonType_GenericAlloc
)
cls
->
tp_alloc
=
&
PyType_GenericAlloc
;
cls
->
gc_visit
=
&
conservativeGCHandler
;
cls
->
is_user_defined
=
true
;
...
...
src/runtime/objmodel.cpp
View file @
f250404f
...
...
@@ -355,6 +355,8 @@ BoxedClass::BoxedClass(BoxedClass* base, gcvisit_func gc_visit, int attrs_offset
tp_flags
|=
Py_TPFLAGS_HEAPTYPE
;
tp_flags
|=
Py_TPFLAGS_CHECKTYPES
;
tp_flags
|=
Py_TPFLAGS_BASETYPE
;
tp_flags
|=
Py_TPFLAGS_HAVE_CLASS
;
tp_flags
|=
Py_TPFLAGS_HAVE_GC
;
tp_base
=
base
;
...
...
@@ -3353,8 +3355,10 @@ Box* typeNew(Box* _cls, Box* arg1, Box* arg2, Box** _args) {
PystonType_Ready
(
made
);
fixup_slot_dispatchers
(
made
);
made
->
tp_alloc
=
base
->
tp_alloc
;
assert
(
made
->
tp_alloc
);
if
(
base
->
tp_alloc
==
&
PystonType_GenericAlloc
)
made
->
tp_alloc
=
PystonType_GenericAlloc
;
else
made
->
tp_alloc
=
PyType_GenericAlloc
;
return
made
;
}
...
...
test/test_extension/slots_test.c
View file @
f250404f
...
...
@@ -37,6 +37,13 @@ slots_tester_init(PyObject *self, PyObject *args, PyObject *kwds)
return
0
;
}
static
PyObject
*
slots_tester_alloc
(
PyTypeObject
*
type
,
Py_ssize_t
nitems
)
{
printf
(
"slots_tester_seq.tp_alloc, %s %ld
\n
"
,
type
->
tp_name
,
nitems
);
return
PyType_GenericAlloc
(
type
,
nitems
);
}
static
long
slots_tester_seq_hash
(
slots_tester_object
*
obj
)
{
printf
(
"slots_tester_seq.__hash__
\n
"
);
return
obj
->
n
^
1
;
...
...
@@ -139,7 +146,7 @@ static PyTypeObject slots_tester_seq = {
0
,
/* tp_descr_set */
0
,
/* tp_dictoffset */
slots_tester_init
,
/* tp_init */
0
,
/* tp_alloc */
(
allocfunc
)
slots_tester_alloc
,
/* tp_alloc */
slots_tester_new
,
/* tp_new */
0
,
/* tp_free */
};
...
...
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