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
00e024af
Commit
00e024af
authored
Mar 22, 2016
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix abstractmethods check
parent
b0959d9e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
12 deletions
+28
-12
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+1
-1
src/runtime/list.cpp
src/runtime/list.cpp
+1
-0
src/runtime/types.cpp
src/runtime/types.cpp
+26
-11
No files found.
src/runtime/builtin_modules/builtins.cpp
View file @
00e024af
...
...
@@ -441,10 +441,10 @@ Box* notimplementedRepr(Box* self) {
}
Box
*
sorted
(
Box
*
obj
,
Box
*
cmp
,
Box
*
key
,
Box
**
args
)
{
assert
(
0
&&
"check refcounting"
);
Box
*
reverse
=
args
[
0
];
BoxedList
*
rtn
=
new
BoxedList
();
KEEP_ALIVE
(
rtn
);
for
(
Box
*
e
:
obj
->
pyElements
())
{
listAppendInternalStolen
(
rtn
,
e
);
}
...
...
src/runtime/list.cpp
View file @
00e024af
...
...
@@ -901,6 +901,7 @@ public:
};
void
listSort
(
BoxedList
*
self
,
Box
*
cmp
,
Box
*
key
,
Box
*
reverse
)
{
assert
(
0
&&
"check refcounting"
);
assert
(
PyList_Check
(
self
));
if
(
cmp
==
None
)
...
...
src/runtime/types.cpp
View file @
00e024af
...
...
@@ -2883,20 +2883,28 @@ static void typeSetAbstractMethods(Box* _type, PyObject* value, void* context) {
throwCAPIException
();
}
static
Box
*
typeAbstractMethods
(
Box
*
_type
,
void
*
)
{
RELEASE_ASSERT
(
PyType_Check
(
_type
),
""
);
PyTypeObject
*
type
=
static_cast
<
PyTypeObject
*>
(
_type
);
PyObject
*
mod
=
NULL
;
static
PyObject
*
type_abstractmethods
(
PyTypeObject
*
type
,
void
*
context
)
noexcept
{
PyObject
*
mod
=
NULL
;
/* type itself has an __abstractmethods__ descriptor (this). Don't return
that. */
if
(
type
!=
&
PyType_Type
)
mod
=
PyDict_GetItemString
(
type
->
tp_dict
,
"__abstractmethods__"
);
// mod = type->getattr(internStringMortal("__abstractmethods__"));
if
(
!
mod
)
{
raiseExcHelper
(
AttributeError
,
"__abstractmethods__"
);
PyErr_SetString
(
PyExc_AttributeError
,
"__abstractmethods__"
);
return
NULL
;
}
return
incref
(
mod
);
Py_XINCREF
(
mod
);
return
mod
;
}
static
Box
*
typeAbstractMethods
(
Box
*
_type
,
void
*
c
)
{
RELEASE_ASSERT
(
PyType_Check
(
_type
),
""
);
PyTypeObject
*
type
=
static_cast
<
PyTypeObject
*>
(
_type
);
Box
*
rtn
=
type_abstractmethods
(
type
,
c
);
if
(
!
rtn
)
throwCAPIException
();
return
rtn
;
}
static
PyObject
*
object_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
noexcept
{
...
...
@@ -2923,20 +2931,24 @@ static PyObject* object_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
/* Compute ", ".join(sorted(type.__abstractmethods__))
into joined. */
abstract_methods
=
type
AbstractM
ethods
(
type
,
NULL
);
abstract_methods
=
type
_abstractm
ethods
(
type
,
NULL
);
if
(
abstract_methods
==
NULL
)
goto
error
;
builtins
=
PyEval_GetBuiltins
();
if
(
builtins
==
NULL
)
goto
error
;
sorted
=
builtins
->
getattr
(
internStringMortal
(
"sorted"
));
// Pyston change: builtins is a module not a dict
// sorted = PyDict_GetItemString(builtins, "sorted");
sorted
=
builtins
->
getattr
(
autoDecref
(
internStringMortal
(
"sorted"
)));
if
(
sorted
==
NULL
)
goto
error
;
sorted_methods
=
PyObject_CallFunctionObjArgs
(
sorted
,
abstract_methods
,
NULL
);
if
(
sorted_methods
==
NULL
)
goto
error
;
if
(
comma
==
NULL
)
{
comma
=
PyString_InternFromString
(
", "
);
// Pyston change:
// comma = PyGC_ PyString_InternFromString(", ");
comma
=
getStaticString
(
", "
);
if
(
comma
==
NULL
)
goto
error
;
}
...
...
@@ -2951,6 +2963,9 @@ static PyObject* object_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
"with abstract methods %s"
,
type
->
tp_name
,
joined_str
);
error:
Py_XDECREF
(
joined
);
Py_XDECREF
(
sorted_methods
);
Py_XDECREF
(
abstract_methods
);
return
NULL
;
}
return
type
->
tp_alloc
(
type
,
0
);
...
...
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