Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
bf93c499
Commit
bf93c499
authored
May 03, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix some cases where errors in IsInstance()/IsSubtype() calls were not handled
parent
b339e287
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
12 deletions
+37
-12
CHANGES.rst
CHANGES.rst
+3
-0
Cython/Utility/CythonFunction.c
Cython/Utility/CythonFunction.c
+11
-7
Cython/Utility/Exceptions.c
Cython/Utility/Exceptions.c
+7
-3
Cython/Utility/Generator.c
Cython/Utility/Generator.c
+14
-2
Cython/Utility/ObjectHandling.c
Cython/Utility/ObjectHandling.c
+2
-0
No files found.
CHANGES.rst
View file @
bf93c499
...
...
@@ -10,6 +10,9 @@ Bugs fixed
* Crash when returning values on generator termination.
* In some cases, exceptions raised during internal isinstance() checks were
not propagated.
* Runtime reported file paths of source files (e.g for profiling and tracing)
are now relative to the build root directory instead of the main source file.
...
...
Cython/Utility/CythonFunction.c
View file @
bf93c499
...
...
@@ -1017,13 +1017,17 @@ __pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw)
self
=
PyTuple_GET_ITEM
(
args
,
0
);
}
if
(
self
&&
!
is_classmethod
&&
!
is_staticmethod
&&
!
PyObject_IsInstance
(
self
,
binding_func
->
type
))
{
PyErr_Format
(
PyExc_TypeError
,
"First argument should be of type %.200s, got %.200s."
,
((
PyTypeObject
*
)
binding_func
->
type
)
->
tp_name
,
self
->
ob_type
->
tp_name
);
goto
__pyx_err
;
if
(
self
&&
!
is_classmethod
&&
!
is_staticmethod
)
{
int
is_instance
=
PyObject_IsInstance
(
self
,
binding_func
->
type
);
if
(
unlikely
(
!
is_instance
))
{
PyErr_Format
(
PyExc_TypeError
,
"First argument should be of type %.200s, got %.200s."
,
((
PyTypeObject
*
)
binding_func
->
type
)
->
tp_name
,
self
->
ob_type
->
tp_name
);
goto
__pyx_err
;
}
else
if
(
unlikely
(
is_instance
==
-
1
))
{
goto
__pyx_err
;
}
}
if
(
binding_func
->
__signatures__
)
{
...
...
Cython/Utility/Exceptions.c
View file @
bf93c499
...
...
@@ -144,11 +144,15 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject
if
(
value
&&
PyExceptionInstance_Check
(
value
))
{
instance_class
=
(
PyObject
*
)
Py_TYPE
(
value
);
if
(
instance_class
!=
type
)
{
if
(
PyObject_IsSubclass
(
instance_class
,
type
))
{
int
is_subclass
=
PyObject_IsSubclass
(
instance_class
,
type
);
if
(
!
is_subclass
)
{
instance_class
=
NULL
;
}
else
if
(
unlikely
(
is_subclass
==
-
1
))
{
// error on subclass test
goto
bad
;
}
else
{
// believe the instance
type
=
instance_class
;
}
else
{
instance_class
=
NULL
;
}
}
}
...
...
Cython/Utility/Generator.c
View file @
bf93c499
...
...
@@ -102,6 +102,7 @@ static PyTypeObject *__pyx_GeneratorType = 0;
static
int
__Pyx_PyGen_FetchStopIterationValue
(
PyObject
**
pvalue
)
{
PyObject
*
et
,
*
ev
,
*
tb
;
PyObject
*
value
=
NULL
;
int
result
;
__Pyx_ErrFetch
(
&
et
,
&
ev
,
&
tb
);
...
...
@@ -121,7 +122,8 @@ static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) {
// most common case: plain StopIteration without or with separate argument
if
(
likely
(
et
==
PyExc_StopIteration
))
{
if
(
likely
(
!
ev
)
||
!
PyObject_IsInstance
(
ev
,
PyExc_StopIteration
))
{
int
error
=
0
;
if
(
!
ev
||
!
(
error
=
PyObject_IsInstance
(
ev
,
PyExc_StopIteration
)))
{
// PyErr_SetObject() and friends put the value directly into ev
if
(
!
ev
)
{
Py_INCREF
(
Py_None
);
...
...
@@ -132,16 +134,26 @@ static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) {
*
pvalue
=
ev
;
return
0
;
}
if
(
unlikely
(
error
==
-
1
))
{
// error during isinstance() check
return
-
1
;
}
}
// otherwise: normalise and check what that gives us
PyErr_NormalizeException
(
&
et
,
&
ev
,
&
tb
);
if
(
unlikely
(
!
PyObject_IsInstance
(
ev
,
PyExc_StopIteration
)))
{
result
=
PyObject_IsInstance
(
ev
,
PyExc_StopIteration
);
if
(
unlikely
(
!
result
))
{
// looks like normalisation failed - raise the new exception
__Pyx_ErrRestore
(
et
,
ev
,
tb
);
return
-
1
;
}
Py_XDECREF
(
tb
);
Py_DECREF
(
et
);
if
(
unlikely
(
result
==
-
1
))
{
// error during isinstance() check
Py_DECREF
(
ev
);
return
-
1
;
}
#if PY_VERSION_HEX >= 0x030300A0
value
=
((
PyStopIterationObject
*
)
ev
)
->
value
;
Py_INCREF
(
value
);
...
...
Cython/Utility/ObjectHandling.c
View file @
bf93c499
...
...
@@ -1415,6 +1415,8 @@ bad:
static
PyObject
*
__Pyx__PyNumber_MatrixMultiply
(
PyObject
*
x
,
PyObject
*
y
,
const
char
*
op_name
)
{
int
right_is_subtype
=
PyObject_IsSubclass
((
PyObject
*
)
Py_TYPE
(
y
),
(
PyObject
*
)
Py_TYPE
(
x
));
if
(
unlikely
(
right_is_subtype
==
-
1
))
return
NULL
;
if
(
right_is_subtype
)
{
// to allow subtypes to override parent behaviour, try reversed operation first
// see note at https://docs.python.org/3/reference/datamodel.html#emulating-numeric-types
...
...
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