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
fbb9c678
Commit
fbb9c678
authored
Jan 06, 2016
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't overwrite empty tp_new when type is inheriting from object
The capi uses this to deny instancing a type directly.
parent
25847f9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
src/capi/typeobject.cpp
src/capi/typeobject.cpp
+3
-1
test/tests/capi_slots.py
test/tests/capi_slots.py
+8
-0
No files found.
src/capi/typeobject.cpp
View file @
fbb9c678
...
...
@@ -3427,6 +3427,9 @@ extern "C" int PyType_Ready(PyTypeObject* cls) noexcept {
// RELEASE_ASSERT(cls->tp_traverse == NULL, "");
// RELEASE_ASSERT(cls->tp_clear == NULL, "");
// set this flag early because some function check if it is set pretty early
cls
->
is_user_defined
=
true
;
assert
(
cls
->
attrs
.
hcls
==
NULL
);
new
(
&
cls
->
attrs
)
HCAttrs
(
HiddenClass
::
makeSingleton
());
#define INITIALIZE(a) new (&(a)) decltype(a)
...
...
@@ -3510,7 +3513,6 @@ extern "C" int PyType_Ready(PyTypeObject* cls) noexcept {
cls
->
gc_visit
=
&
conservativeAndBasesGCHandler
;
else
cls
->
gc_visit
=
&
conservativeGCHandler
;
cls
->
is_user_defined
=
true
;
if
(
!
cls
->
instancesHaveHCAttrs
()
&&
cls
->
tp_base
)
{
...
...
test/tests/capi_slots.py
View file @
fbb9c678
...
...
@@ -44,6 +44,14 @@ print slots_test.SlotsTesterNum(0) == slots_test.SlotsTesterNum(1)
for
i
in
slots_test
.
SlotsTesterSeq
(
6
):
print
i
try
:
# seqiter.tp_new is NULL so we should not be allowed to create an instance
slot_tester_seqiter
=
type
(
iter
(
slots_test
.
SlotsTesterSeq
(
6
)))
print
slot_tester_seqiter
slot_tester_seqiter
()
except
Exception
as
e
:
print
e
su
=
slots_test
.
SlotsTesterSub
(
5
)
print
su
...
...
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