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
e5bb2964
Commit
e5bb2964
authored
Sep 21, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #930 from kmod/flslots
Set cls->has_getattribute for extension classes
parents
e039ff0f
05922941
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
src/capi/typeobject.cpp
src/capi/typeobject.cpp
+20
-0
test/tests/capi_slots.py
test/tests/capi_slots.py
+10
-0
No files found.
src/capi/typeobject.cpp
View file @
e5bb2964
...
...
@@ -1940,6 +1940,21 @@ void fixup_slot_dispatchers(BoxedClass* self) noexcept {
p
=
update_one_slot
(
self
,
p
);
}
void
fixup_pyston_slot_dispatchers
(
BoxedClass
*
self
)
noexcept
{
init_slotdefs
();
const
slotdef
*
p
=
slotdefs
;
while
(
p
->
name
.
size
()
!=
0
)
{
// Skip slotdefs that are either in the CPython slots (things before tp_version_tag), or
// things that are pointers into the tp_as_foo structs (which are represented as offsets
// past the end of BoxedClass, ie into BoxedHeapClass)
if
(
p
->
offset
<=
offsetof
(
BoxedClass
,
tp_version_tag
)
||
p
->
offset
>=
sizeof
(
BoxedClass
))
++
p
;
else
p
=
update_one_slot
(
self
,
p
);
}
}
static
int
update_subclasses
(
PyTypeObject
*
type
,
PyObject
*
name
,
update_callback
callback
,
void
*
data
)
noexcept
{
if
(
callback
(
type
,
data
)
<
0
)
return
-
1
;
...
...
@@ -3375,6 +3390,11 @@ extern "C" int PyType_Ready(PyTypeObject* cls) noexcept {
assert
(
!
(
cls
->
instancesHaveHCAttrs
()
&&
cls
->
instancesHaveDictAttrs
()));
// We need to apply any pyston-specific slotdefs to extension types.
// Extensions are usually responsible for setting their own tp_ slots if they
// want them, but they don't know about our custom ones so we need to fill those in.
fixup_pyston_slot_dispatchers
(
cls
);
if
(
Py_TPFLAGS_BASE_EXC_SUBCLASS
&
cls
->
tp_flags
)
{
exception_types
.
push_back
(
cls
);
}
...
...
test/tests/capi_slots.py
View file @
e5bb2964
...
...
@@ -224,3 +224,13 @@ slots_test.call_funcs(C())
class
C
(
object
):
val
=
slots_test
.
SlotsTesterDescrGet
()
print
C
().
val
# Test that extension classes (in this case, weakref.proxy) get our custom class-level flags
# (in this case, has_getattribute)
import
weakref
class
C
(
object
):
pass
c
=
C
()
proxy
=
weakref
.
proxy
(
c
)
print
isinstance
(
proxy
,
C
)
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