summaryrefslogtreecommitdiffstats
path: root/Python/getargs.c
Commit message (Collapse)AuthorAgeFilesLines
* Revert backwards-incompatible const changes.Martin v. Löwis2006-02-271-10/+11
|
* Based on discussion with Martin and Thomas on python-checkinsNeal Norwitz2006-02-201-1/+1
| | | | add a Py_SAFE_DOWNCAST() to make the code correct.
* Fix compiler warning on amd64. We can't use zd here since this isNeal Norwitz2006-02-191-2/+2
| | | | ultimately going to snprintf() not the python string formatter. Right?
* Use Py_ssize_t to count theMartin v. Löwis2006-02-161-2/+2
|
* Merge ssize_t branch.Martin v. Löwis2006-02-151-60/+202
|
* typoGeorg Brandl2006-01-201-1/+1
|
* Remove extra parensNeal Norwitz2005-12-191-1/+1
|
* Fix SF bug #1072182, problems with signed characters.Neal Norwitz2005-12-191-4/+4
| | | | Most of these can be backported.
* Add const to several API functions that take char *.Jeremy Hylton2005-12-101-46/+44
| | | | | | | | | | | | | | | | | | | 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 *.
* Complete format code support in getargs.c::skipitem(), which is called whenGeorg Brandl2005-09-141-59/+39
| | | | evaluating keyword arguments.
* Disallow keyword arguments for type constructors that don't use them.Georg Brandl2005-08-261-0/+26
| | | | (fixes bug #1119418)
* I suppose a bug report or even a fix would be a better response, butMichael W. Hudson2005-03-301-1/+2
| | | | | commit a yelp about a noted flaw the error messages for METH_KEYWORDS functions under some circumstances.
* Revert previous checkin on getargs 'L' code. Try to convert allMartin v. Löwis2005-03-031-1/+0
| | | | | numbers in PyLong_AsLongLong, and update test suite accordingly. Backported to 2.4.
* Clear internal call error in 'L' format. Fixes #723201.Martin v. Löwis2005-03-031-0/+1
| | | | Backported to 2.4.
* FixMichael W. Hudson2004-08-071-9/+7
| | | | | | | | | [ 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...)
* Add PyArg_VaParseTupleAndKeywords(). Document this function andBrett Cannon2004-07-101-0/+36
| | | | | | PyArg_VaParse(). Closes patch #550732. Thanks Greg Chapman.
* Patch #684981: Add cleanup capability for argument parsers. Fixes 501716.Martin v. Löwis2003-05-031-28/+90
|
* Roll back changes to 'h' format code -- too much breaks. OtherGuido van Rossum2003-04-181-5/+5
| | | | changes stay.
* SF # 595026: support for masks in getargs.c.Thomas Heller2003-04-171-27/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Rename LONG_LONG to PY_LONG_LONG. Fixes #710285.Martin v. Löwis2003-03-291-6/+6
|
* If a float is passed where a int is expected, issue a DeprecationWarningNeil Schemenauer2003-02-041-12/+25
| | | | instead of raising a TypeError. Closes #660144 (again).
* Raise a TypeError if a float is passed when an integer is specified.Neil Schemenauer2003-01-241-6/+24
| | | | | Calling PyInt_AsLong() on a float truncates it which is almost never the desired behavior. This closes SF bug #660144.
* Wrap uargs declaration in a #ifdef Py_USING_UNICODE, so thatWalter Dörwald2002-11-211-0/+2
| | | | | the --disable-unicode build doesn't complain about an unused variable.
* Patch #554716: Use __va_copy where available.Martin v. Löwis2002-07-281-0/+4
|
* Fix by Greg Chapman from SF bug 534347: Potential AV in vgetargskeywords.Guido van Rossum2002-04-041-1/+7
| | | | Bugfix candidate.
* Fixed "u#" parser marker to pass through Unicode objects as-is withoutMarc-André Lemburg2002-01-091-2/+6
| | | | | | going through the buffer interface API. Added tests for this to the _testcapi module and updated docs.
* mysnprintf.c: Massive rewrite of PyOS_snprintf and PyOS_vsnprintf, toTim Peters2001-12-031-3/+3
| | | | | | | | | | | | | | | 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.
* SF bug 486278 SystemError: Python/getargs.c:1086: bad.Tim Peters2001-11-291-7/+10
| | | | | | | | | | 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).
* Two screwups fixed for sizeof(char *) instead of sizeof(char []).Jeremy Hylton2001-11-281-77/+82
| | | | | Also change all the helper functions to pass along the size of the msgbuf and use PyOS_snprintf() when writing into the buffer.
* Use PyOS_snprintf() at some cost even though it was correct before.Jeremy Hylton2001-11-281-6/+7
| | | | | | 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.
* Use PyOS_snprintf when possible.Jeremy Hylton2001-11-281-34/+41
|
* Fixes for possible buffer overflows in sprintf() usages.Marc-André Lemburg2001-11-281-14/+9
|
* vgetargskeywords()Tim Peters2001-10-271-16/+17
| | | | | | | | | | + 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>.
* vgetargskeywords: Now that it's clear that nkwlist must equal max, andTim Peters2001-10-271-4/+3
| | | | we're ensuring that's true during the format parse, get rid of nkwlist.
* vgetargskeywords: Prevent another potential sprintf buffer overrun.Tim Peters2001-10-271-2/+2
|
* vgetargskeywords: Verify kwlist has the required length while parsingTim Peters2001-10-271-20/+24
| | | | | the format, instead of waiting until after we can overindex it by mistake.
* vgetargskeywords: Removed all PyErr_Clear() calls. It's possible thatTim Peters2001-10-271-4/+8
| | | | | this routine will report an error now when it didn't before, but, if so, it's a legitimate error that should never have been suppressed.
* vgetargskeywords: The keywords arg is a dict (if non-NULL), so use theTim Peters2001-10-271-5/+5
| | | | | dict API everywhere on it instead of sometimes using the slower mapping API.
* vgetargskeywords: Removed one of the mysterious PyErr_Clear() calls.Tim Peters2001-10-271-10/+1
| | | | | | | The "need" for this was probably removed by an earlier patch that stopped the loop right before it from passing NULL to a dict lookup routine. I still haven't convinced myself that the next loop is correct, so am leaving the next mysterious PyErr_Clear() call in for now.
* vgetargskeywords:Tim Peters2001-10-271-16/+9
| | | | | | | | | | | | + Generally test nkeywords against 0 instead of keywords against NULL (saves a little work if an empty keywords dict is passed, and is conceptually more on-target regardless). + When a call erroneously specifies a keyword argument both by position and by keyword name: - It was easy to provoke this routine into an internal buffer overrun by using a long argument name. Now uses PyErr_format instead (which computes a safe buffer size). - Improved the error msg.
* vgetargskeywords:Tim Peters2001-10-271-20/+7
| | | | | | + Got rid of now-redundant dict typecheck. + Renamed nkwds to nkwlist. Now all the "counting" vrbls have names related to the things they're counting in an obvious way.
* vgetargskeywords:Tim Peters2001-10-271-12/+13
| | | | | | | + Renamed argslen to nargs. + Renamed kwlen to nkeywords. This one was especially confusing because kwlen wasn't the length of the kwlist argument, but of the keywords argument.
* vgetargskeywords:Tim Peters2001-10-271-15/+10
| | | | | | | + Removed now-redundant tuple typecheck. + Renamed "tplen" local to "argslen" (it's the length of the "args" argument; I suppose "tp" was for "Tim Peters should rename me someday <wink>).
* PyArg_ParseTupleAndKeywords: return false on internal error, not -1 (ITim Peters2001-10-271-30/+34
| | | | | | | | | | | introduced this bug just a little while ago, when *adding* internal error checks). vgetargskeywords: Rewrote the section that crawls over the format string. + Added block comment so it won't take the next person 15 minutes to reverse-engineer what it's doing. + Lined up the "else" clauses. + Rearranged the ifs in decreasing order of likelihood (for speed).
* PyArg_ParseTupleAndKeywords: do basic sanity checks on the arguments,Tim Peters2001-10-271-1/+16
| | | | | | and raise an error if they're insane. vgetargskeywords: the same, except that since this is an internal routine, just assert that the arguments are sane.
* tuple(3,4,5,x=2) dumped core on my box. vgetargskeywords() overindexedTim Peters2001-10-271-3/+13
| | | | | | | | | | | | | | the kwlist vector whenever there was a mix of positional and keyword arguments, and the number of positional arguments exceeded the length of the kwlist vector. If there was just one more positional arg than keyword, the kwlist-terminating NULL got passed to PyMapping_HasKeyString, which set an internal error that vgetargskeywords() then squashed (but it's impossible to say whether it knew it was masking an error). If more than one more positional argument, it went on to pass random trash to PyMapping_HasKeyString, which is why the example at the start happened to kill the process. Pure bugfix candidate.
* vgetargskeywords(): remove test that can't succeed. Not a bugfix, justTim Peters2001-10-271-13/+7
| | | | removing useless obfuscation.
* PyArg_UnpackTuple(): New argument unpacking function suggested by JimFred Drake2001-10-231-0/+60
| | | | Fulton, based on code Jim supplied.
* Style conformance: function name begins a new line *consistently*.Fred Drake2001-10-231-7/+11
| | | | Make convertbuffer() static like the prototype says. Not used elsewhere.
* Undo part of 2.59: 't' case of convertsimple() should not use convertbuffer().Jeremy Hylton2001-10-111-5/+11
| | | | | convertbuffer() uses the buffer interface's getreadbuffer(), but 't' should use getcharbuffer().