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
1d1236b2
Commit
1d1236b2
authored
May 19, 2016
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1170 from Daetalus/numpy_update
some minor NumPy fixing
parents
da8686b1
64bc9769
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
4 deletions
+25
-4
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+1
-1
src/runtime/str.cpp
src/runtime/str.cpp
+8
-0
src/runtime/types.cpp
src/runtime/types.cpp
+9
-3
test/tests/str_functions.py
test/tests/str_functions.py
+6
-0
test/tests/wrapperdesc.py
test/tests/wrapperdesc.py
+1
-0
No files found.
src/runtime/builtin_modules/builtins.cpp
View file @
1d1236b2
...
...
@@ -1397,7 +1397,7 @@ extern "C" BORROWED(PyObject*) PyEval_GetGlobals(void) noexcept {
}
extern
"C"
BORROWED
(
PyObject
*
)
PyEval_GetBuiltins
(
void
)
noexcept
{
return
builtins_module
;
return
builtins_module
->
getAttrWrapper
()
;
}
Box
*
ellipsisRepr
(
Box
*
self
)
{
...
...
src/runtime/str.cpp
View file @
1d1236b2
...
...
@@ -1164,6 +1164,13 @@ extern "C" Box* strMod(BoxedString* lhs, Box* rhs) {
return
rtn
;
}
Box
*
strRMod
(
BoxedString
*
lhs
,
Box
*
rhs
)
{
Box
*
rtn
=
PyString_Format
(
rhs
,
lhs
);
if
(
!
rtn
)
throwCAPIException
();
return
rtn
;
}
extern
"C"
Box
*
strMul
(
BoxedString
*
lhs
,
Box
*
rhs
)
{
assert
(
PyString_Check
(
lhs
));
...
...
@@ -2926,6 +2933,7 @@ void setupStr() {
str_cls
->
giveAttr
(
"__add__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
strAdd
,
UNKNOWN
,
2
)));
str_cls
->
giveAttr
(
"__mod__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
strMod
,
UNKNOWN
,
2
)));
str_cls
->
giveAttr
(
"__rmod__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
strRMod
,
UNKNOWN
,
2
)));
str_cls
->
giveAttr
(
"__mul__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
strMul
,
UNKNOWN
,
2
)));
// TODO not sure if this is right in all cases:
str_cls
->
giveAttr
(
"__rmul__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
strMul
,
UNKNOWN
,
2
)));
...
...
src/runtime/types.cpp
View file @
1d1236b2
...
...
@@ -1561,6 +1561,12 @@ static Box* builtinFunctionOrMethodName(Box* b, void*) {
return
incref
(
func
->
name
);
}
static
Box
*
wrapperobjectName
(
Box
*
w
,
void
*
)
{
assert
(
w
->
cls
==
wrapperobject_cls
);
BoxedWrapperObject
*
wrapper_obj
=
static_cast
<
BoxedWrapperObject
*>
(
w
);
return
boxString
(
wrapper_obj
->
descr
->
wrapper
->
name
);
}
static
Box
*
functionCode
(
Box
*
self
,
void
*
)
{
assert
(
self
->
cls
==
function_cls
);
BoxedFunction
*
func
=
static_cast
<
BoxedFunction
*>
(
self
);
...
...
@@ -2956,9 +2962,7 @@ static PyObject* object_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
builtins
=
PyEval_GetBuiltins
();
if
(
builtins
==
NULL
)
goto
error
;
// Pyston change: builtins is a module not a dict
// sorted = PyDict_GetItemString(builtins, "sorted");
sorted
=
builtins
->
getattr
(
autoDecref
(
internStringMortal
(
"sorted"
)));
sorted
=
PyDict_GetItemString
(
builtins
,
"sorted"
);
if
(
sorted
==
NULL
)
goto
error
;
sorted_methods
=
PyObject_CallFunctionObjArgs
(
sorted
,
abstract_methods
,
NULL
);
...
...
@@ -4499,6 +4503,8 @@ void setupRuntime() {
instancemethod_cls
->
giveAttr
(
"im_class"
,
new
BoxedMemberDescriptor
(
BoxedMemberDescriptor
::
OBJECT
,
offsetof
(
BoxedInstanceMethod
,
im_class
),
true
));
wrapperobject_cls
->
giveAttrDescriptor
(
"__name__"
,
wrapperobjectName
,
NULL
);
slice_cls
->
giveAttr
(
"__new__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
sliceNew
,
UNKNOWN
,
4
,
false
,
false
),
{
NULL
,
None
}));
...
...
test/tests/str_functions.py
View file @
1d1236b2
...
...
@@ -215,3 +215,9 @@ for i in xrange(-8, 8):
print
i
,
j
,
repr
(
s
[
i
:
j
])
for
k
in
(
-
2
,
1
,
1
,
2
):
print
i
,
j
,
k
,
repr
(
s
[
i
:
j
:
k
]),
repr
(
s
[
slice
(
i
,
j
,
k
)])
class
D
(
str
):
pass
print
(
D
(
'abc'
).
__rmod__
(
'%s'
))
test/tests/wrapperdesc.py
View file @
1d1236b2
...
...
@@ -5,5 +5,6 @@ print type(C).__str__ is object.__str__
print
type
(
None
).
__str__
is
object
.
__str__
print
type
(
None
).
__str__
is
None
.
__str__
print
type
(
None
.
__str__
)
print
(
None
.
__str__
.
__name__
)
print
type
(
type
(
None
).
__str__
.
__get__
(
None
,
type
(
None
)))
print
u""
.
__len__
.
__call__
()
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