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
7aaaf4bf
Commit
7aaaf4bf
authored
Jan 11, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't set __str__ to __repr__, that breaks subclasses
parent
2dad87ad
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
2 additions
and
12 deletions
+2
-12
src/runtime/bool.cpp
src/runtime/bool.cpp
+0
-1
src/runtime/capi.cpp
src/runtime/capi.cpp
+0
-1
src/runtime/dict.cpp
src/runtime/dict.cpp
+0
-1
src/runtime/file.cpp
src/runtime/file.cpp
+0
-1
src/runtime/int.cpp
src/runtime/int.cpp
+0
-1
src/runtime/list.cpp
src/runtime/list.cpp
+0
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+2
-0
src/runtime/tuple.cpp
src/runtime/tuple.cpp
+0
-1
src/runtime/types.cpp
src/runtime/types.cpp
+0
-5
No files found.
src/runtime/bool.cpp
View file @
7aaaf4bf
...
...
@@ -52,7 +52,6 @@ void setupBool() {
bool_cls
->
giveAttr
(
"__nonzero__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
boolNonzero
,
BOXED_BOOL
,
1
)));
bool_cls
->
giveAttr
(
"__repr__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
boolRepr
,
STR
,
1
)));
bool_cls
->
giveAttr
(
"__str__"
,
bool_cls
->
getattr
(
"__repr__"
));
bool_cls
->
giveAttr
(
"__hash__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
boolHash
,
BOXED_INT
,
1
)));
bool_cls
->
giveAttr
(
"__new__"
,
...
...
src/runtime/capi.cpp
View file @
7aaaf4bf
...
...
@@ -1304,7 +1304,6 @@ void setupCAPI() {
capifunc_cls
->
giveAttr
(
"__repr__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
BoxedCApiFunction
::
__repr__
,
UNKNOWN
,
1
)));
capifunc_cls
->
giveAttr
(
"__str__"
,
capifunc_cls
->
getattr
(
"__repr__"
));
capifunc_cls
->
giveAttr
(
"__call__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
BoxedCApiFunction
::
__call__
,
UNKNOWN
,
1
,
0
,
true
,
true
)));
...
...
src/runtime/dict.cpp
View file @
7aaaf4bf
...
...
@@ -530,7 +530,6 @@ void setupDict() {
dict_cls
->
giveAttr
(
"__new__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
dictNew
,
UNKNOWN
,
1
,
0
,
true
,
true
)));
dict_cls
->
giveAttr
(
"__init__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
dictInit
,
NONE
,
1
,
0
,
true
,
true
)));
dict_cls
->
giveAttr
(
"__repr__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
dictRepr
,
STR
,
1
)));
dict_cls
->
giveAttr
(
"__str__"
,
dict_cls
->
getattr
(
"__repr__"
));
dict_cls
->
giveAttr
(
"__iter__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
dictIterKeys
,
typeFromClass
(
dict_iterator_cls
),
1
)));
...
...
src/runtime/file.cpp
View file @
7aaaf4bf
...
...
@@ -291,7 +291,6 @@ void setupFile() {
file_cls
->
giveAttr
(
"close"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
fileClose
,
NONE
,
1
)));
file_cls
->
giveAttr
(
"__repr__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
fileRepr
,
STR
,
1
)));
file_cls
->
giveAttr
(
"__str__"
,
file_cls
->
getattr
(
"__repr__"
));
file_cls
->
giveAttr
(
"__enter__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
fileEnter
,
typeFromClass
(
file_cls
),
1
)));
file_cls
->
giveAttr
(
"__exit__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
fileExit
,
UNKNOWN
,
4
)));
...
...
src/runtime/int.cpp
View file @
7aaaf4bf
...
...
@@ -876,7 +876,6 @@ void setupInt() {
int_cls
->
giveAttr
(
"__neg__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
intNeg
,
UNKNOWN
,
1
)));
int_cls
->
giveAttr
(
"__nonzero__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
intNonzero
,
BOXED_BOOL
,
1
)));
int_cls
->
giveAttr
(
"__repr__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
intRepr
,
STR
,
1
)));
int_cls
->
giveAttr
(
"__str__"
,
int_cls
->
getattr
(
"__repr__"
));
int_cls
->
giveAttr
(
"__hash__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
intHash
,
BOXED_INT
,
1
)));
int_cls
->
giveAttr
(
"__divmod__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
intDivmod
,
BOXED_TUPLE
,
2
)));
...
...
src/runtime/list.cpp
View file @
7aaaf4bf
...
...
@@ -670,7 +670,6 @@ void setupList() {
list_cls
->
giveAttr
(
"__ne__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
listNe
,
UNKNOWN
,
2
)));
list_cls
->
giveAttr
(
"__repr__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
listRepr
,
STR
,
1
)));
list_cls
->
giveAttr
(
"__str__"
,
list_cls
->
getattr
(
"__repr__"
));
list_cls
->
giveAttr
(
"__nonzero__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
listNonzero
,
BOXED_BOOL
,
1
)));
list_cls
->
giveAttr
(
"pop"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
listPop
,
UNKNOWN
,
2
,
1
,
false
,
false
),
{
None
}));
...
...
src/runtime/objmodel.cpp
View file @
7aaaf4bf
...
...
@@ -1723,6 +1723,8 @@ extern "C" BoxedString* str(Box* obj) {
if
(
obj
->
cls
!=
str_cls
)
{
static
const
std
::
string
str_str
(
"__str__"
);
// TODO could do an IC optimization here (once we do rewrites here at all):
// if __str__ is objectStr, just guard on that and call repr directly.
obj
=
callattrInternal
(
obj
,
&
str_str
,
CLASS_ONLY
,
NULL
,
ArgPassSpec
(
0
),
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
}
...
...
src/runtime/tuple.cpp
View file @
7aaaf4bf
...
...
@@ -412,7 +412,6 @@ void setupTuple() {
tuple_cls
->
giveAttr
(
"__hash__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
tupleHash
,
BOXED_INT
,
1
)));
tuple_cls
->
giveAttr
(
"__len__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
tupleLen
,
BOXED_INT
,
1
)));
tuple_cls
->
giveAttr
(
"__repr__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
tupleRepr
,
STR
,
1
)));
tuple_cls
->
giveAttr
(
"__str__"
,
tuple_cls
->
getattr
(
"__repr__"
));
tuple_cls
->
giveAttr
(
"__add__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
tupleAdd
,
BOXED_TUPLE
,
2
)));
tuple_cls
->
giveAttr
(
"__mul__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
tupleMul
,
BOXED_TUPLE
,
2
)));
tuple_cls
->
giveAttr
(
"__rmul__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
tupleMul
,
BOXED_TUPLE
,
2
)));
...
...
src/runtime/types.cpp
View file @
7aaaf4bf
...
...
@@ -1040,20 +1040,17 @@ void setupRuntime() {
type_cls
->
giveAttr
(
"__new__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
typeNew
,
UNKNOWN
,
4
,
2
,
false
,
false
),
{
NULL
,
NULL
}));
type_cls
->
giveAttr
(
"__repr__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
typeRepr
,
STR
,
1
)));
type_cls
->
giveAttr
(
"__str__"
,
type_cls
->
getattr
(
"__repr__"
));
type_cls
->
giveAttr
(
"__hash__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
typeHash
,
BOXED_INT
,
1
)));
type_cls
->
freeze
();
none_cls
->
giveAttr
(
"__name__"
,
boxStrConstant
(
"NoneType"
));
none_cls
->
giveAttr
(
"__repr__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
noneRepr
,
STR
,
1
)));
none_cls
->
giveAttr
(
"__str__"
,
none_cls
->
getattr
(
"__repr__"
));
none_cls
->
giveAttr
(
"__hash__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
noneHash
,
UNKNOWN
,
1
)));
none_cls
->
giveAttr
(
"__nonzero__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
noneNonzero
,
BOXED_BOOL
,
1
)));
none_cls
->
freeze
();
module_cls
->
giveAttr
(
"__name__"
,
boxStrConstant
(
"module"
));
module_cls
->
giveAttr
(
"__repr__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
moduleRepr
,
STR
,
1
)));
module_cls
->
giveAttr
(
"__str__"
,
module_cls
->
getattr
(
"__repr__"
));
module_cls
->
freeze
();
closure_cls
->
giveAttr
(
"__name__"
,
boxStrConstant
(
"closure"
));
...
...
@@ -1079,7 +1076,6 @@ void setupRuntime() {
function_cls
->
giveAttr
(
"__name__"
,
boxStrConstant
(
"function"
));
function_cls
->
giveAttr
(
"__repr__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
functionRepr
,
STR
,
1
)));
function_cls
->
giveAttr
(
"__str__"
,
function_cls
->
getattr
(
"__repr__"
));
function_cls
->
giveAttr
(
"__module__"
,
new
BoxedMemberDescriptor
(
BoxedMemberDescriptor
::
OBJECT
,
offsetof
(
BoxedFunction
,
modname
)));
function_cls
->
giveAttr
(
"__get__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
functionGet
,
UNKNOWN
,
3
)));
...
...
@@ -1103,7 +1099,6 @@ void setupRuntime() {
slice_cls
->
giveAttr
(
"__new__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
sliceNew
,
UNKNOWN
,
4
,
2
,
false
,
false
),
{
NULL
,
None
}));
slice_cls
->
giveAttr
(
"__repr__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
sliceRepr
,
STR
,
1
)));
slice_cls
->
giveAttr
(
"__str__"
,
slice_cls
->
getattr
(
"__repr__"
));
slice_cls
->
giveAttr
(
"start"
,
new
BoxedMemberDescriptor
(
BoxedMemberDescriptor
::
OBJECT
,
SLICE_START_OFFSET
));
slice_cls
->
giveAttr
(
"stop"
,
new
BoxedMemberDescriptor
(
BoxedMemberDescriptor
::
OBJECT
,
SLICE_STOP_OFFSET
));
slice_cls
->
giveAttr
(
"step"
,
new
BoxedMemberDescriptor
(
BoxedMemberDescriptor
::
OBJECT
,
SLICE_STEP_OFFSET
));
...
...
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