| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
improve error msg
My tests don't show the promised speed up of 10%. The code is as fast as the old code for simple cases and slightly faster for complex cases with several of args and kwargs. But the patch simplifies the code, too.
|
| |
|
|
|
|
|
|
| |
The t# and w# formats were not correctly handled.
Will backport.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* unified the way intobject, longobject and mystrtoul handle
values around -sys.maxint-1.
* in general, trying to entierely avoid overflows in any computation
involving signed ints or longs is extremely involved. Fixed a few
simple cases where a compiler might be too clever (but that's all
guesswork).
* more overflow checks against bad data in marshal.c.
* 2.5 specific: fixed a number of places that were still confusing int
and Py_ssize_t. Some of them could potentially have caused
"real-world" breakage.
* list.pop(x): fixing overflow issues on x was messy. I just reverted
to PyArg_ParseTuple("n"), which does the right thing. (An obscure
test was trying to give a Decimal to list.pop()... doesn't make
sense any more IMHO)
* trying to write a few tests...
|
| |
|
|
|
|
| |
C argument format strings; fixes rest of #1523610.
|
|
|
|
|
| |
Also add a guard against NULL in converttuple and add a test case
(that previously would have crashed).
|
|
|
|
|
| |
Actually, checking for INT_MAX and INT_MIN is correct since
the format code explicitly handles a C "int".
|
|
|
|
| |
checking.
|
| |
|
|
|
|
| |
PyObject_CallMethod aware of PY_SSIZE_T_CLEAN.
|
|
|
|
|
|
|
|
| |
passing a string. Martin already fixed the actual crash by ensuring
Py_UNICODE is unsigned. As discussed on python-dev, this fix
removes the possibility of creating a unicode string from a raw buffer.
There is an outstanding question of how to fix the crash in 2.4.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
add a Py_SAFE_DOWNCAST() to make the code correct.
|
|
|
|
| |
ultimately going to snprintf() not the python string formatter. Right?
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
Most of these can be backported.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In C++, it's an error to pass a string literal to a char* function
without a const_cast(). Rather than require every C++ extension
module to put a cast around string literals, fix the API to state the
const-ness.
I focused on parts of the API where people usually pass literals:
PyArg_ParseTuple() and friends, Py_BuildValue(), PyMethodDef, the type
slots, etc. Predictably, there were a large set of functions that
needed to be fixed as a result of these changes. The most pervasive
change was to make the keyword args list passed to
PyArg_ParseTupleAndKewords() to be a const char *kwlist[].
One cast was required as a result of the changes: A type object
mallocs the memory for its tp_doc slot and later frees it.
PyTypeObject says that tp_doc is const char *; but if the type was
created by type_new(), we know it is safe to cast to char *.
|
|
|
|
| |
evaluating keyword arguments.
|
|
|
|
| |
(fixes bug #1119418)
|
|
|
|
|
| |
commit a yelp about a noted flaw the error messages for METH_KEYWORDS
functions under some circumstances.
|
|
|
|
|
| |
numbers in PyLong_AsLongLong, and update test suite accordingly.
Backported to 2.4.
|
|
|
|
| |
Backported to 2.4.
|
|
|
|
|
|
|
|
|
| |
[ 991812 ] PyArg_ParseTuple can miss errors with warnings as exceptions
as suggested in the report.
This is definitely a 2.3 candidate (as are most of the checkins I've
made in the last month...)
|
|
|
|
|
|
| |
PyArg_VaParse().
Closes patch #550732. Thanks Greg Chapman.
|
| |
|
|
|
|
| |
changes stay.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
New functions:
unsigned long PyInt_AsUnsignedLongMask(PyObject *);
unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *);
unsigned long PyLong_AsUnsignedLongMask(PyObject *);
unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);
New and changed format codes:
b unsigned char 0..UCHAR_MAX
B unsigned char none **
h unsigned short 0..USHRT_MAX
H unsigned short none **
i int INT_MIN..INT_MAX
I * unsigned int 0..UINT_MAX
l long LONG_MIN..LONG_MAX
k * unsigned long none
L long long LLONG_MIN..LLONG_MAX
K * unsigned long long none
Notes:
* New format codes.
** Changed from previous "range-and-a-half" to "none"; the
range-and-a-half checking wasn't particularly useful.
New test test_getargs2.py, to verify all this.
|
| |
|
|
|
|
| |
instead of raising a TypeError. Closes #660144 (again).
|
|
|
|
|
| |
Calling PyInt_AsLong() on a float truncates it which is almost never
the desired behavior. This closes SF bug #660144.
|
|
|
|
|
| |
the --disable-unicode build doesn't complain about an
unused variable.
|
| |
|
|
|
|
| |
Bugfix candidate.
|
|
|
|
|
|
| |
going through the buffer interface API.
Added tests for this to the _testcapi module and updated docs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
use wrappers on all platforms, to make this as consistent as possible x-
platform (in particular, make sure there's at least one \0 byte in
the output buffer). Also document more of the truth about what these do.
getargs.c, seterror(): Three computations of remaining buffer size were
backwards, thus telling PyOS_snprintf the buffer is larger than it
actually is. This matters a lot now that PyOS_snprintf ensures there's a
trailing \0 byte (because it didn't get the truth about the buffer size,
it was storing \0 beyond the true end of the buffer).
sysmodule.c, mywrite(): Simplify, now that PyOS_vsnprintf guarantees to
produce a \0 byte.
|
|
|
|
|
|
|
|
|
|
| |
vgetargskeywords(): Now that this routine is checking for bad input
(rather than dump core in some cases), some bad calls are raising errors
that previously "worked". This patch makes the error strings more
revealing, and changes the exceptions from SystemError to RuntimeError
(under the theory that SystemError is more of a "can't happen!" assert-
like thing, and so inappropriate for bad arguments to a public C API
function).
|
|
|
|
|
| |
Also change all the helper functions to pass along the size of the
msgbuf and use PyOS_snprintf() when writing into the buffer.
|
|
|
|
|
|
| |
seterror() uses a char array and a pointer to the current position in
that array. Use snprintf() and compute the amount of space left in
the buffer based on the current pointer position.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
+ Squash another potential buffer overrun.
+ Simplify the keyword-arg loop by decrementing the count of keywords
remaining instead of incrementing Yet Another Variable; also break
out early if the number of keyword args remaining hits 0.
Since I hit the function's closing curly brace with this patch, that's
enough of this for now <wink>.
|