diff -r 59a2807872d5 Modules/_codecsmodule.c --- a/Modules/_codecsmodule.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/_codecsmodule.c Fri Sep 21 18:13:47 2012 +0300 @@ -263,7 +263,7 @@ Py_ssize_t consumed; PyObject *decoded = NULL; - if (!PyArg_ParseTuple(args, "y*|zi:utf_7_decode", + if (!PyArg_ParseTuple(args, "y*|zp:utf_7_decode", &pbuf, &errors, &final)) return NULL; consumed = pbuf.len; @@ -286,7 +286,7 @@ Py_ssize_t consumed; PyObject *decoded = NULL; - if (!PyArg_ParseTuple(args, "y*|zi:utf_8_decode", + if (!PyArg_ParseTuple(args, "y*|zp:utf_8_decode", &pbuf, &errors, &final)) return NULL; consumed = pbuf.len; @@ -310,7 +310,7 @@ Py_ssize_t consumed; PyObject *decoded; - if (!PyArg_ParseTuple(args, "y*|zi:utf_16_decode", + if (!PyArg_ParseTuple(args, "y*|zp:utf_16_decode", &pbuf, &errors, &final)) return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ @@ -333,7 +333,7 @@ Py_ssize_t consumed; PyObject *decoded = NULL; - if (!PyArg_ParseTuple(args, "y*|zi:utf_16_le_decode", + if (!PyArg_ParseTuple(args, "y*|zp:utf_16_le_decode", &pbuf, &errors, &final)) return NULL; @@ -357,7 +357,7 @@ Py_ssize_t consumed; PyObject *decoded = NULL; - if (!PyArg_ParseTuple(args, "y*|zi:utf_16_be_decode", + if (!PyArg_ParseTuple(args, "y*|zp:utf_16_be_decode", &pbuf, &errors, &final)) return NULL; @@ -389,7 +389,7 @@ int final = 0; Py_ssize_t consumed; - if (!PyArg_ParseTuple(args, "y*|zii:utf_16_ex_decode", + if (!PyArg_ParseTuple(args, "y*|zip:utf_16_ex_decode", &pbuf, &errors, &byteorder, &final)) return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ @@ -414,7 +414,7 @@ Py_ssize_t consumed; PyObject *decoded; - if (!PyArg_ParseTuple(args, "y*|zi:utf_32_decode", + if (!PyArg_ParseTuple(args, "y*|zp:utf_32_decode", &pbuf, &errors, &final)) return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ @@ -437,7 +437,7 @@ Py_ssize_t consumed; PyObject *decoded; - if (!PyArg_ParseTuple(args, "y*|zi:utf_32_le_decode", + if (!PyArg_ParseTuple(args, "y*|zp:utf_32_le_decode", &pbuf, &errors, &final)) return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ @@ -460,7 +460,7 @@ Py_ssize_t consumed; PyObject *decoded; - if (!PyArg_ParseTuple(args, "y*|zi:utf_32_be_decode", + if (!PyArg_ParseTuple(args, "y*|zp:utf_32_be_decode", &pbuf, &errors, &final)) return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ @@ -491,7 +491,7 @@ int final = 0; Py_ssize_t consumed; - if (!PyArg_ParseTuple(args, "y*|zii:utf_32_ex_decode", + if (!PyArg_ParseTuple(args, "y*|zip:utf_32_ex_decode", &pbuf, &errors, &byteorder, &final)) return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ @@ -605,7 +605,7 @@ Py_ssize_t consumed; PyObject *decoded = NULL; - if (!PyArg_ParseTuple(args, "y*|zi:mbcs_decode", + if (!PyArg_ParseTuple(args, "y*|zp:mbcs_decode", &pbuf, &errors, &final)) return NULL; consumed = pbuf.len; @@ -629,7 +629,7 @@ PyObject *decoded = NULL; int code_page; - if (!PyArg_ParseTuple(args, "iy*|zi:code_page_decode", + if (!PyArg_ParseTuple(args, "iy*|zp:code_page_decode", &code_page, &pbuf, &errors, &final)) return NULL; consumed = pbuf.len; diff -r 59a2807872d5 Modules/_io/_iomodule.c --- a/Modules/_io/_iomodule.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/_io/_iomodule.c Fri Sep 21 18:13:47 2012 +0300 @@ -238,7 +238,7 @@ _Py_IDENTIFIER(fileno); _Py_IDENTIFIER(mode); - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|sizzziO:open", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|sizzzpO:open", kwlist, &file, &mode, &buffering, &encoding, &errors, &newline, &closefd, &opener)) { @@ -345,7 +345,8 @@ /* Create the Raw file stream */ raw = PyObject_CallFunction((PyObject *)&PyFileIO_Type, - "OsiO", file, rawmode, closefd, opener); + "OsOO", file, rawmode, + closefd ? Py_True : Py_False, opener); if (raw == NULL) return NULL; @@ -358,9 +359,9 @@ PyObject *res = _PyObject_CallMethodId(raw, &PyId_isatty, NULL); if (res == NULL) goto error; - isatty = PyLong_AsLong(res); + isatty = PyObject_IsTrue(res); Py_DECREF(res); - if (isatty == -1 && PyErr_Occurred()) + if (isatty < 0) goto error; } @@ -440,10 +441,10 @@ /* wraps into a TextIOWrapper */ wrapper = PyObject_CallFunction((PyObject *)&PyTextIOWrapper_Type, - "Osssi", + "OsssO", buffer, encoding, errors, newline, - line_buffering); + line_buffering ? Py_True : Py_False); Py_CLEAR(buffer); if (wrapper == NULL) goto error; diff -r 59a2807872d5 Modules/_io/fileio.c --- a/Modules/_io/fileio.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/_io/fileio.c Fri Sep 21 18:13:47 2012 +0300 @@ -233,7 +233,7 @@ self->fd = -1; } - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|siO:fileio", + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|spO:fileio", kwlist, &nameobj, &mode, &closefd, &opener)) return -1; diff -r 59a2807872d5 Modules/_io/stringio.c --- a/Modules/_io/stringio.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/_io/stringio.c Fri Sep 21 18:13:47 2012 +0300 @@ -722,7 +722,7 @@ if (self->readuniversal) { self->decoder = PyObject_CallFunction( (PyObject *)&PyIncrementalNewlineDecoder_Type, - "Oi", Py_None, (int) self->readtranslate); + "OO", Py_None, self->readtranslate ? Py_True : Py_False); if (self->decoder == NULL) return -1; } diff -r 59a2807872d5 Modules/_io/textio.c --- a/Modules/_io/textio.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/_io/textio.c Fri Sep 21 18:13:47 2012 +0300 @@ -225,7 +225,7 @@ PyObject *errors = NULL; char *kwlist[] = {"decoder", "translate", "errors", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "Oi|O:IncrementalNewlineDecoder", + if (!PyArg_ParseTupleAndKeywords(args, kwds, "Op|O:IncrementalNewlineDecoder", kwlist, &decoder, &translate, &errors)) return -1; @@ -480,7 +480,7 @@ PyObject *input; int final = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|i:IncrementalNewlineDecoder", + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|p:IncrementalNewlineDecoder", kwlist, &input, &final)) return NULL; return _PyIncrementalNewlineDecoder_decode((PyObject *) self, input, final); @@ -837,7 +837,7 @@ self->ok = 0; self->detached = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|zzzii:fileio", + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|zzzpp:fileio", kwlist, &buffer, &encoding, &errors, &newline, &line_buffering, &write_through)) return -1; @@ -986,7 +986,7 @@ if (self->readuniversal) { PyObject *incrementalDecoder = PyObject_CallFunction( (PyObject *)&PyIncrementalNewlineDecoder_Type, - "Oi", self->decoder, (int)self->readtranslate); + "OO", self->decoder, self->readtranslate ? Py_True : Py_False); if (incrementalDecoder == NULL) goto error; Py_CLEAR(self->decoder); diff -r 59a2807872d5 Modules/_json.c --- a/Modules/_json.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/_json.c Fri Sep 21 18:13:47 2012 +0300 @@ -32,7 +32,7 @@ typedef struct _PyScannerObject { PyObject_HEAD - PyObject *strict; + char strict; PyObject *object_hook; PyObject *object_pairs_hook; PyObject *parse_float; @@ -42,7 +42,7 @@ } PyScannerObject; static PyMemberDef scanner_members[] = { - {"strict", T_OBJECT, offsetof(PyScannerObject, strict), READONLY, "strict"}, + {"strict", T_BOOL, offsetof(PyScannerObject, strict), READONLY, "strict"}, {"object_hook", T_OBJECT, offsetof(PyScannerObject, object_hook), READONLY, "object_hook"}, {"object_pairs_hook", T_OBJECT, offsetof(PyScannerObject, object_pairs_hook), READONLY}, {"parse_float", T_OBJECT, offsetof(PyScannerObject, parse_float), READONLY, "parse_float"}, @@ -59,8 +59,8 @@ PyObject *indent; PyObject *key_separator; PyObject *item_separator; - PyObject *sort_keys; - PyObject *skipkeys; + char sort_keys; + char skipkeys; int fast_encode; int allow_nan; } PyEncoderObject; @@ -72,8 +72,8 @@ {"indent", T_OBJECT, offsetof(PyEncoderObject, indent), READONLY, "indent"}, {"key_separator", T_OBJECT, offsetof(PyEncoderObject, key_separator), READONLY, "key_separator"}, {"item_separator", T_OBJECT, offsetof(PyEncoderObject, item_separator), READONLY, "item_separator"}, - {"sort_keys", T_OBJECT, offsetof(PyEncoderObject, sort_keys), READONLY, "sort_keys"}, - {"skipkeys", T_OBJECT, offsetof(PyEncoderObject, skipkeys), READONLY, "skipkeys"}, + {"sort_keys", T_BOOL, offsetof(PyEncoderObject, sort_keys), READONLY, "sort_keys"}, + {"skipkeys", T_BOOL, offsetof(PyEncoderObject, skipkeys), READONLY, "skipkeys"}, {NULL} }; @@ -525,7 +525,7 @@ Py_ssize_t end; Py_ssize_t next_end = -1; int strict = 1; - if (!PyArg_ParseTuple(args, "OO&|i:scanstring", &pystr, _convertPyInt_AsSsize_t, &end, &strict)) { + if (!PyArg_ParseTuple(args, "OO&|p:scanstring", &pystr, _convertPyInt_AsSsize_t, &end, &strict)) { return NULL; } if (PyUnicode_Check(pystr)) { @@ -578,7 +578,6 @@ PyScannerObject *s; assert(PyScanner_Check(self)); s = (PyScannerObject *)self; - Py_VISIT(s->strict); Py_VISIT(s->object_hook); Py_VISIT(s->object_pairs_hook); Py_VISIT(s->parse_float); @@ -593,7 +592,6 @@ PyScannerObject *s; assert(PyScanner_Check(self)); s = (PyScannerObject *)self; - Py_CLEAR(s->strict); Py_CLEAR(s->object_hook); Py_CLEAR(s->object_pairs_hook); Py_CLEAR(s->parse_float); @@ -618,7 +616,6 @@ PyObject *val = NULL; PyObject *rval = NULL; PyObject *key = NULL; - int strict = PyObject_IsTrue(s->strict); int has_pairs_hook = (s->object_pairs_hook != Py_None); Py_ssize_t next_idx; @@ -649,7 +646,7 @@ raise_errmsg("Expecting property name enclosed in double quotes", pystr, idx); goto bail; } - key = scanstring_unicode(pystr, idx + 1, strict, &next_idx); + key = scanstring_unicode(pystr, idx + 1, s->strict, &next_idx); if (key == NULL) goto bail; memokey = PyDict_GetItem(s->memo, key); @@ -994,8 +991,7 @@ case '"': /* string */ return scanstring_unicode(pystr, idx + 1, - PyObject_IsTrue(s->strict), - next_idx_ptr); + s->strict, next_idx_ptr); case '{': /* object */ if (Py_EnterRecursiveCall(" while decoding a JSON object " @@ -1112,7 +1108,6 @@ PyScannerObject *s; s = (PyScannerObject *)type->tp_alloc(type, 0); if (s != NULL) { - s->strict = NULL; s->object_hook = NULL; s->object_pairs_hook = NULL; s->parse_float = NULL; @@ -1127,6 +1122,7 @@ { /* Initialize Scanner object */ PyObject *ctx; + PyObject *strict; static char *kwlist[] = {"context", NULL}; PyScannerObject *s; @@ -1142,10 +1138,13 @@ goto bail; } + strict = PyObject_GetAttrString(ctx, "strict"); + if (strict == NULL) + goto bail; + s->strict = PyObject_IsTrue(strict); + if (s->strict < 0) + goto bail; /* All of these will fail "gracefully" so we don't need to verify them */ - s->strict = PyObject_GetAttrString(ctx, "strict"); - if (s->strict == NULL) - goto bail; s->object_hook = PyObject_GetAttrString(ctx, "object_hook"); if (s->object_hook == NULL) goto bail; @@ -1165,7 +1164,7 @@ return 0; bail: - Py_CLEAR(s->strict); + Py_XDECREF(strict); Py_CLEAR(s->object_hook); Py_CLEAR(s->object_pairs_hook); Py_CLEAR(s->parse_float); @@ -1231,8 +1230,6 @@ s->indent = NULL; s->key_separator = NULL; s->item_separator = NULL; - s->sort_keys = NULL; - s->skipkeys = NULL; } return (PyObject *)s; } @@ -1245,12 +1242,13 @@ PyEncoderObject *s; PyObject *markers, *defaultfn, *encoder, *indent, *key_separator; - PyObject *item_separator, *sort_keys, *skipkeys, *allow_nan; + PyObject *item_separator; + int sort_keys, skipkeys, allow_nan; assert(PyEncoder_Check(self)); s = (PyEncoderObject *)self; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOOOOOOOO:make_encoder", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOOOOOppp:make_encoder", kwlist, &markers, &defaultfn, &encoder, &indent, &key_separator, &item_separator, &sort_keys, &skipkeys, &allow_nan)) return -1; @@ -1264,7 +1262,7 @@ s->sort_keys = sort_keys; s->skipkeys = skipkeys; s->fast_encode = (PyCFunction_Check(s->encoder) && PyCFunction_GetFunction(s->encoder) == (PyCFunction)py_encode_basestring_ascii); - s->allow_nan = PyObject_IsTrue(allow_nan); + s->allow_nan = allow_nan; Py_INCREF(s->markers); Py_INCREF(s->defaultfn); @@ -1272,8 +1270,6 @@ Py_INCREF(s->indent); Py_INCREF(s->key_separator); Py_INCREF(s->item_separator); - Py_INCREF(s->sort_keys); - Py_INCREF(s->skipkeys); return 0; } @@ -1484,7 +1480,6 @@ PyObject *it = NULL; PyObject *items; PyObject *item = NULL; - int skipkeys; Py_ssize_t idx; if (open_dict == NULL || close_dict == NULL || empty_dict == NULL) { @@ -1526,7 +1521,7 @@ */ } - if (PyObject_IsTrue(s->sort_keys)) { + if (s->sort_keys) { /* First sort the keys then replace them with (key, value) tuples. */ Py_ssize_t i, nitems; items = PyMapping_Keys(dct); @@ -1559,7 +1554,6 @@ Py_DECREF(items); if (it == NULL) goto bail; - skipkeys = PyObject_IsTrue(s->skipkeys); idx = 0; while ((item = PyIter_Next(it)) != NULL) { PyObject *encoded, *key, *value; @@ -1589,7 +1583,7 @@ if (kstr == NULL) goto bail; } - else if (skipkeys) { + else if (s->skipkeys) { Py_DECREF(item); continue; } @@ -1761,8 +1755,6 @@ Py_VISIT(s->indent); Py_VISIT(s->key_separator); Py_VISIT(s->item_separator); - Py_VISIT(s->sort_keys); - Py_VISIT(s->skipkeys); return 0; } @@ -1779,8 +1771,6 @@ Py_CLEAR(s->indent); Py_CLEAR(s->key_separator); Py_CLEAR(s->item_separator); - Py_CLEAR(s->sort_keys); - Py_CLEAR(s->skipkeys); return 0; } diff -r 59a2807872d5 Modules/_lsprof.c --- a/Modules/_lsprof.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/_lsprof.c Fri Sep 21 18:13:47 2012 +0300 @@ -694,7 +694,7 @@ int subcalls = -1; int builtins = -1; static char *kwlist[] = {"subcalls", "builtins", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|ii:enable", + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|pp:enable", kwlist, &subcalls, &builtins)) return NULL; if (setSubcalls(self, subcalls) < 0 || setBuiltins(self, builtins) < 0) @@ -779,7 +779,7 @@ static char *kwlist[] = {"timer", "timeunit", "subcalls", "builtins", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kw, "|Odii:Profiler", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kw, "|Odpp:Profiler", kwlist, &timer, &timeunit, &subcalls, &builtins)) return -1; diff -r 59a2807872d5 Modules/_multiprocessing/semaphore.c --- a/Modules/_multiprocessing/semaphore.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/_multiprocessing/semaphore.c Fri Sep 21 18:13:47 2012 +0300 @@ -68,7 +68,7 @@ static char *kwlist[] = {"block", "timeout", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|iO", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|pO", kwlist, &blocking, &timeout_obj)) return NULL; @@ -265,7 +265,7 @@ static char *kwlist[] = {"block", "timeout", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|iO", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|pO", kwlist, &blocking, &timeout_obj)) return NULL; diff -r 59a2807872d5 Modules/_pickle.c --- a/Modules/_pickle.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/_pickle.c Fri Sep 21 18:13:47 2012 +0300 @@ -793,10 +793,9 @@ static int _Pickler_SetProtocol(PicklerObject *self, PyObject *proto_obj, - PyObject *fix_imports_obj) + int fix_imports) { long proto = 0; - int fix_imports; if (proto_obj == NULL || proto_obj == Py_None) proto = DEFAULT_PROTOCOL; @@ -812,10 +811,6 @@ HIGHEST_PROTOCOL); return -1; } - fix_imports = PyObject_IsTrue(fix_imports_obj); - if (fix_imports == -1) - return -1; - self->proto = proto; self->bin = proto > 0; self->fix_imports = fix_imports && proto < 3; @@ -3469,11 +3464,11 @@ static char *kwlist[] = {"file", "protocol", "fix_imports", 0}; PyObject *file; PyObject *proto_obj = NULL; - PyObject *fix_imports = Py_True; + int fix_imports = 1; _Py_IDENTIFIER(persistent_id); _Py_IDENTIFIER(dispatch_table); - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|OO:Pickler", + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|Op:Pickler", kwlist, &file, &proto_obj, &fix_imports)) return -1; @@ -5640,7 +5635,7 @@ { static char *kwlist[] = {"file", "fix_imports", "encoding", "errors", 0}; PyObject *file; - PyObject *fix_imports = Py_True; + int fix_imports = 1; char *encoding = NULL; char *errors = NULL; _Py_IDENTIFIER(persistent_load); @@ -5660,7 +5655,7 @@ extra careful in the other Unpickler methods, since a subclass could forget to call Unpickler.__init__() thus breaking our internal invariants. */ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|Oss:Unpickler", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|pss:Unpickler", kwlist, &file, &fix_imports, &encoding, &errors)) return -1; @@ -5674,9 +5669,7 @@ if (_Unpickler_SetInputEncoding(self, encoding, errors) < 0) return -1; - self->fix_imports = PyObject_IsTrue(fix_imports); - if (self->fix_imports == -1) - return -1; + self->fix_imports = fix_imports; if (_PyObject_HasAttrId((PyObject *)self, &PyId_persistent_load)) { self->pers_func = _PyObject_GetAttrId((PyObject *)self, @@ -6072,7 +6065,7 @@ PyObject *obj; PyObject *file; PyObject *proto = NULL; - PyObject *fix_imports = Py_True; + int fix_imports = 1; PicklerObject *pickler; /* fix_imports is a keyword-only argument. */ @@ -6083,7 +6076,7 @@ return NULL; } - if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO:dump", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO|Op:dump", kwlist, &obj, &file, &proto, &fix_imports)) return NULL; @@ -6136,7 +6129,7 @@ PyObject *obj; PyObject *proto = NULL; PyObject *result; - PyObject *fix_imports = Py_True; + int fix_imports = 1; PicklerObject *pickler; /* fix_imports is a keyword-only argument. */ @@ -6147,7 +6140,7 @@ return NULL; } - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|OO:dumps", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|Op:dumps", kwlist, &obj, &proto, &fix_imports)) return NULL; @@ -6199,7 +6192,7 @@ { static char *kwlist[] = {"file", "fix_imports", "encoding", "errors", 0}; PyObject *file; - PyObject *fix_imports = Py_True; + int fix_imports = 1; PyObject *result; char *encoding = NULL; char *errors = NULL; @@ -6213,7 +6206,7 @@ return NULL; } - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|Oss:load", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|pss:load", kwlist, &file, &fix_imports, &encoding, &errors)) return NULL; @@ -6227,9 +6220,7 @@ if (_Unpickler_SetInputEncoding(unpickler, encoding, errors) < 0) goto error; - unpickler->fix_imports = PyObject_IsTrue(fix_imports); - if (unpickler->fix_imports == -1) - goto error; + unpickler->fix_imports = fix_imports; result = load(unpickler); Py_DECREF(unpickler); @@ -6262,7 +6253,7 @@ { static char *kwlist[] = {"input", "fix_imports", "encoding", "errors", 0}; PyObject *input; - PyObject *fix_imports = Py_True; + int fix_imports = 1; PyObject *result; char *encoding = NULL; char *errors = NULL; @@ -6276,7 +6267,7 @@ return NULL; } - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|Oss:loads", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|pss:loads", kwlist, &input, &fix_imports, &encoding, &errors)) return NULL; @@ -6290,9 +6281,7 @@ if (_Unpickler_SetInputEncoding(unpickler, encoding, errors) < 0) goto error; - unpickler->fix_imports = PyObject_IsTrue(fix_imports); - if (unpickler->fix_imports == -1) - goto error; + unpickler->fix_imports = fix_imports; result = load(unpickler); Py_DECREF(unpickler); diff -r 59a2807872d5 Modules/_posixsubprocess.c --- a/Modules/_posixsubprocess.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/_posixsubprocess.c Fri Sep 21 18:13:47 2012 +0300 @@ -518,7 +518,7 @@ Py_ssize_t arg_num; if (!PyArg_ParseTuple( - args, "OOpOOOiiiiiiiiiiO:fork_exec", + args, "OOpOOOiiiiiiiipiO:fork_exec", &process_args, &executable_list, &close_fds, &py_fds_to_keep, &cwd_obj, &env_list, &p2cread, &p2cwrite, &c2pread, &c2pwrite, diff -r 59a2807872d5 Modules/_sqlite/connection.c --- a/Modules/_sqlite/connection.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/_sqlite/connection.c Fri Sep 21 18:13:47 2012 +0300 @@ -71,7 +71,7 @@ double timeout = 5.0; int rc; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|diOiOi", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|diOpOi", kwlist, &database, &timeout, &detect_types, &isolation_level, &check_same_thread, &factory, &cached_statements)) { return -1; @@ -1032,7 +1032,7 @@ return NULL; } - if (!PyArg_ParseTuple(args, "i", &onoff)) { + if (!PyArg_ParseTuple(args, "p", &onoff)) { return NULL; } diff -r 59a2807872d5 Modules/_sqlite/module.c --- a/Modules/_sqlite/module.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/_sqlite/module.c Fri Sep 21 18:13:47 2012 +0300 @@ -61,7 +61,7 @@ PyObject* result; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|diOiOi", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|diOpOi", kwlist, &database, &timeout, &detect_types, &isolation_level, &check_same_thread, &factory, &cached_statements)) { return NULL; @@ -120,7 +120,7 @@ int do_enable; int rc; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &do_enable)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "p", kwlist, &do_enable)) { return NULL; } diff -r 59a2807872d5 Modules/_ssl.c --- a/Modules/_ssl.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/_ssl.c Fri Sep 21 18:13:47 2012 +0300 @@ -2205,12 +2205,12 @@ /* server_hostname is either None (or absent), or to be encoded using the idna encoding. */ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!i|O!:_wrap_socket", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!p|O!:_wrap_socket", kwlist, PySocketModule.Sock_Type, &sock, &server_side, Py_TYPE(Py_None), &hostname_obj)) { PyErr_Clear(); - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!iet:_wrap_socket", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!pet:_wrap_socket", kwlist, PySocketModule.Sock_Type, &sock, &server_side, "idna", &hostname)) diff -r 59a2807872d5 Modules/_threadmodule.c --- a/Modules/_threadmodule.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/_threadmodule.c Fri Sep 21 18:13:47 2012 +0300 @@ -106,7 +106,7 @@ PY_TIMEOUT_T microseconds; PyLockStatus r; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|id:acquire", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|pd:acquire", kwlist, &blocking, &timeout)) return NULL; @@ -276,7 +276,7 @@ long tid; PyLockStatus r = PY_LOCK_ACQUIRED; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|id:acquire", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|pd:acquire", kwlist, &blocking, &timeout)) return NULL; diff -r 59a2807872d5 Modules/_tkinter.c --- a/Modules/_tkinter.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/_tkinter.c Fri Sep 21 18:13:47 2012 +0300 @@ -2667,7 +2667,7 @@ { int wantobjects = -1; - if (!PyArg_ParseTuple(args, "|i:wantobjects", &wantobjects)) + if (!PyArg_ParseTuple(args, "|p:wantobjects", &wantobjects)) return NULL; if (wantobjects == -1) return PyBool_FromLong(((TkappObject*)self)->wantobjects); @@ -2909,7 +2909,7 @@ className = "Tk"; - if (!PyArg_ParseTuple(args, "|zssiiiiz:create", + if (!PyArg_ParseTuple(args, "|zssppppz:create", &screenName, &baseName, &className, &interactive, &wantobjects, &wantTk, &sync, &use)) diff -r 59a2807872d5 Modules/binascii.c --- a/Modules/binascii.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/binascii.c Fri Sep 21 18:13:47 2012 +0300 @@ -646,7 +646,7 @@ rv = NULL; } if (rv) { - PyObject *rrv = Py_BuildValue("Oi", rv, done); + PyObject *rrv = Py_BuildValue("OO", rv, done ? Py_True : Py_False); PyBuffer_Release(&pascii); Py_DECREF(rv); return rrv; @@ -1235,7 +1235,7 @@ static char *kwlist[] = {"data", "header", NULL}; int header = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|i:a2b_qp", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|p:a2b_qp", kwlist, ascii_buffer_converter, &pdata, &header)) return NULL; data = pdata.buf; @@ -1347,7 +1347,7 @@ int crlf = 0; unsigned char *p; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|iii", kwlist, &pdata, + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|ppp", kwlist, &pdata, "etabs, &istext, &header)) return NULL; data = pdata.buf; diff -r 59a2807872d5 Modules/cjkcodecs/multibytecodec.c --- a/Modules/cjkcodecs/multibytecodec.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/cjkcodecs/multibytecodec.c Fri Sep 21 18:13:47 2012 +0300 @@ -903,7 +903,7 @@ PyObject *data; int final = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i:encode", + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|p:encode", incrementalkwarglist, &data, &final)) return NULL; @@ -1057,7 +1057,7 @@ Py_ssize_t wsize, finalsize = 0, size, origpending; int final = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|i:decode", + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|p:decode", incrementalkwarglist, &pdata, &final)) return NULL; data = pdata.buf; diff -r 59a2807872d5 Modules/faulthandler.c --- a/Modules/faulthandler.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/faulthandler.c Fri Sep 21 18:13:47 2012 +0300 @@ -199,7 +199,7 @@ int fd; if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|Oi:dump_traceback", kwlist, + "|Op:dump_traceback", kwlist, &file, &all_threads)) return NULL; @@ -324,7 +324,7 @@ PyThreadState *tstate; if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|Oi:enable", kwlist, &file, &all_threads)) + "|Op:enable", kwlist, &file, &all_threads)) return NULL; file = faulthandler_get_fileno(file, &fd); @@ -714,7 +714,7 @@ int err; if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "i|Oii:register", kwlist, + "i|Opp:register", kwlist, &signum, &file, &all_threads, &chain)) return NULL; @@ -802,7 +802,7 @@ volatile int *x; volatile int y; int release_gil = 0; - if (!PyArg_ParseTuple(args, "|i:_read_null", &release_gil)) + if (!PyArg_ParseTuple(args, "|p:_read_null", &release_gil)) return NULL; x = NULL; diff -r 59a2807872d5 Modules/fcntlmodule.c --- a/Modules/fcntlmodule.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/fcntlmodule.c Fri Sep 21 18:13:47 2012 +0300 @@ -119,7 +119,7 @@ int mutate_arg = 1; char buf[IOCTL_BUFSZ+1]; /* argument plus NUL byte */ - if (PyArg_ParseTuple(args, "O&Iw*|i:ioctl", + if (PyArg_ParseTuple(args, "O&Iw*|p:ioctl", conv_descriptor, &fd, &code, &pstr, &mutate_arg)) { char *arg; diff -r 59a2807872d5 Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/itertoolsmodule.c Fri Sep 21 18:13:47 2012 +0300 @@ -945,8 +945,8 @@ /* Create a new cycle with the iterator tuple, then set * the saved state on it. */ - return Py_BuildValue("O(O)(Oi)", Py_TYPE(lz), - lz->it, lz->saved, lz->firstpass); + return Py_BuildValue("O(O)(OO)", Py_TYPE(lz), + lz->it, lz->saved, lz->firstpass ? Py_True : Py_False); } static PyObject * @@ -954,12 +954,12 @@ { PyObject *saved=NULL; int firstpass; - if (!PyArg_ParseTuple(state, "Oi", &saved, &firstpass)) + if (!PyArg_ParseTuple(state, "Op", &saved, &firstpass)) return NULL; Py_CLEAR(lz->saved); lz->saved = saved; Py_XINCREF(lz->saved); - lz->firstpass = firstpass != 0; + lz->firstpass = firstpass; Py_RETURN_NONE; } diff -r 59a2807872d5 Modules/main.c --- a/Modules/main.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/main.c Fri Sep 21 18:13:47 2012 +0300 @@ -186,7 +186,7 @@ Py_DECREF(runmodule); return -1; } - runargs = Py_BuildValue("(Oi)", module, set_argv0); + runargs = Py_BuildValue("(OO)", module, set_argv0 ? Py_True : Py_False); if (runargs == NULL) { fprintf(stderr, "Could not create arguments for runpy._run_module_as_main\n"); diff -r 59a2807872d5 Modules/ossaudiodev.c --- a/Modules/ossaudiodev.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/ossaudiodev.c Fri Sep 21 18:13:47 2012 +0300 @@ -566,7 +566,7 @@ if (!_is_fd_valid(self->fd)) return NULL; - if (!PyArg_ParseTuple(args, "iii|i:setparameters", + if (!PyArg_ParseTuple(args, "iii|p:setparameters", &wanted_fmt, &wanted_channels, &wanted_rate, &strict)) return NULL; diff -r 59a2807872d5 Modules/posixmodule.c --- a/Modules/posixmodule.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/posixmodule.c Fri Sep 21 18:13:47 2012 +0300 @@ -2077,7 +2077,7 @@ stat_float_times(PyObject* self, PyObject *args) { int newval = -1; - if (!PyArg_ParseTuple(args, "|i:stat_float_times", &newval)) + if (!PyArg_ParseTuple(args, "|p:stat_float_times", &newval)) return NULL; if (PyErr_WarnEx(PyExc_DeprecationWarning, "stat_float_times() is deprecated", @@ -2825,7 +2825,7 @@ static char *keywords[] = {"path", "flags", "follow_symlinks", NULL}; memset(&path, 0, sizeof(path)); - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&k|$i:chflags", keywords, + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&k|$p:chflags", keywords, path_converter, &path, &flags, &follow_symlinks)) return NULL; @@ -7124,7 +7124,7 @@ } #endif - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&|i$O&:symlink", + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&|p$O&:symlink", keywords, path_converter, &src, path_converter, &dst, diff -r 59a2807872d5 Modules/pyexpat.c --- a/Modules/pyexpat.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/pyexpat.c Fri Sep 21 18:13:47 2012 +0300 @@ -785,7 +785,7 @@ int slen; int isFinal = 0; - if (!PyArg_ParseTuple(args, "s#|i:Parse", &s, &slen, &isFinal)) + if (!PyArg_ParseTuple(args, "s#|p:Parse", &s, &slen, &isFinal)) return NULL; return get_parse_result(self, XML_Parse(self->itself, s, slen, isFinal)); diff -r 59a2807872d5 Modules/socketmodule.c --- a/Modules/socketmodule.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Modules/socketmodule.c Fri Sep 21 18:13:47 2012 +0300 @@ -2075,8 +2075,8 @@ { int block; - block = PyLong_AsLong(arg); - if (block == -1 && PyErr_Occurred()) + block = PyObject_IsTrue(arg); + if (block < 0) return NULL; s->sock_timeout = block ? -1.0 : 0.0; diff -r 59a2807872d5 Objects/bytearrayobject.c --- a/Objects/bytearrayobject.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Objects/bytearrayobject.c Fri Sep 21 18:13:47 2012 +0300 @@ -2651,7 +2651,7 @@ static char *kwlist[] = {"keepends", 0}; int keepends = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i:splitlines", + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|p:splitlines", kwlist, &keepends)) return NULL; diff -r 59a2807872d5 Objects/bytesobject.c --- a/Objects/bytesobject.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Objects/bytesobject.c Fri Sep 21 18:13:47 2012 +0300 @@ -2330,7 +2330,7 @@ static char *kwlist[] = {"keepends", 0}; int keepends = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i:splitlines", + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|p:splitlines", kwlist, &keepends)) return NULL; diff -r 59a2807872d5 Objects/fileobject.c --- a/Objects/fileobject.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Objects/fileobject.c Fri Sep 21 18:13:47 2012 +0300 @@ -35,9 +35,9 @@ io = PyImport_ImportModule("io"); if (io == NULL) return NULL; - stream = _PyObject_CallMethodId(io, &PyId_open, "isisssi", fd, mode, + stream = _PyObject_CallMethodId(io, &PyId_open, "isisssO", fd, mode, buffering, encoding, errors, - newline, closefd); + newline, closefd ? Py_True : Py_False); Py_DECREF(io); if (stream == NULL) return NULL; diff -r 59a2807872d5 Objects/listobject.c --- a/Objects/listobject.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Objects/listobject.c Fri Sep 21 18:13:47 2012 +0300 @@ -1918,7 +1918,7 @@ assert(self != NULL); assert (PyList_Check(self)); if (args != NULL) { - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oi:sort", + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Op:sort", kwlist, &keyfunc, &reverse)) return NULL; if (Py_SIZE(args) > 0) { diff -r 59a2807872d5 Objects/longobject.c --- a/Objects/longobject.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Objects/longobject.c Fri Sep 21 18:13:47 2012 +0300 @@ -4623,16 +4623,15 @@ long_to_bytes(PyLongObject *v, PyObject *args, PyObject *kwds) { PyObject *byteorder_str; - PyObject *is_signed_obj = NULL; Py_ssize_t length; int little_endian; - int is_signed; + int is_signed = 0; PyObject *bytes; static char *kwlist[] = {"length", "byteorder", "signed", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "nU|O:to_bytes", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "nU|p:to_bytes", kwlist, &length, &byteorder_str, - &is_signed_obj)) + &is_signed)) return NULL; if (args != NULL && Py_SIZE(args) > 2) { @@ -4651,18 +4650,6 @@ return NULL; } - if (is_signed_obj != NULL) { - int cmp = PyObject_IsTrue(is_signed_obj); - if (cmp < 0) - return NULL; - is_signed = cmp ? 1 : 0; - } - else { - /* If the signed argument was omitted, use False as the - default. */ - is_signed = 0; - } - if (length < 0) { PyErr_SetString(PyExc_ValueError, "length argument must be non-negative"); @@ -4705,17 +4692,16 @@ long_from_bytes(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *byteorder_str; - PyObject *is_signed_obj = NULL; int little_endian; - int is_signed; + int is_signed = 0; PyObject *obj; PyObject *bytes; PyObject *long_obj; static char *kwlist[] = {"bytes", "byteorder", "signed", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "OU|O:from_bytes", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "OU|p:from_bytes", kwlist, &obj, &byteorder_str, - &is_signed_obj)) + &is_signed)) return NULL; if (args != NULL && Py_SIZE(args) > 2) { @@ -4734,18 +4720,6 @@ return NULL; } - if (is_signed_obj != NULL) { - int cmp = PyObject_IsTrue(is_signed_obj); - if (cmp < 0) - return NULL; - is_signed = cmp ? 1 : 0; - } - else { - /* If the signed argument was omitted, use False as the - default. */ - is_signed = 0; - } - bytes = PyObject_Bytes(obj); if (bytes == NULL) return NULL; diff -r 59a2807872d5 Objects/unicodeobject.c --- a/Objects/unicodeobject.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Objects/unicodeobject.c Fri Sep 21 18:13:47 2012 +0300 @@ -12470,7 +12470,7 @@ static char *kwlist[] = {"keepends", 0}; int keepends = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i:splitlines", + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|p:splitlines", kwlist, &keepends)) return NULL; diff -r 59a2807872d5 Python/bltinmodule.c --- a/Python/bltinmodule.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Python/bltinmodule.c Fri Sep 21 18:13:47 2012 +0300 @@ -585,7 +585,7 @@ int start[] = {Py_file_input, Py_eval_input, Py_single_input}; PyObject *result; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO&s|iii:compile", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO&s|ipi:compile", kwlist, &cmd, PyUnicode_FSConverter, &filename_obj, &startstr, &supplied_flags, @@ -1519,12 +1519,13 @@ { static char *kwlist[] = {"sep", "end", "file", "flush", 0}; static PyObject *dummy_args; - PyObject *sep = NULL, *end = NULL, *file = NULL, *flush = NULL; + PyObject *sep = NULL, *end = NULL, *file = NULL; + int flush = 0; int i, err; if (dummy_args == NULL && !(dummy_args = PyTuple_New(0))) return NULL; - if (!PyArg_ParseTupleAndKeywords(dummy_args, kwds, "|OOOO:print", + if (!PyArg_ParseTupleAndKeywords(dummy_args, kwds, "|OOOp:print", kwlist, &sep, &end, &file, &flush)) return NULL; if (file == NULL || file == Py_None) { @@ -1576,18 +1577,11 @@ if (err) return NULL; - if (flush != NULL) { - PyObject *tmp; - int do_flush = PyObject_IsTrue(flush); - if (do_flush == -1) + if (flush) { + PyObject *tmp = PyObject_CallMethod(file, "flush", ""); + if (tmp == NULL) return NULL; - else if (do_flush) { - tmp = PyObject_CallMethod(file, "flush", ""); - if (tmp == NULL) - return NULL; - else - Py_DECREF(tmp); - } + Py_DECREF(tmp); } Py_RETURN_NONE; @@ -1859,7 +1853,7 @@ _Py_IDENTIFIER(sort); /* args 1-3 should match listsort in Objects/listobject.c */ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|Oi:sorted", + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|Op:sorted", kwlist, &seq, &keyfunc, &reverse)) return NULL; diff -r 59a2807872d5 Python/pythonrun.c --- a/Python/pythonrun.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Python/pythonrun.c Fri Sep 21 18:13:47 2012 +0300 @@ -936,9 +936,9 @@ mode = "wb"; else mode = "rb"; - buf = _PyObject_CallMethodId(io, &PyId_open, "isiOOOi", + buf = _PyObject_CallMethodId(io, &PyId_open, "isiOOOO", fd, mode, buffering, - Py_None, Py_None, Py_None, 0); + Py_None, Py_None, Py_None, Py_False); if (buf == NULL) goto error; diff -r 59a2807872d5 Python/sysmodule.c --- a/Python/sysmodule.c Fri Sep 21 17:29:20 2012 +0300 +++ b/Python/sysmodule.c Fri Sep 21 18:13:47 2012 +0300 @@ -575,7 +575,7 @@ int bool; PyThreadState *tstate = PyThreadState_Get(); - if (!PyArg_ParseTuple(args, "i:settscdump", &bool)) + if (!PyArg_ParseTuple(args, "p:settscdump", &bool)) return NULL; if (bool) tstate->interp->tscdump = 1;