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
bbe39d40
Commit
bbe39d40
authored
Mar 27, 2015
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup isSubclass check. Remove isInstance()
parent
20014568
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
15 deletions
+4
-15
src/runtime/capi.cpp
src/runtime/capi.cpp
+2
-2
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+2
-12
src/runtime/objmodel.h
src/runtime/objmodel.h
+0
-1
No files found.
src/runtime/capi.cpp
View file @
bbe39d40
...
@@ -669,7 +669,7 @@ void checkAndThrowCAPIException() {
...
@@ -669,7 +669,7 @@ void checkAndThrowCAPIException() {
if
(
_type
)
{
if
(
_type
)
{
BoxedClass
*
type
=
static_cast
<
BoxedClass
*>
(
_type
);
BoxedClass
*
type
=
static_cast
<
BoxedClass
*>
(
_type
);
assert
(
is
Instance
(
_type
,
type_cls
)
&&
isSubclass
(
static_cast
<
BoxedClass
*>
(
type
),
BaseException
)
assert
(
is
Subclass
(
_type
->
cls
,
type_cls
)
&&
isSubclass
(
static_cast
<
BoxedClass
*>
(
type
),
BaseException
)
&&
"Only support throwing subclass of BaseException for now"
);
&&
"Only support throwing subclass of BaseException for now"
);
Box
*
value
=
cur_thread_state
.
curexc_value
;
Box
*
value
=
cur_thread_state
.
curexc_value
;
...
@@ -686,7 +686,7 @@ void checkAndThrowCAPIException() {
...
@@ -686,7 +686,7 @@ void checkAndThrowCAPIException() {
PyErr_Clear
();
PyErr_Clear
();
// This is similar to PyErr_NormalizeException:
// This is similar to PyErr_NormalizeException:
if
(
!
is
Instance
(
value
,
type
))
{
if
(
!
is
Subclass
(
value
->
cls
,
type
))
{
if
(
value
->
cls
==
tuple_cls
)
{
if
(
value
->
cls
==
tuple_cls
)
{
value
=
runtimeCall
(
type
,
ArgPassSpec
(
0
,
0
,
true
,
false
),
value
,
NULL
,
NULL
,
NULL
,
NULL
);
value
=
runtimeCall
(
type
,
ArgPassSpec
(
0
,
0
,
true
,
false
),
value
,
NULL
,
NULL
,
NULL
,
NULL
);
}
else
if
(
value
==
None
)
{
}
else
if
(
value
==
None
)
{
...
...
src/runtime/objmodel.cpp
View file @
bbe39d40
...
@@ -211,18 +211,8 @@ extern "C" void my_assert(bool b) {
...
@@ -211,18 +211,8 @@ extern "C" void my_assert(bool b) {
assert
(
b
);
assert
(
b
);
}
}
bool
isInstance
(
Box
*
obj
,
BoxedClass
*
cls
)
{
int
rtn
=
_PyObject_RealIsInstance
(
obj
,
cls
);
if
(
rtn
<
0
)
checkAndThrowCAPIException
();
return
rtn
;
}
extern
"C"
bool
isSubclass
(
BoxedClass
*
child
,
BoxedClass
*
parent
)
{
extern
"C"
bool
isSubclass
(
BoxedClass
*
child
,
BoxedClass
*
parent
)
{
int
rtn
=
_PyObject_RealIsSubclass
(
child
,
parent
);
return
PyType_IsSubtype
(
child
,
parent
);
if
(
rtn
<
0
)
checkAndThrowCAPIException
();
return
rtn
;
}
}
extern
"C"
void
assertFail
(
BoxedModule
*
inModule
,
Box
*
msg
)
{
extern
"C"
void
assertFail
(
BoxedModule
*
inModule
,
Box
*
msg
)
{
...
@@ -4465,7 +4455,7 @@ extern "C" Box* boxedLocalsGet(Box* boxedLocals, const char* attr, BoxedModule*
...
@@ -4465,7 +4455,7 @@ extern "C" Box* boxedLocalsGet(Box* boxedLocals, const char* attr, BoxedModule*
// TODO should check the exact semantic here but it's something like:
// TODO should check the exact semantic here but it's something like:
// If it throws a KeyError, then the variable doesn't exist so move on
// If it throws a KeyError, then the variable doesn't exist so move on
// and check the globals (below); otherwise, just propogate the exception.
// and check the globals (below); otherwise, just propogate the exception.
if
(
!
is
Instance
(
e
.
value
,
KeyError
))
{
if
(
!
is
Subclass
(
e
.
value
->
cls
,
KeyError
))
{
throw
;
throw
;
}
}
}
}
...
...
src/runtime/objmodel.h
View file @
bbe39d40
...
@@ -84,7 +84,6 @@ extern "C" Box* importStar(Box* from_module, BoxedModule* to_module);
...
@@ -84,7 +84,6 @@ extern "C" Box* importStar(Box* from_module, BoxedModule* to_module);
extern
"C"
Box
**
unpackIntoArray
(
Box
*
obj
,
int64_t
expected_size
);
extern
"C"
Box
**
unpackIntoArray
(
Box
*
obj
,
int64_t
expected_size
);
extern
"C"
void
assertNameDefined
(
bool
b
,
const
char
*
name
,
BoxedClass
*
exc_cls
,
bool
local_var_msg
);
extern
"C"
void
assertNameDefined
(
bool
b
,
const
char
*
name
,
BoxedClass
*
exc_cls
,
bool
local_var_msg
);
extern
"C"
void
assertFail
(
BoxedModule
*
inModule
,
Box
*
msg
);
extern
"C"
void
assertFail
(
BoxedModule
*
inModule
,
Box
*
msg
);
extern
"C"
bool
isInstance
(
Box
*
obj
,
BoxedClass
*
parent
);
extern
"C"
bool
isSubclass
(
BoxedClass
*
child
,
BoxedClass
*
parent
);
extern
"C"
bool
isSubclass
(
BoxedClass
*
child
,
BoxedClass
*
parent
);
extern
"C"
BoxedClosure
*
createClosure
(
BoxedClosure
*
parent_closure
);
extern
"C"
BoxedClosure
*
createClosure
(
BoxedClosure
*
parent_closure
);
...
...
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