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
010be57d
Commit
010be57d
authored
Feb 16, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix exception string formatting for Py_ssize_t values: needs %zd instead of %d on Python >= 2.5
parent
3853c437
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
3 deletions
+28
-3
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+28
-3
No files found.
Cython/Compiler/Nodes.py
View file @
010be57d
...
...
@@ -1094,6 +1094,8 @@ class DefNode(FuncDefNode):
if
self
.
signature_has_generic_args
():
if
self
.
star_arg
:
env
.
use_utility_code
(
get_stararg_utility_code
)
elif
self
.
signature_has_generic_args
():
env
.
use_utility_code
(
raise_argtuple_too_long_utility_code
)
if
not
self
.
signature_has_nongeneric_args
():
env
.
use_utility_code
(
get_keyword_string_check_utility_code
)
elif
self
.
starstar_arg
:
...
...
@@ -1566,9 +1568,8 @@ class DefNode(FuncDefNode):
def
generate_positional_args_check
(
self
,
code
,
nargs
):
code
.
putln
(
"if (unlikely(PyTuple_GET_SIZE(%s) > %d)) {"
%
(
Naming
.
args_cname
,
nargs
))
error_message
=
"function takes at most %d positional arguments (%d given)"
code
.
putln
(
"PyErr_Format(PyExc_TypeError,
\
"
%s
\
"
, %d, PyTuple_GET_SIZE(%s));"
%
(
error_message
,
nargs
,
Naming
.
args_cname
))
code
.
putln
(
"__Pyx_RaiseArgtupleTooLong(%d, PyTuple_GET_SIZE(%s));"
%
(
nargs
,
Naming
.
args_cname
))
code
.
putln
(
"return %s;"
%
self
.
error_value
())
code
.
putln
(
"}"
)
...
...
@@ -3641,6 +3642,30 @@ static INLINE int __Pyx_SplitStarArg(
}
"""
]
#------------------------------------------------------------------------------------
#
# __Pyx_RaiseArgtupleTooLong raises the correct exception when too
# many positional arguments were found. This handles Py_ssize_t
# formatting correctly.
raise_argtuple_too_long_utility_code
=
[
"""
static INLINE void __Pyx_RaiseArgtupleTooLong(Py_ssize_t num_expected, Py_ssize_t num_found); /*proto*/
"""
,
"""
static INLINE void __Pyx_RaiseArgtupleTooLong(
Py_ssize_t num_expected,
Py_ssize_t num_found)
{
const char* error_message =
#if PY_VERSION_HEX < 0x02050000
"function takes at most %d positional arguments (%d given)";
#else
"function takes at most %zd positional arguments (%zd given)";
#endif
PyErr_Format(PyExc_TypeError, error_message, num_expected, num_found);
}
"""
]
#------------------------------------------------------------------------------------
#
# __Pyx_CheckKeywordStrings raises an error if non-string keywords
...
...
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