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
099b2b90
Commit
099b2b90
authored
Dec 10, 2015
by
Rudi Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Loosen type annotation to allow NotImplemented.
parent
06339b3b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
1 deletion
+13
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+5
-0
src/runtime/tuple.cpp
src/runtime/tuple.cpp
+3
-1
test/tests/tuples.py
test/tests/tuples.py
+5
-0
No files found.
src/runtime/objmodel.cpp
View file @
099b2b90
...
@@ -4157,6 +4157,11 @@ Box* callCLFunc(FunctionMetadata* md, CallRewriteArgs* rewrite_args, int num_out
...
@@ -4157,6 +4157,11 @@ Box* callCLFunc(FunctionMetadata* md, CallRewriteArgs* rewrite_args, int num_out
if
(
!
r
)
{
if
(
!
r
)
{
assert
(
S
==
CAPI
);
assert
(
S
==
CAPI
);
}
else
{
}
else
{
// If this assertion is triggered because the type isn't what we expected,
// but something that should be allowed (e.g. NotImplementedType), it is
// possible that the program has a bad type annotation. For example, an
// attribute that we added in C++ should have return type UNKNOWN instead
// of BOXED_SOMETHING.
ASSERT
(
chosen_cf
->
spec
->
rtn_type
->
isFitBy
(
r
->
cls
),
"%s (%p) was supposed to return %s, but gave a %s"
,
ASSERT
(
chosen_cf
->
spec
->
rtn_type
->
isFitBy
(
r
->
cls
),
"%s (%p) was supposed to return %s, but gave a %s"
,
g
.
func_addr_registry
.
getFuncNameAtAddress
(
chosen_cf
->
code
,
true
,
NULL
).
c_str
(),
chosen_cf
->
code
,
g
.
func_addr_registry
.
getFuncNameAtAddress
(
chosen_cf
->
code
,
true
,
NULL
).
c_str
(),
chosen_cf
->
code
,
chosen_cf
->
spec
->
rtn_type
->
debugName
().
c_str
(),
r
->
cls
->
tp_name
);
chosen_cf
->
spec
->
rtn_type
->
debugName
().
c_str
(),
r
->
cls
->
tp_name
);
...
...
src/runtime/tuple.cpp
View file @
099b2b90
...
@@ -687,7 +687,9 @@ void setupTuple() {
...
@@ -687,7 +687,9 @@ void setupTuple() {
tuple_cls
->
giveAttr
(
"__len__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
tupleLen
,
BOXED_INT
,
1
)));
tuple_cls
->
giveAttr
(
"__len__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
tupleLen
,
BOXED_INT
,
1
)));
tuple_cls
->
giveAttr
(
"__repr__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
tupleRepr
,
STR
,
1
)));
tuple_cls
->
giveAttr
(
"__repr__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
tupleRepr
,
STR
,
1
)));
tuple_cls
->
giveAttr
(
"__add__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
tupleAdd
,
BOXED_TUPLE
,
2
)));
// Return type is UNKNOWN as it could be NotImplemented.
tuple_cls
->
giveAttr
(
"__add__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
tupleAdd
,
UNKNOWN
,
2
)));
tuple_cls
->
giveAttr
(
"__mul__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
tupleMul
,
BOXED_TUPLE
,
2
)));
tuple_cls
->
giveAttr
(
"__mul__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
tupleMul
,
BOXED_TUPLE
,
2
)));
tuple_cls
->
giveAttr
(
"__rmul__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
tupleMul
,
BOXED_TUPLE
,
2
)));
tuple_cls
->
giveAttr
(
"__rmul__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
tupleMul
,
BOXED_TUPLE
,
2
)));
...
...
test/tests/tuples.py
View file @
099b2b90
...
@@ -95,6 +95,11 @@ print (1, 2, 3) + ()
...
@@ -95,6 +95,11 @@ print (1, 2, 3) + ()
print
()
+
(
1
,
2
,
3
)
print
()
+
(
1
,
2
,
3
)
print
(
1
,
2
)
+
(
2
,
3
)
print
(
1
,
2
)
+
(
2
,
3
)
try
:
(
1
,
2
)
+
"a"
except
TypeError
as
e
:
print
"adding failed"
## __new__
## __new__
print
tuple
()
print
tuple
()
print
tuple
((
1
,
3
,
7
,
42
))
print
tuple
((
1
,
3
,
7
,
42
))
...
...
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