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
Gwenaël Samain
cython
Commits
219725ca
Commit
219725ca
authored
Dec 06, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up lots of places where exceptions are being raised to reduce the message building overhead
parent
683aa853
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
42 additions
and
41 deletions
+42
-41
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+4
-4
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+4
-4
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-1
Cython/Utility/Buffer.c
Cython/Utility/Buffer.c
+2
-2
Cython/Utility/CythonFunction.c
Cython/Utility/CythonFunction.c
+5
-5
Cython/Utility/FunctionArguments.c
Cython/Utility/FunctionArguments.c
+6
-6
Cython/Utility/ImportExport.c
Cython/Utility/ImportExport.c
+8
-8
Cython/Utility/MemoryView_C.c
Cython/Utility/MemoryView_C.c
+1
-1
Cython/Utility/ObjectHandling.c
Cython/Utility/ObjectHandling.c
+4
-4
Cython/Utility/Overflow.c
Cython/Utility/Overflow.c
+2
-1
Cython/Utility/StringTools.c
Cython/Utility/StringTools.c
+1
-1
Cython/Utility/TypeConversion.c
Cython/Utility/TypeConversion.c
+4
-4
No files found.
Cython/Compiler/ExprNodes.py
View file @
219725ca
...
...
@@ -8998,7 +8998,7 @@ class NumBinopNode(BinopNode):
super
(
NumBinopNode
,
self
).
generate_evaluation_code
(
code
)
if
self
.
overflow_check
:
code
.
putln
(
"if (unlikely(%s)) {"
%
self
.
overflow_bit
)
code
.
putln
(
'PyErr_
Format
(PyExc_OverflowError, "value too large");'
)
code
.
putln
(
'PyErr_
SetString
(PyExc_OverflowError, "value too large");'
)
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
"}"
)
code
.
funcstate
.
release_temp
(
self
.
overflow_bit
)
...
...
@@ -9233,7 +9233,7 @@ class DivNode(NumBinopNode):
zero_test
=
"%s == 0"
%
self
.
operand2
.
result
()
code
.
putln
(
"if (unlikely(%s)) {"
%
zero_test
)
code
.
put_ensure_gil
()
code
.
putln
(
'PyErr_
Format
(PyExc_ZeroDivisionError, "%s");'
%
self
.
zero_division_message
())
code
.
putln
(
'PyErr_
SetString
(PyExc_ZeroDivisionError, "%s");'
%
self
.
zero_division_message
())
code
.
put_release_ensured_gil
()
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
"}"
)
...
...
@@ -9248,7 +9248,7 @@ class DivNode(NumBinopNode):
self
.
operand2
.
result
(),
type_of_op2
,
self
.
operand1
.
result
()))
code
.
put_ensure_gil
()
code
.
putln
(
'PyErr_
Format
(PyExc_OverflowError, "value too large to perform division");'
)
code
.
putln
(
'PyErr_
SetString
(PyExc_OverflowError, "value too large to perform division");'
)
code
.
put_release_ensured_gil
()
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
"}"
)
...
...
@@ -10599,7 +10599,7 @@ class CoerceIntToBytesNode(CoerceToPyTypeNode):
arg_result
,
arg_result
))
else
:
code
.
putln
(
"if (%s > 255) {"
%
arg_result
)
code
.
putln
(
'PyErr_
Format
(PyExc_OverflowError, '
code
.
putln
(
'PyErr_
SetString
(PyExc_OverflowError, '
'"value too large to pack into a byte"); %s'
%
(
code
.
error_goto
(
self
.
pos
)))
code
.
putln
(
'}'
)
...
...
Cython/Compiler/ModuleNode.py
View file @
219725ca
...
...
@@ -1496,7 +1496,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"PyErr_Format(PyExc_NotImplementedError,"
)
code
.
putln
(
' "Subscript assignment not supported by %s", Py_TYPE(o)->tp_name);'
)
' "Subscript assignment not supported by %
.200
s", Py_TYPE(o)->tp_name);'
)
code
.
putln
(
"return -1;"
)
code
.
putln
(
...
...
@@ -1513,7 +1513,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"PyErr_Format(PyExc_NotImplementedError,"
)
code
.
putln
(
' "Subscript deletion not supported by %s", Py_TYPE(o)->tp_name);'
)
' "Subscript deletion not supported by %
.200
s", Py_TYPE(o)->tp_name);'
)
code
.
putln
(
"return -1;"
)
code
.
putln
(
...
...
@@ -1563,7 +1563,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"PyErr_Format(PyExc_NotImplementedError,"
)
code
.
putln
(
' "2-element slice assignment not supported by %s", Py_TYPE(o)->tp_name);'
)
' "2-element slice assignment not supported by %
.200
s", Py_TYPE(o)->tp_name);'
)
code
.
putln
(
"return -1;"
)
code
.
putln
(
...
...
@@ -1580,7 +1580,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"PyErr_Format(PyExc_NotImplementedError,"
)
code
.
putln
(
' "2-element slice deletion not supported by %s", Py_TYPE(o)->tp_name);'
)
' "2-element slice deletion not supported by %
.200
s", Py_TYPE(o)->tp_name);'
)
code
.
putln
(
"return -1;"
)
code
.
putln
(
...
...
Cython/Compiler/Nodes.py
View file @
219725ca
...
...
@@ -1965,7 +1965,7 @@ class FuncDefNode(StatNode, BlockNode):
cname
=
arg
.
entry
.
cname
code
.
putln
(
'if (unlikely(((PyObject *)%s) == Py_None)) {'
%
cname
)
code
.
putln
(
'''PyErr_Format(PyExc_TypeError, "Argument '%
s' must not be None
"); %s'''
%
(
code
.
putln
(
'''PyErr_Format(PyExc_TypeError, "Argument '%
%s' must not be None", "%s
"); %s'''
%
(
arg
.
name
,
code
.
error_goto
(
arg
.
pos
)))
code
.
putln
(
'}'
)
...
...
Cython/Utility/Buffer.c
View file @
219725ca
...
...
@@ -47,7 +47,7 @@ static void __Pyx_RaiseBufferFallbackError(void); /*proto*/
/////////////// BufferFallbackError ///////////////
static
void
__Pyx_RaiseBufferFallbackError
(
void
)
{
PyErr_
Format
(
PyExc_ValueError
,
PyErr_
SetString
(
PyExc_ValueError
,
"Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!"
);
}
...
...
@@ -134,7 +134,7 @@ static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
}
#endif
PyErr_Format
(
PyExc_TypeError
,
"'%
1
00s' does not have the buffer interface"
,
Py_TYPE
(
obj
)
->
tp_name
);
PyErr_Format
(
PyExc_TypeError
,
"'%
.2
00s' does not have the buffer interface"
,
Py_TYPE
(
obj
)
->
tp_name
);
#if PY_VERSION_HEX < 0x02060000
fail:
...
...
Cython/Utility/CythonFunction.c
View file @
219725ca
...
...
@@ -973,7 +973,7 @@ __pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw)
}
else
if
(
binding_func
->
type
)
{
/* Unbound method call */
if
(
argc
<
1
)
{
PyErr_
Format
(
PyExc_TypeError
,
"Need at least one argument, 0 given."
);
PyErr_
SetString
(
PyExc_TypeError
,
"Need at least one argument, 0 given."
);
return
NULL
;
}
self
=
PyTuple_GET_ITEM
(
args
,
0
);
...
...
@@ -982,7 +982,7 @@ __pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw)
if
(
self
&&
!
is_classmethod
&&
!
is_staticmethod
&&
!
PyObject_IsInstance
(
self
,
binding_func
->
type
))
{
PyErr_Format
(
PyExc_TypeError
,
"First argument should be of type %
s, got %
s."
,
"First argument should be of type %
.200s, got %.200
s."
,
((
PyTypeObject
*
)
binding_func
->
type
)
->
tp_name
,
self
->
ob_type
->
tp_name
);
goto
__pyx_err
;
...
...
@@ -1141,8 +1141,8 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
return
PyClassMethod_New
(
method
);
}
#endif
PyErr_
Format
(
PyExc_TypeError
,
"Class-level classmethod() can only be called on "
"a method_descriptor or instance method."
);
PyErr_
SetString
(
PyExc_TypeError
,
"Class-level classmethod() can only be called on "
"a method_descriptor or instance method."
);
return
NULL
;
}
Cython/Utility/FunctionArguments.c
View file @
219725ca
...
...
@@ -15,7 +15,7 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in
const
char
*
name
,
int
exact
)
{
if
(
unlikely
(
!
type
))
{
PyErr_
Format
(
PyExc_SystemError
,
"Missing type object"
);
PyErr_
SetString
(
PyExc_SystemError
,
"Missing type object"
);
return
0
;
}
if
(
none_allowed
&&
obj
==
Py_None
)
return
1
;
...
...
@@ -64,7 +64,7 @@ static void __Pyx_RaiseArgtupleInvalid(
more_or_less
=
"exactly"
;
}
PyErr_Format
(
PyExc_TypeError
,
"%
s() takes %
s %"
CYTHON_FORMAT_SSIZE_T
"d positional argument%s (%"
CYTHON_FORMAT_SSIZE_T
"d given)"
,
"%
.200s() takes %.8
s %"
CYTHON_FORMAT_SSIZE_T
"d positional argument%s (%"
CYTHON_FORMAT_SSIZE_T
"d given)"
,
func_name
,
more_or_less
,
num_expected
,
(
num_expected
==
1
)
?
""
:
"s"
,
num_found
);
}
...
...
@@ -145,13 +145,13 @@ static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
return
1
;
invalid_keyword_type:
PyErr_Format
(
PyExc_TypeError
,
"%s() keywords must be strings"
,
function_name
);
"%
.200
s() keywords must be strings"
,
function_name
);
return
0
;
#endif
invalid_keyword:
PyErr_Format
(
PyExc_TypeError
,
#if PY_MAJOR_VERSION < 3
"%
s() got an unexpected keyword argument '%
s'"
,
"%
.200s() got an unexpected keyword argument '%.200
s'"
,
function_name
,
PyString_AsString
(
key
));
#else
"%s() got an unexpected keyword argument '%U'"
,
...
...
@@ -276,12 +276,12 @@ arg_passed_twice:
goto
bad
;
invalid_keyword_type:
PyErr_Format
(
PyExc_TypeError
,
"%s() keywords must be strings"
,
function_name
);
"%
.200
s() keywords must be strings"
,
function_name
);
goto
bad
;
invalid_keyword:
PyErr_Format
(
PyExc_TypeError
,
#if PY_MAJOR_VERSION < 3
"%
s() got an unexpected keyword argument '%
s'"
,
"%
.200s() got an unexpected keyword argument '%.200
s'"
,
function_name
,
PyString_AsString
(
key
));
#else
"%s() got an unexpected keyword argument '%U'"
,
...
...
Cython/Utility/ImportExport.c
View file @
219725ca
...
...
@@ -267,7 +267,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class
goto
bad
;
if
(
!
PyType_Check
(
result
))
{
PyErr_Format
(
PyExc_TypeError
,
"%
s.%
s is not a type object"
,
"%
.200s.%.200
s is not a type object"
,
module_name
,
class_name
);
goto
bad
;
}
...
...
@@ -295,7 +295,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class
}
else
if
((
size_t
)
basicsize
!=
size
)
{
PyErr_Format
(
PyExc_ValueError
,
"%
s.%
s has the wrong size, try recompiling"
,
"%
.200s.%.200
s has the wrong size, try recompiling"
,
module_name
,
class_name
);
goto
bad
;
}
...
...
@@ -330,14 +330,14 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**
cobj
=
PyDict_GetItemString
(
d
,
funcname
);
if
(
!
cobj
)
{
PyErr_Format
(
PyExc_ImportError
,
"%
s does not export expected C function %
s"
,
"%
.200s does not export expected C function %.200
s"
,
PyModule_GetName
(
module
),
funcname
);
goto
bad
;
}
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0)
if
(
!
PyCapsule_IsValid
(
cobj
,
sig
))
{
PyErr_Format
(
PyExc_TypeError
,
"C function %
s.%s has wrong signature (expected %s, got %
s)"
,
"C function %
.200s.%.200s has wrong signature (expected %.500s, got %.500
s)"
,
PyModule_GetName
(
module
),
funcname
,
sig
,
PyCapsule_GetName
(
cobj
));
goto
bad
;
}
...
...
@@ -351,7 +351,7 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**
while
(
*
s1
!=
'\0'
&&
*
s1
==
*
s2
)
{
s1
++
;
s2
++
;
}
if
(
*
s1
!=
*
s2
)
{
PyErr_Format
(
PyExc_TypeError
,
"C function %
s.%s has wrong signature (expected %s, got %
s)"
,
"C function %
.200s.%.200s has wrong signature (expected %.500s, got %.500
s)"
,
PyModule_GetName
(
module
),
funcname
,
sig
,
desc
);
goto
bad
;
}
...
...
@@ -431,14 +431,14 @@ static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, con
cobj
=
PyDict_GetItemString
(
d
,
name
);
if
(
!
cobj
)
{
PyErr_Format
(
PyExc_ImportError
,
"%
s does not export expected C variable %
s"
,
"%
.200s does not export expected C variable %.200
s"
,
PyModule_GetName
(
module
),
name
);
goto
bad
;
}
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0)
if
(
!
PyCapsule_IsValid
(
cobj
,
sig
))
{
PyErr_Format
(
PyExc_TypeError
,
"C variable %
s.%s has wrong signature (expected %s, got %
s)"
,
"C variable %
.200s.%.200s has wrong signature (expected %.500s, got %.500
s)"
,
PyModule_GetName
(
module
),
name
,
sig
,
PyCapsule_GetName
(
cobj
));
goto
bad
;
}
...
...
@@ -452,7 +452,7 @@ static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, con
while
(
*
s1
!=
'\0'
&&
*
s1
==
*
s2
)
{
s1
++
;
s2
++
;
}
if
(
*
s1
!=
*
s2
)
{
PyErr_Format
(
PyExc_TypeError
,
"C variable %
s.%s has wrong signature (expected %s, got %
s)"
,
"C variable %
.200s.%.200s has wrong signature (expected %.500s, got %.500
s)"
,
PyModule_GetName
(
module
),
name
,
sig
,
desc
);
goto
bad
;
}
...
...
Cython/Utility/MemoryView_C.c
View file @
219725ca
...
...
@@ -238,7 +238,7 @@ __pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec
if
(
spec
&
__Pyx_MEMVIEW_PTR
)
{
if
(
!
buf
->
suboffsets
||
(
buf
->
suboffsets
&&
buf
->
suboffsets
[
dim
]
<
0
))
{
PyErr_Format
(
PyExc_ValueError
,
"Buffer is not indirectly accessi
s
ble "
"Buffer is not indirectly accessible "
"in dimension %d."
,
dim
);
goto
fail
;
}
...
...
Cython/Utility/ObjectHandling.c
View file @
219725ca
...
...
@@ -36,7 +36,7 @@ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
static
CYTHON_INLINE
void
__Pyx_RaiseNeedMoreValuesError
(
Py_ssize_t
index
)
{
PyErr_Format
(
PyExc_ValueError
,
"need more than %"
CYTHON_FORMAT_SSIZE_T
"d value%s to unpack"
,
"need more than %"
CYTHON_FORMAT_SSIZE_T
"d value%
.1
s to unpack"
,
index
,
(
index
==
1
)
?
""
:
"s"
);
}
...
...
@@ -593,7 +593,7 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
{{
if
access
==
'
Get
'
}}
"'%.200s' object is unsliceable"
,
Py_TYPE
(
obj
)
->
tp_name
);
{{
else
}}
"'%.200s' object does not support slice %s"
,
"'%.200s' object does not support slice %
.10
s"
,
Py_TYPE
(
obj
)
->
tp_name
,
value
?
"assignment"
:
"deletion"
);
{{
endif
}}
...
...
@@ -919,7 +919,7 @@ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*pr
static
CYTHON_INLINE
int
__Pyx_TypeTest
(
PyObject
*
obj
,
PyTypeObject
*
type
)
{
if
(
unlikely
(
!
type
))
{
PyErr_
Format
(
PyExc_SystemError
,
"Missing type object"
);
PyErr_
SetString
(
PyExc_SystemError
,
"Missing type object"
);
return
0
;
}
if
(
likely
(
PyObject_TypeCheck
(
obj
,
type
)))
...
...
@@ -972,7 +972,7 @@ static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
#if PY_MAJOR_VERSION >= 3
"name '%U' is not defined"
,
name
);
#else
"name '%s' is not defined"
,
PyString_AS_STRING
(
name
));
"name '%
.200
s' is not defined"
,
PyString_AS_STRING
(
name
));
#endif
}
return
result
;
...
...
Cython/Utility/Overflow.c
View file @
219725ca
...
...
@@ -231,7 +231,8 @@ static int __Pyx_check_sane_{{NAME}}(void) {
sizeof
({{
TYPE
}})
==
sizeof
(
long
long
))
{
return
0
;
}
else
{
PyErr_Format
(
PyExc_RuntimeError
,
"Bad size for int type %s: %d"
,
"{{TYPE}}"
,
(
int
)
sizeof
({{
TYPE
}}));
PyErr_Format
(
PyExc_RuntimeError
,
\
"Bad size for int type %.{{max(60, len(TYPE))}}s: %d"
,
"{{TYPE}}"
,
(
int
)
sizeof
({{
TYPE
}}));
return
1
;
}
}
...
...
Cython/Utility/StringTools.c
View file @
219725ca
...
...
@@ -640,7 +640,7 @@ static CYTHON_INLINE char __Pyx_PyBytes_GetItemInt(PyObject* bytes, Py_ssize_t i
if
(
check_bounds
)
{
Py_ssize_t
size
=
PyBytes_GET_SIZE
(
bytes
);
if
(
unlikely
(
index
>=
size
)
|
((
index
<
0
)
&
unlikely
(
index
<
-
size
)))
{
PyErr_
Format
(
PyExc_IndexError
,
"string index out of range"
);
PyErr_
SetString
(
PyExc_IndexError
,
"string index out of range"
);
return
-
1
;
}
}
...
...
Cython/Utility/TypeConversion.c
View file @
219725ca
...
...
@@ -95,7 +95,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) {
if
(
ascii_chars_b
==
NULL
||
strncmp
(
ascii_chars
,
PyBytes_AS_STRING
(
ascii_chars_b
),
128
)
!=
0
)
{
PyErr_Format
(
PyExc_ValueError
,
"This module compiled with c_string_encoding=ascii, but default encoding '%s' is not a superset of ascii."
,
"This module compiled with c_string_encoding=ascii, but default encoding '%
.200
s' is not a superset of ascii."
,
default_encoding_c
);
goto
bad
;
}
...
...
@@ -263,7 +263,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
if
(
!
PyLong_Check
(
res
))
{
#endif
PyErr_Format
(
PyExc_TypeError
,
"__%
s__ returned non-%
s (type %.200s)"
,
"__%
.4s__ returned non-%.4
s (type %.200s)"
,
name
,
name
,
Py_TYPE
(
res
)
->
tp_name
);
Py_DECREF
(
res
);
return
NULL
;
...
...
@@ -319,8 +319,8 @@ static {{struct_type_decl}} {{funcname}}(PyObject * o) {
value
=
PyObject_GetItem
(
o
,
PYIDENT
(
"{{member.name}}"
));
if
(
!
value
)
{
PyErr_
SetString
(
PyExc_ValueError
,
"No value specified for struct "
"attribute '{{member.name}}'
"
);
PyErr_
Format
(
PyExc_ValueError
,
\
"No value specified for struct attribute '%.{{max(200, len(member.name))}}s'"
,
"{{member.name}}
"
);
goto
bad
;
}
{{
attr
}}
=
{{
member
.
type
.
from_py_function
}}(
value
);
...
...
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