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
4c729f7b
Commit
4c729f7b
authored
Mar 05, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make str more subclassing friendly
Also, try to set the HAVE_NEWBUFFER flag more accurately
parent
7de279c8
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
52 deletions
+73
-52
src/capi/abstract.cpp
src/capi/abstract.cpp
+3
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+3
-0
src/runtime/str.cpp
src/runtime/str.cpp
+57
-51
src/runtime/types.cpp
src/runtime/types.cpp
+2
-0
test/tests/str_subclassing.py
test/tests/str_subclassing.py
+8
-0
No files found.
src/capi/abstract.cpp
View file @
4c729f7b
...
@@ -135,7 +135,9 @@ extern "C" void PyBuffer_Release(Py_buffer* view) noexcept {
...
@@ -135,7 +135,9 @@ extern "C" void PyBuffer_Release(Py_buffer* view) noexcept {
PyObject
*
obj
=
view
->
obj
;
PyObject
*
obj
=
view
->
obj
;
if
(
obj
)
{
if
(
obj
)
{
assert
(
obj
->
cls
==
str_cls
);
// This is a Pyston assert
assert
(
isSubclass
(
obj
->
cls
,
str_cls
));
if
(
obj
&&
Py_TYPE
(
obj
)
->
tp_as_buffer
&&
Py_TYPE
(
obj
)
->
tp_as_buffer
->
bf_releasebuffer
)
if
(
obj
&&
Py_TYPE
(
obj
)
->
tp_as_buffer
&&
Py_TYPE
(
obj
)
->
tp_as_buffer
->
bf_releasebuffer
)
Py_TYPE
(
obj
)
->
tp_as_buffer
->
bf_releasebuffer
(
obj
,
view
);
Py_TYPE
(
obj
)
->
tp_as_buffer
->
bf_releasebuffer
(
obj
,
view
);
Py_XDECREF
(
obj
);
Py_XDECREF
(
obj
);
...
...
src/runtime/objmodel.cpp
View file @
4c729f7b
...
@@ -304,6 +304,9 @@ BoxedClass::BoxedClass(BoxedClass* base, gcvisit_func gc_visit, int attrs_offset
...
@@ -304,6 +304,9 @@ BoxedClass::BoxedClass(BoxedClass* base, gcvisit_func gc_visit, int attrs_offset
tp_flags
|=
Py_TPFLAGS_HAVE_GC
;
tp_flags
|=
Py_TPFLAGS_HAVE_GC
;
tp_flags
|=
Py_TPFLAGS_HAVE_WEAKREFS
;
tp_flags
|=
Py_TPFLAGS_HAVE_WEAKREFS
;
if
(
base
&&
(
base
->
tp_flags
&
Py_TPFLAGS_HAVE_NEWBUFFER
))
tp_flags
|=
Py_TPFLAGS_HAVE_NEWBUFFER
;
tp_base
=
base
;
tp_base
=
base
;
if
(
tp_base
)
{
if
(
tp_base
)
{
...
...
src/runtime/str.cpp
View file @
4c729f7b
This diff is collapsed.
Click to expand it.
src/runtime/types.cpp
View file @
4c729f7b
...
@@ -1320,6 +1320,8 @@ void setupRuntime() {
...
@@ -1320,6 +1320,8 @@ void setupRuntime() {
tuple_cls
->
finishInitialization
();
tuple_cls
->
finishInitialization
();
list_cls
->
finishInitialization
();
list_cls
->
finishInitialization
();
str_cls
->
tp_flags
|=
Py_TPFLAGS_HAVE_NEWBUFFER
;
module_cls
=
BoxedHeapClass
::
create
(
type_cls
,
object_cls
,
NULL
,
offsetof
(
BoxedModule
,
attrs
),
0
,
module_cls
=
BoxedHeapClass
::
create
(
type_cls
,
object_cls
,
NULL
,
offsetof
(
BoxedModule
,
attrs
),
0
,
...
...
test/tests/str_subclassing.py
0 → 100644
View file @
4c729f7b
class
MyStr
(
str
):
pass
s
=
MyStr
(
1
)
print
repr
(
s
)
import
sys
sys
.
stdout
.
write
(
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