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
c69e0d81
Commit
c69e0d81
authored
Mar 16, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix this len issue
parent
71ebba5c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
12 deletions
+32
-12
.travis.yml
.travis.yml
+4
-0
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+28
-12
No files found.
.travis.yml
View file @
c69e0d81
language
:
cpp
language
:
cpp
branches
:
except
:
-
refcounting
compiler
:
compiler
:
-
clang
-
clang
-
gcc
-
gcc
...
...
src/runtime/objmodel.cpp
View file @
c69e0d81
...
@@ -3188,10 +3188,27 @@ BoxedInt* lenInternal(Box* obj, LenRewriteArgs* rewrite_args) noexcept(S == CAPI
...
@@ -3188,10 +3188,27 @@ BoxedInt* lenInternal(Box* obj, LenRewriteArgs* rewrite_args) noexcept(S == CAPI
return
(
BoxedInt
*
)
boxInt
(
r
);
return
(
BoxedInt
*
)
boxInt
(
r
);
}
}
class
FixupLenReturn
{
public:
static
BoxedInt
*
call
(
Box
*
rtn
)
{
// TODO: support returning longs as the length
if
(
rtn
->
cls
!=
int_cls
)
{
Py_DECREF
(
rtn
);
if
(
S
==
CAPI
)
{
PyErr_Format
(
TypeError
,
"an integer is required"
);
return
NULL
;
}
else
raiseExcHelper
(
TypeError
,
"an integer is required"
);
}
return
static_cast
<
BoxedInt
*>
(
rtn
);
};
};
Box
*
rtn
;
Box
*
rtn
;
RewriterVar
*
r_rtn
=
NULL
;
try
{
try
{
if
(
rewrite_args
)
{
if
(
rewrite_args
)
{
assert
(
0
&&
"how do we know this is going to return an int?"
);
CallattrRewriteArgs
crewrite_args
(
rewrite_args
->
rewriter
,
rewrite_args
->
obj
,
rewrite_args
->
destination
);
CallattrRewriteArgs
crewrite_args
(
rewrite_args
->
rewriter
,
rewrite_args
->
obj
,
rewrite_args
->
destination
);
rtn
=
callattrInternal0
<
CXX
,
REWRITABLE
>
(
obj
,
len_str
,
CLASS_ONLY
,
&
crewrite_args
,
ArgPassSpec
(
0
));
rtn
=
callattrInternal0
<
CXX
,
REWRITABLE
>
(
obj
,
len_str
,
CLASS_ONLY
,
&
crewrite_args
,
ArgPassSpec
(
0
));
if
(
!
crewrite_args
.
isSuccessful
())
if
(
!
crewrite_args
.
isSuccessful
())
...
@@ -3204,7 +3221,7 @@ BoxedInt* lenInternal(Box* obj, LenRewriteArgs* rewrite_args) noexcept(S == CAPI
...
@@ -3204,7 +3221,7 @@ BoxedInt* lenInternal(Box* obj, LenRewriteArgs* rewrite_args) noexcept(S == CAPI
&&
return_convention
!=
ReturnConvention
::
NO_RETURN
)
&&
return_convention
!=
ReturnConvention
::
NO_RETURN
)
rewrite_args
=
NULL
;
rewrite_args
=
NULL
;
else
{
else
{
r
ewrite_args
->
out
_rtn
=
rtn
;
r_rtn
=
rtn
;
}
}
if
(
rewrite_args
)
if
(
rewrite_args
)
...
@@ -3231,18 +3248,17 @@ BoxedInt* lenInternal(Box* obj, LenRewriteArgs* rewrite_args) noexcept(S == CAPI
...
@@ -3231,18 +3248,17 @@ BoxedInt* lenInternal(Box* obj, LenRewriteArgs* rewrite_args) noexcept(S == CAPI
raiseExcHelper
(
TypeError
,
"object of type '%s' has no len()"
,
getTypeName
(
obj
));
raiseExcHelper
(
TypeError
,
"object of type '%s' has no len()"
,
getTypeName
(
obj
));
}
}
if
(
rtn
->
cls
!=
int_cls
)
{
if
(
rewrite_args
)
{
Py_DECREF
(
rtn
);
if
(
S
==
CXX
)
{
if
(
S
==
CAPI
)
{
rewrite_args
->
out_rtn
=
rewrite_args
->
rewriter
->
call
(
true
,
(
void
*
)
FixupLenReturn
::
call
,
r_rtn
)
->
setType
(
RefType
::
OWNED
);
PyErr_Format
(
TypeError
,
"an integer is required"
);
rewrite_args
->
out_success
=
true
;
return
NULL
;
}
else
{
}
else
// Don't know how to propagate the exception
raiseExcHelper
(
TypeError
,
"an integer is required"
);
rewrite_args
=
NULL
;
}
}
}
if
(
rewrite_args
)
return
FixupLenReturn
::
call
(
rtn
);
rewrite_args
->
out_success
=
true
;
return
static_cast
<
BoxedInt
*>
(
rtn
);
}
}
// force template instantiation:
// force template instantiation:
...
...
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