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
2254da9f
Commit
2254da9f
authored
May 30, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug if you try to call something not callable
parent
53c2fadd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
11 deletions
+20
-11
src/codegen/llvm_interpreter.cpp
src/codegen/llvm_interpreter.cpp
+8
-4
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+7
-2
test/tests/exceptions_basic.py
test/tests/exceptions_basic.py
+5
-5
No files found.
src/codegen/llvm_interpreter.cpp
View file @
2254da9f
...
@@ -30,6 +30,10 @@
...
@@ -30,6 +30,10 @@
#include "core/stats.h"
#include "core/stats.h"
#include "core/util.h"
#include "core/util.h"
//#undef VERBOSITY
//#define VERBOSITY(x) 2
//#define TIME_INTERPRETS
extern
"C"
void
*
__cxa_allocate_exception
(
size_t
);
extern
"C"
void
*
__cxa_allocate_exception
(
size_t
);
namespace
pyston
{
namespace
pyston
{
...
@@ -62,10 +66,6 @@ int width(llvm::Value* v, const llvm::DataLayout& dl) {
...
@@ -62,10 +66,6 @@ int width(llvm::Value* v, const llvm::DataLayout& dl) {
return
width
(
v
->
getType
(),
dl
);
return
width
(
v
->
getType
(),
dl
);
}
}
//#undef VERBOSITY
//#define VERBOSITY(x) 2
//#define TIME_INTERPRETS
Val
fetch
(
llvm
::
Value
*
v
,
const
llvm
::
DataLayout
&
dl
,
const
SymMap
&
symbols
)
{
Val
fetch
(
llvm
::
Value
*
v
,
const
llvm
::
DataLayout
&
dl
,
const
SymMap
&
symbols
)
{
assert
(
v
);
assert
(
v
);
...
@@ -636,6 +636,10 @@ Box* interpretFunction(llvm::Function* f, int nargs, Box* arg1, Box* arg2, Box*
...
@@ -636,6 +636,10 @@ Box* interpretFunction(llvm::Function* f, int nargs, Box* arg1, Box* arg2, Box*
}
}
}
}
catch
(
Box
*
e
)
{
catch
(
Box
*
e
)
{
if
(
VERBOSITY
(
"interpreter"
)
>=
2
)
{
printf
(
"Caught exception: %p
\n
"
,
e
);
}
if
(
invoke
==
nullptr
)
if
(
invoke
==
nullptr
)
throw
;
throw
;
...
...
src/runtime/objmodel.cpp
View file @
2254da9f
...
@@ -1560,13 +1560,17 @@ Box* runtimeCallInternal(Box* obj, CallRewriteArgs* rewrite_args, int64_t nargs,
...
@@ -1560,13 +1560,17 @@ Box* runtimeCallInternal(Box* obj, CallRewriteArgs* rewrite_args, int64_t nargs,
Box
*
orig_obj
=
obj
;
Box
*
orig_obj
=
obj
;
if
(
obj
->
cls
!=
function_cls
&&
obj
->
cls
!=
instancemethod_cls
)
{
if
(
obj
->
cls
!=
function_cls
&&
obj
->
cls
!=
instancemethod_cls
)
{
Box
*
rtn
;
if
(
rewrite_args
)
{
if
(
rewrite_args
)
{
// TODO is this ok?
// TODO is this ok?
// rewrite_args->rewriter->trap();
// rewrite_args->rewriter->trap();
r
eturn
callattrInternal
(
obj
,
&
_call_str
,
CLASS_ONLY
,
rewrite_args
,
nargs
,
arg1
,
arg2
,
arg3
,
args
);
r
tn
=
callattrInternal
(
obj
,
&
_call_str
,
CLASS_ONLY
,
rewrite_args
,
nargs
,
arg1
,
arg2
,
arg3
,
args
);
}
else
{
}
else
{
r
eturn
callattrInternal
(
obj
,
&
_call_str
,
CLASS_ONLY
,
NULL
,
nargs
,
arg1
,
arg2
,
arg3
,
args
);
r
tn
=
callattrInternal
(
obj
,
&
_call_str
,
CLASS_ONLY
,
NULL
,
nargs
,
arg1
,
arg2
,
arg3
,
args
);
}
}
if
(
!
rtn
)
raiseExcHelper
(
TypeError
,
"'%s' object is not callable"
,
getTypeName
(
obj
)
->
c_str
());
return
rtn
;
}
}
if
(
rewrite_args
)
{
if
(
rewrite_args
)
{
...
@@ -1747,6 +1751,7 @@ extern "C" Box* runtimeCall(Box* obj, int64_t nargs, Box* arg1, Box* arg2, Box*
...
@@ -1747,6 +1751,7 @@ extern "C" Box* runtimeCall(Box* obj, int64_t nargs, Box* arg1, Box* arg2, Box*
}
else
{
}
else
{
rtn
=
runtimeCallInternal
(
obj
,
NULL
,
nargs
,
arg1
,
arg2
,
arg3
,
args
);
rtn
=
runtimeCallInternal
(
obj
,
NULL
,
nargs
,
arg1
,
arg2
,
arg3
,
args
);
}
}
assert
(
rtn
);
if
(
rewriter
.
get
())
{
if
(
rewriter
.
get
())
{
rewriter
->
commit
();
rewriter
->
commit
();
...
...
test/tests/exceptions_basic.py
View file @
2254da9f
...
@@ -33,17 +33,17 @@ except ZeroDivisionError, e:
...
@@ -33,17 +33,17 @@ except ZeroDivisionError, e:
class
MyException
(
Exception
):
class
MyException
(
Exception
):
pass
pass
def
catches
(
e
):
def
catches
(
e
,
c
):
try
:
try
:
try
:
try
:
raise
e
raise
e
except
MyException
:
except
c
:
return
True
return
True
except
:
except
:
return
False
return
False
print
catches
(
Exception
())
for
e
in
[
Exception
(),
AttributeError
(),
MyException
()]:
print
catches
(
AttributeError
())
for
c
in
[
Exception
,
AttributeError
,
MyException
,
TypeError
]:
print
catches
(
MyException
()
)
print
catches
(
e
,
c
)
def
f
():
def
f
():
try
:
try
:
...
...
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