mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Ka-Ping Yee <ping@lfw.org>:
Changes to error messages to increase consistency & clarity. This (mostly) closes SourceForge patch #101839.
This commit is contained in:
parent
bd6f4fba1b
commit
661ea26b3d
16 changed files with 186 additions and 144 deletions
|
@ -9,9 +9,9 @@ test_extcall
|
||||||
(1, 2, 3) {'b': 5, 'a': 4}
|
(1, 2, 3) {'b': 5, 'a': 4}
|
||||||
(1, 2, 3, 4, 5) {'b': 7, 'a': 6}
|
(1, 2, 3, 4, 5) {'b': 7, 'a': 6}
|
||||||
(1, 2, 3, 6, 7) {'y': 5, 'b': 9, 'x': 4, 'a': 8}
|
(1, 2, 3, 6, 7) {'y': 5, 'b': 9, 'x': 4, 'a': 8}
|
||||||
TypeError: not enough arguments; expected 1, got 0
|
TypeError: not enough arguments to g(); expected 1, got 0
|
||||||
TypeError: not enough arguments; expected 1, got 0
|
TypeError: not enough arguments to g(); expected 1, got 0
|
||||||
TypeError: not enough arguments; expected 1, got 0
|
TypeError: not enough arguments to g(); expected 1, got 0
|
||||||
1 () {}
|
1 () {}
|
||||||
1 (2,) {}
|
1 (2,) {}
|
||||||
1 (2, 3) {}
|
1 (2, 3) {}
|
||||||
|
@ -20,10 +20,10 @@ TypeError: not enough arguments; expected 1, got 0
|
||||||
1 () {'d': 4, 'b': 2, 'c': 3, 'a': 1}
|
1 () {'d': 4, 'b': 2, 'c': 3, 'a': 1}
|
||||||
{'b': 2, 'c': 3, 'a': 1}
|
{'b': 2, 'c': 3, 'a': 1}
|
||||||
{'b': 2, 'c': 3, 'a': 1}
|
{'b': 2, 'c': 3, 'a': 1}
|
||||||
keyword parameter redefined: x
|
keyword parameter 'x' redefined in call to g()
|
||||||
keyword parameter redefined: b
|
keyword parameter 'b' redefined in function call
|
||||||
keywords must be strings
|
keywords must be strings
|
||||||
unexpected keyword argument: e
|
h() got an unexpected keyword argument 'e'
|
||||||
* argument must be a sequence
|
* argument must be a sequence
|
||||||
** argument must be a dictionary
|
** argument must be a dictionary
|
||||||
3 512 1
|
3 512 1
|
||||||
|
|
|
@ -140,7 +140,7 @@ dbm_ass_sub(dbmobject *dp, PyObject *v, PyObject *w)
|
||||||
if ( dbm_store(dp->di_dbm, krec, drec, DBM_REPLACE) < 0 ) {
|
if ( dbm_store(dp->di_dbm, krec, drec, DBM_REPLACE) < 0 ) {
|
||||||
dbm_clearerr(dp->di_dbm);
|
dbm_clearerr(dp->di_dbm);
|
||||||
PyErr_SetString(DbmError,
|
PyErr_SetString(DbmError,
|
||||||
"Cannot add item to database");
|
"cannot add item to database");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ dbm_setdefault(register dbmobject *dp, PyObject *args)
|
||||||
val.dsize = PyString_GET_SIZE(defvalue);
|
val.dsize = PyString_GET_SIZE(defvalue);
|
||||||
if (dbm_store(dp->di_dbm, key, val, DBM_INSERT) < 0) {
|
if (dbm_store(dp->di_dbm, key, val, DBM_INSERT) < 0) {
|
||||||
dbm_clearerr(dp->di_dbm);
|
dbm_clearerr(dp->di_dbm);
|
||||||
PyErr_SetString(DbmError, "Cannot add item to database");
|
PyErr_SetString(DbmError, "cannot add item to database");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return defvalue;
|
return defvalue;
|
||||||
|
@ -325,7 +325,7 @@ dbmopen(PyObject *self, PyObject *args)
|
||||||
iflags = O_RDWR|O_CREAT|O_TRUNC;
|
iflags = O_RDWR|O_CREAT|O_TRUNC;
|
||||||
else {
|
else {
|
||||||
PyErr_SetString(DbmError,
|
PyErr_SetString(DbmError,
|
||||||
"Flags should be one of 'r', 'w', 'c' or 'n'");
|
"arg 2 to open should be 'r', 'w', 'c', or 'n'");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return newdbmobject(name, iflags, mode);
|
return newdbmobject(name, iflags, mode);
|
||||||
|
|
|
@ -508,7 +508,7 @@ parser_do_parse(PyObject *args, PyObject *kw, char *argspec, int type)
|
||||||
if (n != 0)
|
if (n != 0)
|
||||||
res = parser_newastobject(n, type);
|
res = parser_newastobject(n, type);
|
||||||
else
|
else
|
||||||
err_string("Could not parse string.");
|
err_string("could not parse string");
|
||||||
}
|
}
|
||||||
return (res);
|
return (res);
|
||||||
}
|
}
|
||||||
|
@ -611,14 +611,14 @@ parser_tuple2ast(PyAST_Object *self, PyObject *args, PyObject *kw)
|
||||||
else {
|
else {
|
||||||
/* This is a fragment, at best. */
|
/* This is a fragment, at best. */
|
||||||
PyNode_Free(tree);
|
PyNode_Free(tree);
|
||||||
err_string("Parse tree does not use a valid start symbol.");
|
err_string("parse tree does not use a valid start symbol");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Make sure we throw an exception on all errors. We should never
|
/* Make sure we throw an exception on all errors. We should never
|
||||||
* get this, but we'd do well to be sure something is done.
|
* get this, but we'd do well to be sure something is done.
|
||||||
*/
|
*/
|
||||||
if ((ast == 0) && !PyErr_Occurred())
|
if ((ast == 0) && !PyErr_Occurred())
|
||||||
err_string("Unspecified ast error occurred.");
|
err_string("unspecified AST error occurred");
|
||||||
|
|
||||||
return (ast);
|
return (ast);
|
||||||
}
|
}
|
||||||
|
@ -670,7 +670,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
|
||||||
PyObject *temp;
|
PyObject *temp;
|
||||||
|
|
||||||
if ((len != 2) && (len != 3)) {
|
if ((len != 2) && (len != 3)) {
|
||||||
err_string("Terminal nodes must have 2 or 3 entries.");
|
err_string("terminal nodes must have 2 or 3 entries");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
temp = PySequence_GetItem(elem, 1);
|
temp = PySequence_GetItem(elem, 1);
|
||||||
|
@ -678,8 +678,8 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
|
||||||
return 0;
|
return 0;
|
||||||
if (!PyString_Check(temp)) {
|
if (!PyString_Check(temp)) {
|
||||||
PyErr_Format(parser_error,
|
PyErr_Format(parser_error,
|
||||||
"Second item in terminal node must be a string,"
|
"second item in terminal node must be a string,"
|
||||||
" found %s.",
|
" found %s",
|
||||||
((PyTypeObject*)PyObject_Type(temp))->tp_name);
|
((PyTypeObject*)PyObject_Type(temp))->tp_name);
|
||||||
Py_DECREF(temp);
|
Py_DECREF(temp);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -691,8 +691,8 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
|
||||||
*line_num = PyInt_AS_LONG(o);
|
*line_num = PyInt_AS_LONG(o);
|
||||||
else {
|
else {
|
||||||
PyErr_Format(parser_error,
|
PyErr_Format(parser_error,
|
||||||
"Third item in terminal node must be an"
|
"third item in terminal node must be an"
|
||||||
" integer, found %s.",
|
" integer, found %s",
|
||||||
((PyTypeObject*)PyObject_Type(temp))->tp_name);
|
((PyTypeObject*)PyObject_Type(temp))->tp_name);
|
||||||
Py_DECREF(o);
|
Py_DECREF(o);
|
||||||
Py_DECREF(temp);
|
Py_DECREF(temp);
|
||||||
|
@ -713,7 +713,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
|
||||||
* Throw an exception.
|
* Throw an exception.
|
||||||
*/
|
*/
|
||||||
PyErr_SetObject(parser_error,
|
PyErr_SetObject(parser_error,
|
||||||
Py_BuildValue("os", elem, "Unknown node type."));
|
Py_BuildValue("os", elem, "unknown node type."));
|
||||||
Py_XDECREF(elem);
|
Py_XDECREF(elem);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -1566,7 +1566,7 @@ validate_dotted_as_name(node *tree)
|
||||||
&& validate_name(CHILD(tree, 2), NULL));
|
&& validate_name(CHILD(tree, 2), NULL));
|
||||||
else {
|
else {
|
||||||
res = 0;
|
res = 0;
|
||||||
err_string("Illegal number of children for dotted_as_name.");
|
err_string("illegal number of children for dotted_as_name");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
@ -1655,7 +1655,7 @@ validate_exec_stmt(node *tree)
|
||||||
&& validate_expr(CHILD(tree, 1)));
|
&& validate_expr(CHILD(tree, 1)));
|
||||||
|
|
||||||
if (!res && !PyErr_Occurred())
|
if (!res && !PyErr_Occurred())
|
||||||
err_string("Illegal exec statement.");
|
err_string("illegal exec statement");
|
||||||
if (res && (nch > 2))
|
if (res && (nch > 2))
|
||||||
res = (validate_name(CHILD(tree, 2), "in")
|
res = (validate_name(CHILD(tree, 2), "in")
|
||||||
&& validate_test(CHILD(tree, 3)));
|
&& validate_test(CHILD(tree, 3)));
|
||||||
|
@ -1682,7 +1682,7 @@ validate_assert_stmt(node *tree)
|
||||||
&& validate_test(CHILD(tree, 1)));
|
&& validate_test(CHILD(tree, 1)));
|
||||||
|
|
||||||
if (!res && !PyErr_Occurred())
|
if (!res && !PyErr_Occurred())
|
||||||
err_string("Illegal assert statement.");
|
err_string("illegal assert statement");
|
||||||
if (res && (nch > 2))
|
if (res && (nch > 2))
|
||||||
res = (validate_comma(CHILD(tree, 2))
|
res = (validate_comma(CHILD(tree, 2))
|
||||||
&& validate_test(CHILD(tree, 3)));
|
&& validate_test(CHILD(tree, 3)));
|
||||||
|
@ -1778,7 +1778,7 @@ validate_try(node *tree)
|
||||||
res = ((strcmp(STR(CHILD(tree, pos)), "except") == 0)
|
res = ((strcmp(STR(CHILD(tree, pos)), "except") == 0)
|
||||||
|| (strcmp(STR(CHILD(tree, pos)), "else") == 0));
|
|| (strcmp(STR(CHILD(tree, pos)), "else") == 0));
|
||||||
if (!res)
|
if (!res)
|
||||||
err_string("Illegal trailing triple in try statement.");
|
err_string("illegal trailing triple in try statement");
|
||||||
}
|
}
|
||||||
else if (nch == (pos + 6)) {
|
else if (nch == (pos + 6)) {
|
||||||
res = (validate_name(CHILD(tree, pos), "except")
|
res = (validate_name(CHILD(tree, pos), "except")
|
||||||
|
@ -1912,11 +1912,11 @@ validate_comp_op(node *tree)
|
||||||
|| (strcmp(STR(tree), "is") == 0));
|
|| (strcmp(STR(tree), "is") == 0));
|
||||||
if (!res) {
|
if (!res) {
|
||||||
PyErr_Format(parser_error,
|
PyErr_Format(parser_error,
|
||||||
"Illegal operator: '%s'.", STR(tree));
|
"illegal operator '%s'", STR(tree));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
err_string("Illegal comparison operator type.");
|
err_string("illegal comparison operator type");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1928,7 +1928,7 @@ validate_comp_op(node *tree)
|
||||||
|| ((strcmp(STR(CHILD(tree, 0)), "not") == 0)
|
|| ((strcmp(STR(CHILD(tree, 0)), "not") == 0)
|
||||||
&& (strcmp(STR(CHILD(tree, 1)), "in") == 0))));
|
&& (strcmp(STR(CHILD(tree, 1)), "in") == 0))));
|
||||||
if (!res && !PyErr_Occurred())
|
if (!res && !PyErr_Occurred())
|
||||||
err_string("Unknown comparison operator.");
|
err_string("unknown comparison operator");
|
||||||
}
|
}
|
||||||
return (res);
|
return (res);
|
||||||
}
|
}
|
||||||
|
@ -2075,7 +2075,7 @@ validate_power(node *tree)
|
||||||
res = validate_trailer(CHILD(tree, pos++));
|
res = validate_trailer(CHILD(tree, pos++));
|
||||||
if (res && (pos < nch)) {
|
if (res && (pos < nch)) {
|
||||||
if (!is_even(nch - pos)) {
|
if (!is_even(nch - pos)) {
|
||||||
err_string("Illegal number of nodes for 'power'.");
|
err_string("illegal number of nodes for 'power'");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
for ( ; res && (pos < (nch - 1)); pos += 2)
|
for ( ; res && (pos < (nch - 1)); pos += 2)
|
||||||
|
@ -2532,7 +2532,7 @@ validate_node(node *tree)
|
||||||
if (res)
|
if (res)
|
||||||
next = CHILD(tree, 0);
|
next = CHILD(tree, 0);
|
||||||
else if (nch == 1)
|
else if (nch == 1)
|
||||||
err_string("Illegal flow_stmt type.");
|
err_string("illegal flow_stmt type");
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
* Compound statements.
|
* Compound statements.
|
||||||
|
@ -2654,7 +2654,7 @@ validate_node(node *tree)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* Hopefully never reached! */
|
/* Hopefully never reached! */
|
||||||
err_string("Unrecogniged node type.");
|
err_string("unrecognized node type");
|
||||||
res = 0;
|
res = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2670,7 +2670,7 @@ validate_expr_tree(node *tree)
|
||||||
int res = validate_eval_input(tree);
|
int res = validate_eval_input(tree);
|
||||||
|
|
||||||
if (!res && !PyErr_Occurred())
|
if (!res && !PyErr_Occurred())
|
||||||
err_string("Could not validate expression tuple.");
|
err_string("could not validate expression tuple");
|
||||||
|
|
||||||
return (res);
|
return (res);
|
||||||
}
|
}
|
||||||
|
@ -2698,7 +2698,7 @@ validate_file_input(node *tree)
|
||||||
* this, we have some debugging to do.
|
* this, we have some debugging to do.
|
||||||
*/
|
*/
|
||||||
if (!res && !PyErr_Occurred())
|
if (!res && !PyErr_Occurred())
|
||||||
err_string("VALIDATION FAILURE: report this to the maintainer!.");
|
err_string("VALIDATION FAILURE: report this to the maintainer!");
|
||||||
|
|
||||||
return (res);
|
return (res);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1226,7 +1226,7 @@ posix_utime(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
else if (!PyArg_Parse(arg, "(ll)", &atime, &mtime)) {
|
else if (!PyArg_Parse(arg, "(ll)", &atime, &mtime)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"Second argument must be a 2-tuple of numbers.");
|
"utime() arg 2 must be a tuple (atime, mtime)");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1294,12 +1294,12 @@ posix_execv(PyObject *self, PyObject *args)
|
||||||
getitem = PyTuple_GetItem;
|
getitem = PyTuple_GetItem;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyErr_SetString(PyExc_TypeError, "argv must be tuple or list");
|
PyErr_SetString(PyExc_TypeError, "execv() arg 2 must be a tuple or list");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
PyErr_SetString(PyExc_ValueError, "empty argument list");
|
PyErr_SetString(PyExc_ValueError, "execv() arg 2 must not be empty");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1310,7 +1310,7 @@ posix_execv(PyObject *self, PyObject *args)
|
||||||
if (!PyArg_Parse((*getitem)(argv, i), "s", &argvlist[i])) {
|
if (!PyArg_Parse((*getitem)(argv, i), "s", &argvlist[i])) {
|
||||||
PyMem_DEL(argvlist);
|
PyMem_DEL(argvlist);
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"all arguments must be strings");
|
"execv() arg 2 must contain only strings");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1364,17 +1364,17 @@ posix_execve(PyObject *self, PyObject *args)
|
||||||
getitem = PyTuple_GetItem;
|
getitem = PyTuple_GetItem;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyErr_SetString(PyExc_TypeError, "argv must be tuple or list");
|
PyErr_SetString(PyExc_TypeError, "execve() arg 2 must be a tuple or list");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!PyMapping_Check(env)) {
|
if (!PyMapping_Check(env)) {
|
||||||
PyErr_SetString(PyExc_TypeError, "env must be mapping object");
|
PyErr_SetString(PyExc_TypeError, "execve() arg 3 must be a mapping object");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"empty argument list");
|
"execve() arg 2 must not be empty");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1385,7 +1385,7 @@ posix_execve(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
if (!PyArg_Parse((*getitem)(argv, i),
|
if (!PyArg_Parse((*getitem)(argv, i),
|
||||||
"s;argv must be list of strings",
|
"s;execve() arg 2 must contain only strings",
|
||||||
&argvlist[i]))
|
&argvlist[i]))
|
||||||
{
|
{
|
||||||
goto fail_1;
|
goto fail_1;
|
||||||
|
@ -1413,8 +1413,8 @@ posix_execve(PyObject *self, PyObject *args)
|
||||||
if (!key || !val)
|
if (!key || !val)
|
||||||
goto fail_2;
|
goto fail_2;
|
||||||
|
|
||||||
if (!PyArg_Parse(key, "s;non-string key in env", &k) ||
|
if (!PyArg_Parse(key, "s;execve() arg 3 contains a non-string key", &k) ||
|
||||||
!PyArg_Parse(val, "s;non-string value in env", &v))
|
!PyArg_Parse(val, "s;execve() arg 3 contains a non-string value", &v))
|
||||||
{
|
{
|
||||||
goto fail_2;
|
goto fail_2;
|
||||||
}
|
}
|
||||||
|
@ -1493,7 +1493,7 @@ posix_spawnv(PyObject *self, PyObject *args)
|
||||||
getitem = PyTuple_GetItem;
|
getitem = PyTuple_GetItem;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyErr_SetString(PyExc_TypeError, "argv must be tuple or list");
|
PyErr_SetString(PyExc_TypeError, "spawmv() arg 2 must be a tuple or list");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1504,7 +1504,7 @@ posix_spawnv(PyObject *self, PyObject *args)
|
||||||
if (!PyArg_Parse((*getitem)(argv, i), "s", &argvlist[i])) {
|
if (!PyArg_Parse((*getitem)(argv, i), "s", &argvlist[i])) {
|
||||||
PyMem_DEL(argvlist);
|
PyMem_DEL(argvlist);
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"all arguments must be strings");
|
"spawnv() arg 2 must contain only strings");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1563,11 +1563,11 @@ posix_spawnve(PyObject *self, PyObject *args)
|
||||||
getitem = PyTuple_GetItem;
|
getitem = PyTuple_GetItem;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyErr_SetString(PyExc_TypeError, "argv must be tuple or list");
|
PyErr_SetString(PyExc_TypeError, "spawnve() arg 2 must be a tuple or list");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!PyMapping_Check(env)) {
|
if (!PyMapping_Check(env)) {
|
||||||
PyErr_SetString(PyExc_TypeError, "env must be mapping object");
|
PyErr_SetString(PyExc_TypeError, "spawnve() arg 3 must be a mapping object");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1578,7 +1578,7 @@ posix_spawnve(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
if (!PyArg_Parse((*getitem)(argv, i),
|
if (!PyArg_Parse((*getitem)(argv, i),
|
||||||
"s;argv must be list of strings",
|
"s;spawnve() arg 2 must contain only strings",
|
||||||
&argvlist[i]))
|
&argvlist[i]))
|
||||||
{
|
{
|
||||||
goto fail_1;
|
goto fail_1;
|
||||||
|
@ -1606,8 +1606,8 @@ posix_spawnve(PyObject *self, PyObject *args)
|
||||||
if (!key || !val)
|
if (!key || !val)
|
||||||
goto fail_2;
|
goto fail_2;
|
||||||
|
|
||||||
if (!PyArg_Parse(key, "s;non-string key in env", &k) ||
|
if (!PyArg_Parse(key, "s;spawnve() arg 3 contains a non-string key", &k) ||
|
||||||
!PyArg_Parse(val, "s;non-string value in env", &v))
|
!PyArg_Parse(val, "s;spawnve() arg 3 contains a non-string value", &v))
|
||||||
{
|
{
|
||||||
goto fail_2;
|
goto fail_2;
|
||||||
}
|
}
|
||||||
|
@ -2150,13 +2150,13 @@ posix_popen(PyObject *self, PyObject *args)
|
||||||
if (*mode == 'r')
|
if (*mode == 'r')
|
||||||
tm = _O_RDONLY;
|
tm = _O_RDONLY;
|
||||||
else if (*mode != 'w') {
|
else if (*mode != 'w') {
|
||||||
PyErr_SetString(PyExc_ValueError, "mode must be 'r' or 'w'");
|
PyErr_SetString(PyExc_ValueError, "popen() arg 2 must be 'r' or 'w'");
|
||||||
return NULL;
|
return NULL;
|
||||||
} else
|
} else
|
||||||
tm = _O_WRONLY;
|
tm = _O_WRONLY;
|
||||||
|
|
||||||
if (bufsize != -1) {
|
if (bufsize != -1) {
|
||||||
PyErr_SetString(PyExc_ValueError, "bufsize must be -1");
|
PyErr_SetString(PyExc_ValueError, "popen() arg 3 must be -1");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2191,13 +2191,13 @@ win32_popen2(PyObject *self, PyObject *args)
|
||||||
if (*mode == 't')
|
if (*mode == 't')
|
||||||
tm = _O_TEXT;
|
tm = _O_TEXT;
|
||||||
else if (*mode != 'b') {
|
else if (*mode != 'b') {
|
||||||
PyErr_SetString(PyExc_ValueError, "mode must be 't' or 'b'");
|
PyErr_SetString(PyExc_ValueError, "popen2() arg 2 must be 't' or 'b'");
|
||||||
return NULL;
|
return NULL;
|
||||||
} else
|
} else
|
||||||
tm = _O_BINARY;
|
tm = _O_BINARY;
|
||||||
|
|
||||||
if (bufsize != -1) {
|
if (bufsize != -1) {
|
||||||
PyErr_SetString(PyExc_ValueError, "bufsize must be -1");
|
PyErr_SetString(PyExc_ValueError, "popen2() arg 3 must be -1");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2228,13 +2228,13 @@ win32_popen3(PyObject *self, PyObject *args)
|
||||||
if (*mode == 't')
|
if (*mode == 't')
|
||||||
tm = _O_TEXT;
|
tm = _O_TEXT;
|
||||||
else if (*mode != 'b') {
|
else if (*mode != 'b') {
|
||||||
PyErr_SetString(PyExc_ValueError, "mode must be 't' or 'b'");
|
PyErr_SetString(PyExc_ValueError, "popen3() arg 2 must be 't' or 'b'");
|
||||||
return NULL;
|
return NULL;
|
||||||
} else
|
} else
|
||||||
tm = _O_BINARY;
|
tm = _O_BINARY;
|
||||||
|
|
||||||
if (bufsize != -1) {
|
if (bufsize != -1) {
|
||||||
PyErr_SetString(PyExc_ValueError, "bufsize must be -1");
|
PyErr_SetString(PyExc_ValueError, "popen3() arg 3 must be -1");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2265,13 +2265,13 @@ win32_popen4(PyObject *self, PyObject *args)
|
||||||
if (*mode == 't')
|
if (*mode == 't')
|
||||||
tm = _O_TEXT;
|
tm = _O_TEXT;
|
||||||
else if (*mode != 'b') {
|
else if (*mode != 'b') {
|
||||||
PyErr_SetString(PyExc_ValueError, "mode must be 't' or 'b'");
|
PyErr_SetString(PyExc_ValueError, "popen4() arg 2 must be 't' or 'b'");
|
||||||
return NULL;
|
return NULL;
|
||||||
} else
|
} else
|
||||||
tm = _O_BINARY;
|
tm = _O_BINARY;
|
||||||
|
|
||||||
if (bufsize != -1) {
|
if (bufsize != -1) {
|
||||||
PyErr_SetString(PyExc_ValueError, "bufsize must be -1");
|
PyErr_SetString(PyExc_ValueError, "popen4() arg 3 must be -1");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2727,13 +2727,13 @@ static int _PyPclose(FILE *file)
|
||||||
* an exception. Just die.
|
* an exception. Just die.
|
||||||
*/
|
*/
|
||||||
Py_FatalError("unable to allocate interpreter state "
|
Py_FatalError("unable to allocate interpreter state "
|
||||||
"when closing popen object.");
|
"when closing popen object");
|
||||||
return -1; /* unreachable */
|
return -1; /* unreachable */
|
||||||
}
|
}
|
||||||
pThreadState = PyThreadState_New(pInterpreterState);
|
pThreadState = PyThreadState_New(pInterpreterState);
|
||||||
if (!pThreadState) {
|
if (!pThreadState) {
|
||||||
Py_FatalError("unable to allocate thread state "
|
Py_FatalError("unable to allocate thread state "
|
||||||
"when closing popen object.");
|
"when closing popen object");
|
||||||
return -1; /* unreachable */
|
return -1; /* unreachable */
|
||||||
}
|
}
|
||||||
/* Grab the global lock. Note that this will deadlock if the
|
/* Grab the global lock. Note that this will deadlock if the
|
||||||
|
@ -3761,7 +3761,7 @@ posix_strerror(PyObject *self, PyObject *args)
|
||||||
message = strerror(code);
|
message = strerror(code);
|
||||||
if (message == NULL) {
|
if (message == NULL) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"strerror code out of range");
|
"strerror() argument out of range");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return PyString_FromString(message);
|
return PyString_FromString(message);
|
||||||
|
|
|
@ -173,7 +173,9 @@ class_getattr(register PyClassObject *op, PyObject *name)
|
||||||
}
|
}
|
||||||
v = class_lookup(op, name, &class);
|
v = class_lookup(op, name, &class);
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
PyErr_SetObject(PyExc_AttributeError, name);
|
PyErr_Format(PyExc_AttributeError,
|
||||||
|
"class %.50s has no attribute '%.400s'",
|
||||||
|
PyString_AS_STRING(op->cl_name), sname);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Py_INCREF(v);
|
Py_INCREF(v);
|
||||||
|
@ -285,8 +287,9 @@ class_setattr(PyClassObject *op, PyObject *name, PyObject *v)
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
int rv = PyDict_DelItem(op->cl_dict, name);
|
int rv = PyDict_DelItem(op->cl_dict, name);
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
PyErr_SetString(PyExc_AttributeError,
|
PyErr_Format(PyExc_AttributeError,
|
||||||
"delete non-existing class attribute");
|
"class %.50s has no attribute '%.400s'",
|
||||||
|
PyString_AS_STRING(op->cl_name), sname);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -578,7 +581,8 @@ instance_getattr1(register PyInstanceObject *inst, PyObject *name)
|
||||||
}
|
}
|
||||||
v = instance_getattr2(inst, name);
|
v = instance_getattr2(inst, name);
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
PyErr_Format(PyExc_AttributeError,"'%.50s' instance has no attribute '%.400s'",
|
PyErr_Format(PyExc_AttributeError,
|
||||||
|
"%.50s instance has no attribute '%.400s'",
|
||||||
PyString_AS_STRING(inst->in_class->cl_name), sname);
|
PyString_AS_STRING(inst->in_class->cl_name), sname);
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
|
@ -642,8 +646,10 @@ instance_setattr1(PyInstanceObject *inst, PyObject *name, PyObject *v)
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
int rv = PyDict_DelItem(inst->in_dict, name);
|
int rv = PyDict_DelItem(inst->in_dict, name);
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
PyErr_SetString(PyExc_AttributeError,
|
PyErr_Format(PyExc_AttributeError,
|
||||||
"delete non-existing instance attribute");
|
"%.50s instance has no attribute '%.400s'",
|
||||||
|
PyString_AS_STRING(inst->in_class->cl_name),
|
||||||
|
PyString_AS_STRING(name));
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -833,7 +833,7 @@ file_readlines(PyFileObject *f, PyObject *args)
|
||||||
buffersize *= 2;
|
buffersize *= 2;
|
||||||
if (buffersize > INT_MAX) {
|
if (buffersize > INT_MAX) {
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"line is too long for a Python string");
|
"line is longer than a Python string can hold");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (big_buffer == NULL) {
|
if (big_buffer == NULL) {
|
||||||
|
@ -938,7 +938,7 @@ file_writelines(PyFileObject *f, PyObject *args)
|
||||||
return err_closed();
|
return err_closed();
|
||||||
if (args == NULL || !PySequence_Check(args)) {
|
if (args == NULL || !PySequence_Check(args)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"writelines() requires sequence of strings");
|
"writelines() argument must be a sequence of strings");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
islist = PyList_Check(args);
|
islist = PyList_Check(args);
|
||||||
|
@ -1001,7 +1001,7 @@ file_writelines(PyFileObject *f, PyObject *args)
|
||||||
&buffer,
|
&buffer,
|
||||||
&len))) {
|
&len))) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"writelines() requires sequences of strings");
|
"writelines() argument must be a sequence of strings");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
line = PyString_FromStringAndSize(buffer,
|
line = PyString_FromStringAndSize(buffer,
|
||||||
|
|
|
@ -466,7 +466,7 @@ float_pow(PyFloatObject *v, PyObject *w, PyFloatObject *z)
|
||||||
if (iv == 0.0) {
|
if (iv == 0.0) {
|
||||||
if (iw < 0.0) {
|
if (iw < 0.0) {
|
||||||
PyErr_SetString(PyExc_ZeroDivisionError,
|
PyErr_SetString(PyExc_ZeroDivisionError,
|
||||||
"0.0 to a negative power");
|
"0.0 cannot be raised to a negative power");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return PyFloat_FromDouble(0.0);
|
return PyFloat_FromDouble(0.0);
|
||||||
|
@ -486,7 +486,7 @@ float_pow(PyFloatObject *v, PyObject *w, PyFloatObject *z)
|
||||||
/* Sort out special cases here instead of relying on pow() */
|
/* Sort out special cases here instead of relying on pow() */
|
||||||
if (iv < 0.0) {
|
if (iv < 0.0) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"negative number to a float power");
|
"negative number cannot be raised to a fractional power");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
|
@ -171,7 +171,7 @@ PyInt_FromString(char *s, char **pend, int base)
|
||||||
char buffer[256]; /* For errors */
|
char buffer[256]; /* For errors */
|
||||||
|
|
||||||
if ((base != 0 && base < 2) || base > 36) {
|
if ((base != 0 && base < 2) || base > 36) {
|
||||||
PyErr_SetString(PyExc_ValueError, "invalid base for int()");
|
PyErr_SetString(PyExc_ValueError, "int() base must be >= 2 and <= 36");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,7 +417,7 @@ i_divmod(register PyIntObject *x, register PyIntObject *y,
|
||||||
|
|
||||||
if (yi == 0) {
|
if (yi == 0) {
|
||||||
PyErr_SetString(PyExc_ZeroDivisionError,
|
PyErr_SetString(PyExc_ZeroDivisionError,
|
||||||
"integer division or modulo");
|
"integer division or modulo by zero");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (yi < 0) {
|
if (yi < 0) {
|
||||||
|
@ -485,17 +485,17 @@ int_pow(PyIntObject *v, PyIntObject *w, PyIntObject *z)
|
||||||
if (iw < 0) {
|
if (iw < 0) {
|
||||||
if (iv)
|
if (iv)
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"integer to a negative power");
|
"cannot raise integer to a negative power");
|
||||||
else
|
else
|
||||||
PyErr_SetString(PyExc_ZeroDivisionError,
|
PyErr_SetString(PyExc_ZeroDivisionError,
|
||||||
"0 to a negative power");
|
"cannot raise 0 to a negative power");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if ((PyObject *)z != Py_None) {
|
if ((PyObject *)z != Py_None) {
|
||||||
iz = z->ob_ival;
|
iz = z->ob_ival;
|
||||||
if (iz == 0) {
|
if (iz == 0) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"pow(x, y, z) with z==0");
|
"pow() arg 3 cannot be 0");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ PyLong_AsLong(PyObject *vv)
|
||||||
|
|
||||||
overflow:
|
overflow:
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"long int too long to convert");
|
"long int too large to convert");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ PyLong_AsUnsignedLong(PyObject *vv)
|
||||||
x = (x << SHIFT) + v->ob_digit[i];
|
x = (x << SHIFT) + v->ob_digit[i];
|
||||||
if ((x >> SHIFT) != prev) {
|
if ((x >> SHIFT) != prev) {
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"long int too long to convert");
|
"long int too large to convert");
|
||||||
return (unsigned long) -1;
|
return (unsigned long) -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -653,7 +653,7 @@ PyLong_FromString(char *str, char **pend, int base)
|
||||||
|
|
||||||
if ((base != 0 && base < 2) || base > 36) {
|
if ((base != 0 && base < 2) || base > 36) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"invalid base for long literal");
|
"long() arg 2 must be >= 2 and <= 36");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
while (*str != '\0' && isspace(Py_CHARMASK(*str)))
|
while (*str != '\0' && isspace(Py_CHARMASK(*str)))
|
||||||
|
@ -751,7 +751,7 @@ long_divrem(PyLongObject *a, PyLongObject *b,
|
||||||
|
|
||||||
if (size_b == 0) {
|
if (size_b == 0) {
|
||||||
PyErr_SetString(PyExc_ZeroDivisionError,
|
PyErr_SetString(PyExc_ZeroDivisionError,
|
||||||
"long division or modulo");
|
"long division or modulo by zero");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (size_a < size_b ||
|
if (size_a < size_b ||
|
||||||
|
|
|
@ -163,13 +163,22 @@ static PyObject *
|
||||||
module_getattr(PyModuleObject *m, char *name)
|
module_getattr(PyModuleObject *m, char *name)
|
||||||
{
|
{
|
||||||
PyObject *res;
|
PyObject *res;
|
||||||
|
char* modname;
|
||||||
if (strcmp(name, "__dict__") == 0) {
|
if (strcmp(name, "__dict__") == 0) {
|
||||||
Py_INCREF(m->md_dict);
|
Py_INCREF(m->md_dict);
|
||||||
return m->md_dict;
|
return m->md_dict;
|
||||||
}
|
}
|
||||||
res = PyDict_GetItemString(m->md_dict, name);
|
res = PyDict_GetItemString(m->md_dict, name);
|
||||||
if (res == NULL)
|
if (res == NULL) {
|
||||||
PyErr_SetString(PyExc_AttributeError, name);
|
modname = PyModule_GetName((PyObject *)m);
|
||||||
|
if (modname == NULL) {
|
||||||
|
PyErr_Clear();
|
||||||
|
modname = "?";
|
||||||
|
}
|
||||||
|
PyErr_Format(PyExc_AttributeError,
|
||||||
|
"'%.50s' module has no attribute '%.400s'",
|
||||||
|
modname, name);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Py_INCREF(res);
|
Py_INCREF(res);
|
||||||
return res;
|
return res;
|
||||||
|
@ -178,6 +187,7 @@ module_getattr(PyModuleObject *m, char *name)
|
||||||
static int
|
static int
|
||||||
module_setattr(PyModuleObject *m, char *name, PyObject *v)
|
module_setattr(PyModuleObject *m, char *name, PyObject *v)
|
||||||
{
|
{
|
||||||
|
char* modname;
|
||||||
if (name[0] == '_' && strcmp(name, "__dict__") == 0) {
|
if (name[0] == '_' && strcmp(name, "__dict__") == 0) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"read-only special attribute");
|
"read-only special attribute");
|
||||||
|
@ -185,9 +195,16 @@ module_setattr(PyModuleObject *m, char *name, PyObject *v)
|
||||||
}
|
}
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
int rv = PyDict_DelItemString(m->md_dict, name);
|
int rv = PyDict_DelItemString(m->md_dict, name);
|
||||||
if (rv < 0)
|
if (rv < 0) {
|
||||||
PyErr_SetString(PyExc_AttributeError,
|
modname = PyModule_GetName((PyObject *)m);
|
||||||
"delete non-existing module attribute");
|
if (modname == NULL) {
|
||||||
|
PyErr_Clear();
|
||||||
|
modname = "?";
|
||||||
|
}
|
||||||
|
PyErr_Format(PyExc_AttributeError,
|
||||||
|
"'%.50s' module has no attribute '%.400s'",
|
||||||
|
modname, name);
|
||||||
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -175,7 +175,7 @@ PyObject_Print(PyObject *op, FILE *fp, int flags)
|
||||||
return -1;
|
return -1;
|
||||||
#ifdef USE_STACKCHECK
|
#ifdef USE_STACKCHECK
|
||||||
if (PyOS_CheckStack()) {
|
if (PyOS_CheckStack()) {
|
||||||
PyErr_SetString(PyExc_MemoryError, "Stack overflow");
|
PyErr_SetString(PyExc_MemoryError, "stack overflow");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -227,7 +227,7 @@ PyObject_Repr(PyObject *v)
|
||||||
return NULL;
|
return NULL;
|
||||||
#ifdef USE_STACKCHECK
|
#ifdef USE_STACKCHECK
|
||||||
if (PyOS_CheckStack()) {
|
if (PyOS_CheckStack()) {
|
||||||
PyErr_SetString(PyExc_MemoryError, "Stack overflow");
|
PyErr_SetString(PyExc_MemoryError, "stack overflow");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2460,7 +2460,7 @@ formatfloat(char *buf, size_t buflen, int flags,
|
||||||
always given), therefore increase by one to 10+prec. */
|
always given), therefore increase by one to 10+prec. */
|
||||||
if (buflen <= (size_t)10 + (size_t)prec) {
|
if (buflen <= (size_t)10 + (size_t)prec) {
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"formatted float is too long (precision too long?)");
|
"formatted float is too long (precision too large?)");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sprintf(buf, fmt, x);
|
sprintf(buf, fmt, x);
|
||||||
|
@ -2626,7 +2626,7 @@ formatint(char *buf, size_t buflen, int flags,
|
||||||
worst case buf = '0x' + [0-9]*prec, where prec >= 11 */
|
worst case buf = '0x' + [0-9]*prec, where prec >= 11 */
|
||||||
if (buflen <= 13 || buflen <= (size_t)2 + (size_t)prec) {
|
if (buflen <= 13 || buflen <= (size_t)2 + (size_t)prec) {
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"formatted integer is too long (precision too long?)");
|
"formatted integer is too long (precision too large?)");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sprintf(buf, fmt, x);
|
sprintf(buf, fmt, x);
|
||||||
|
|
|
@ -71,7 +71,7 @@ builtin_apply(PyObject *self, PyObject *args)
|
||||||
if (!PyTuple_Check(alist)) {
|
if (!PyTuple_Check(alist)) {
|
||||||
if (!PySequence_Check(alist)) {
|
if (!PySequence_Check(alist)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"apply() 2nd argument must be a sequence");
|
"apply() arg 2 must be a sequence");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
t = PySequence_Tuple(alist);
|
t = PySequence_Tuple(alist);
|
||||||
|
@ -82,7 +82,7 @@ builtin_apply(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
if (kwdict != NULL && !PyDict_Check(kwdict)) {
|
if (kwdict != NULL && !PyDict_Check(kwdict)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"apply() 3rd argument must be dictionary");
|
"apply() arg 3 must be a dictionary");
|
||||||
goto finally;
|
goto finally;
|
||||||
}
|
}
|
||||||
retval = PyEval_CallObjectWithKeywords(func, alist, kwdict);
|
retval = PyEval_CallObjectWithKeywords(func, alist, kwdict);
|
||||||
|
@ -181,7 +181,7 @@ builtin_filter(PyObject *self, PyObject *args)
|
||||||
sqf = seq->ob_type->tp_as_sequence;
|
sqf = seq->ob_type->tp_as_sequence;
|
||||||
if (sqf == NULL || sqf->sq_length == NULL || sqf->sq_item == NULL) {
|
if (sqf == NULL || sqf->sq_length == NULL || sqf->sq_item == NULL) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"argument 2 to filter() must be a sequence type");
|
"filter() arg 2 must be a sequence");
|
||||||
goto Fail_2;
|
goto Fail_2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@ builtin_compile(PyObject *self, PyObject *args)
|
||||||
start = Py_single_input;
|
start = Py_single_input;
|
||||||
else {
|
else {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"compile() mode must be 'exec' or 'eval' or 'single'");
|
"compile() arg 3 must be 'exec' or 'eval' or 'single'");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return Py_CompileString(str, filename, start);
|
return Py_CompileString(str, filename, start);
|
||||||
|
@ -421,7 +421,7 @@ complex_from_string(PyObject *v)
|
||||||
}
|
}
|
||||||
else if (PyObject_AsCharBuffer(v, &s, &len)) {
|
else if (PyObject_AsCharBuffer(v, &s, &len)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"complex() needs a string first argument");
|
"complex() arg is not a string");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +431,7 @@ complex_from_string(PyObject *v)
|
||||||
s++;
|
s++;
|
||||||
if (s[0] == '\0') {
|
if (s[0] == '\0') {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"empty string for complex()");
|
"complex() arg is an empty string");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +445,7 @@ complex_from_string(PyObject *v)
|
||||||
if (s-start != len) {
|
if (s-start != len) {
|
||||||
PyErr_SetString(
|
PyErr_SetString(
|
||||||
PyExc_ValueError,
|
PyExc_ValueError,
|
||||||
"null byte in argument for complex()");
|
"complex() arg contains a null byte");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if(!done) sw_error=1;
|
if(!done) sw_error=1;
|
||||||
|
@ -531,7 +531,7 @@ complex_from_string(PyObject *v)
|
||||||
|
|
||||||
if (sw_error) {
|
if (sw_error) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"malformed string for complex()");
|
"complex() arg is a malformed string");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,7 +557,7 @@ builtin_complex(PyObject *self, PyObject *args)
|
||||||
((nbi = i->ob_type->tp_as_number) == NULL ||
|
((nbi = i->ob_type->tp_as_number) == NULL ||
|
||||||
nbi->nb_float == NULL))) {
|
nbi->nb_float == NULL))) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"complex() argument can't be converted to complex");
|
"complex() arg can't be converted to complex");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* XXX Hack to support classes with __complex__ method */
|
/* XXX Hack to support classes with __complex__ method */
|
||||||
|
@ -748,7 +748,7 @@ builtin_eval(PyObject *self, PyObject *args)
|
||||||
if (!PyString_Check(cmd) &&
|
if (!PyString_Check(cmd) &&
|
||||||
!PyUnicode_Check(cmd)) {
|
!PyUnicode_Check(cmd)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"eval() argument 1 must be string or code object");
|
"eval() arg 1 must be a string or code object");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (PyString_AsStringAndSize(cmd, &str, NULL))
|
if (PyString_AsStringAndSize(cmd, &str, NULL))
|
||||||
|
@ -1224,7 +1224,7 @@ builtin_int(PyObject *self, PyObject *args)
|
||||||
base);
|
base);
|
||||||
else {
|
else {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"can't convert non-string with explicit base");
|
"int() can't convert non-string with explicit base");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1257,7 +1257,7 @@ builtin_long(PyObject *self, PyObject *args)
|
||||||
base);
|
base);
|
||||||
else {
|
else {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"can't convert non-string with explicit base");
|
"long() can't convert non-string with explicit base");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1384,7 +1384,7 @@ min_max(PyObject *args, int sign)
|
||||||
sq = v->ob_type->tp_as_sequence;
|
sq = v->ob_type->tp_as_sequence;
|
||||||
if (sq == NULL || sq->sq_item == NULL) {
|
if (sq == NULL || sq->sq_item == NULL) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"min() or max() of non-sequence");
|
"min() or max() arg must be a sequence");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
w = NULL;
|
w = NULL;
|
||||||
|
@ -1417,7 +1417,7 @@ min_max(PyObject *args, int sign)
|
||||||
}
|
}
|
||||||
if (w == NULL)
|
if (w == NULL)
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"min() or max() of empty sequence");
|
"min() or max() arg is an empty sequence");
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1520,7 +1520,7 @@ builtin_ord(PyObject *self, PyObject *args)
|
||||||
ord = (long)*PyUnicode_AS_UNICODE(obj);
|
ord = (long)*PyUnicode_AS_UNICODE(obj);
|
||||||
} else {
|
} else {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"expected string or Unicode character, " \
|
"ord() expected string or Unicode character, " \
|
||||||
"%.200s found", obj->ob_type->tp_name);
|
"%.200s found", obj->ob_type->tp_name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1528,7 +1528,7 @@ builtin_ord(PyObject *self, PyObject *args)
|
||||||
return PyInt_FromLong(ord);
|
return PyInt_FromLong(ord);
|
||||||
|
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"expected a character, length-%d string found",
|
"ord() expected a character, length-%d string found",
|
||||||
size);
|
size);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1607,7 +1607,7 @@ builtin_range(PyObject *self, PyObject *args)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (istep == 0) {
|
if (istep == 0) {
|
||||||
PyErr_SetString(PyExc_ValueError, "zero step for range()");
|
PyErr_SetString(PyExc_ValueError, "range() arg 3 must not be zero");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (istep > 0)
|
if (istep > 0)
|
||||||
|
@ -1617,7 +1617,7 @@ builtin_range(PyObject *self, PyObject *args)
|
||||||
n = (int)bign;
|
n = (int)bign;
|
||||||
if (bign < 0 || (long)n != bign) {
|
if (bign < 0 || (long)n != bign) {
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"range() has too many items");
|
"range() result has too many items");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
v = PyList_New(n);
|
v = PyList_New(n);
|
||||||
|
@ -1664,7 +1664,7 @@ builtin_xrange(PyObject *self, PyObject *args)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (istep == 0) {
|
if (istep == 0) {
|
||||||
PyErr_SetString(PyExc_ValueError, "zero step for xrange()");
|
PyErr_SetString(PyExc_ValueError, "xrange() arg 3 must not be zero");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (istep > 0)
|
if (istep > 0)
|
||||||
|
@ -1673,7 +1673,7 @@ builtin_xrange(PyObject *self, PyObject *args)
|
||||||
n = get_len_of_range(ihigh, ilow, -istep);
|
n = get_len_of_range(ihigh, ilow, -istep);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"xrange() has more than sys.maxint items");
|
"xrange() result has too many items");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return PyRange_New(ilow, n, istep, 1);
|
return PyRange_New(ilow, n, istep, 1);
|
||||||
|
@ -1779,7 +1779,7 @@ builtin_reduce(PyObject *self, PyObject *args)
|
||||||
sqf = seq->ob_type->tp_as_sequence;
|
sqf = seq->ob_type->tp_as_sequence;
|
||||||
if (sqf == NULL || sqf->sq_item == NULL) {
|
if (sqf == NULL || sqf->sq_item == NULL) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"2nd argument to reduce() must be a sequence object");
|
"reduce() arg 2 must be a sequence");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1817,7 +1817,7 @@ builtin_reduce(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"reduce of empty sequence with no initial value");
|
"reduce() of empty sequence with no initial value");
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
@ -2073,7 +2073,7 @@ builtin_isinstance(PyObject *self, PyObject *args)
|
||||||
if (icls != NULL) {
|
if (icls != NULL) {
|
||||||
retval = abstract_issubclass(
|
retval = abstract_issubclass(
|
||||||
icls, cls,
|
icls, cls,
|
||||||
"second argument must be a class",
|
"isinstance() arg 2 must be a class",
|
||||||
1);
|
1);
|
||||||
Py_DECREF(icls);
|
Py_DECREF(icls);
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
|
@ -2081,13 +2081,13 @@ builtin_isinstance(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"second argument must be a class");
|
"isinstance() arg 2 must be a class");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"second argument must be a class");
|
"isinstance() arg 2 must be a class");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return PyInt_FromLong(retval);
|
return PyInt_FromLong(retval);
|
||||||
|
@ -2140,7 +2140,7 @@ builtin_zip(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
if (itemsize < 1) {
|
if (itemsize < 1) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"at least one sequence is required");
|
"zip() requires at least one sequence");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* args must be a tuple */
|
/* args must be a tuple */
|
||||||
|
|
|
@ -61,9 +61,9 @@ static void reset_exc_info(PyThreadState *);
|
||||||
static void format_exc_check_arg(PyObject *, char *, PyObject *);
|
static void format_exc_check_arg(PyObject *, char *, PyObject *);
|
||||||
|
|
||||||
#define NAME_ERROR_MSG \
|
#define NAME_ERROR_MSG \
|
||||||
"There is no variable named '%s'"
|
"name '%.200s' is not defined"
|
||||||
#define UNBOUNDLOCAL_ERROR_MSG \
|
#define UNBOUNDLOCAL_ERROR_MSG \
|
||||||
"Local variable '%.200s' referenced before assignment"
|
"local variable '%.200s' referenced before assignment"
|
||||||
|
|
||||||
/* Dynamic execution profile */
|
/* Dynamic execution profile */
|
||||||
#ifdef DYNAMIC_EXECUTION_PROFILE
|
#ifdef DYNAMIC_EXECUTION_PROFILE
|
||||||
|
@ -439,7 +439,9 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
|
||||||
if (argcount > co->co_argcount) {
|
if (argcount > co->co_argcount) {
|
||||||
if (!(co->co_flags & CO_VARARGS)) {
|
if (!(co->co_flags & CO_VARARGS)) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"too many arguments; expected %d, got %d",
|
"too many arguments to %s(); "
|
||||||
|
"expected %d, got %d",
|
||||||
|
PyString_AsString(co->co_name),
|
||||||
co->co_argcount, argcount);
|
co->co_argcount, argcount);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
@ -483,7 +485,9 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
|
||||||
if (j >= co->co_argcount) {
|
if (j >= co->co_argcount) {
|
||||||
if (kwdict == NULL) {
|
if (kwdict == NULL) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"unexpected keyword argument: %.400s",
|
"%.200s() got an unexpected "
|
||||||
|
"keyword argument '%.400s'",
|
||||||
|
PyString_AsString(co->co_name),
|
||||||
PyString_AsString(keyword));
|
PyString_AsString(keyword));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
@ -492,8 +496,10 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
|
||||||
else {
|
else {
|
||||||
if (GETLOCAL(j) != NULL) {
|
if (GETLOCAL(j) != NULL) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"keyword parameter redefined: %.400s",
|
"keyword parameter '%.400s' "
|
||||||
PyString_AsString(keyword));
|
"redefined in call to %.200s()",
|
||||||
|
PyString_AsString(keyword),
|
||||||
|
PyString_AsString(co->co_name));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
Py_INCREF(value);
|
Py_INCREF(value);
|
||||||
|
@ -505,7 +511,9 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
|
||||||
for (i = argcount; i < m; i++) {
|
for (i = argcount; i < m; i++) {
|
||||||
if (GETLOCAL(i) == NULL) {
|
if (GETLOCAL(i) == NULL) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"not enough arguments; expected %d, got %d",
|
"not enough arguments to "
|
||||||
|
"%.200s(); expected %d, got %d",
|
||||||
|
PyString_AsString(co->co_name),
|
||||||
m, i);
|
m, i);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
@ -525,8 +533,9 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (argcount > 0 || kwcount > 0) {
|
if (argcount > 0 || kwcount > 0) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"no arguments expected");
|
"%.200s() expected no arguments",
|
||||||
|
PyString_AsString(co->co_name));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -565,7 +574,7 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
|
||||||
if (++tstate->recursion_depth > recursion_limit) {
|
if (++tstate->recursion_depth > recursion_limit) {
|
||||||
--tstate->recursion_depth;
|
--tstate->recursion_depth;
|
||||||
PyErr_SetString(PyExc_RuntimeError,
|
PyErr_SetString(PyExc_RuntimeError,
|
||||||
"Maximum recursion depth exceeded");
|
"maximum recursion depth exceeded");
|
||||||
tstate->frame = f->f_back;
|
tstate->frame = f->f_back;
|
||||||
Py_DECREF(f);
|
Py_DECREF(f);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1825,7 +1834,7 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
|
||||||
/* Handy-dandy */ ;
|
/* Handy-dandy */ ;
|
||||||
else {
|
else {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"unbound method must be called with class instance 1st argument");
|
"unbound method must be called with instance as first argument");
|
||||||
x = NULL;
|
x = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1909,7 +1918,8 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
|
||||||
if (PyDict_GetItem(kwdict, key) != NULL) {
|
if (PyDict_GetItem(kwdict, key) != NULL) {
|
||||||
err = 1;
|
err = 1;
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"keyword parameter redefined: %.400s",
|
"keyword parameter '%.400s' "
|
||||||
|
"redefined in function call",
|
||||||
PyString_AsString(key));
|
PyString_AsString(key));
|
||||||
Py_DECREF(key);
|
Py_DECREF(key);
|
||||||
Py_DECREF(value);
|
Py_DECREF(value);
|
||||||
|
@ -2308,7 +2318,7 @@ do_raise(PyObject *type, PyObject *value, PyObject *tb)
|
||||||
}
|
}
|
||||||
else if (tb != NULL && !PyTraceBack_Check(tb)) {
|
else if (tb != NULL && !PyTraceBack_Check(tb)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"raise 3rd arg must be traceback or None");
|
"raise: arg 3 must be a traceback or None");
|
||||||
goto raise_error;
|
goto raise_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2630,6 +2640,7 @@ static PyObject *
|
||||||
call_builtin(PyObject *func, PyObject *arg, PyObject *kw)
|
call_builtin(PyObject *func, PyObject *arg, PyObject *kw)
|
||||||
{
|
{
|
||||||
if (PyCFunction_Check(func)) {
|
if (PyCFunction_Check(func)) {
|
||||||
|
PyCFunctionObject* f = (PyCFunctionObject*) func;
|
||||||
PyCFunction meth = PyCFunction_GetFunction(func);
|
PyCFunction meth = PyCFunction_GetFunction(func);
|
||||||
PyObject *self = PyCFunction_GetSelf(func);
|
PyObject *self = PyCFunction_GetSelf(func);
|
||||||
int flags = PyCFunction_GetFlags(func);
|
int flags = PyCFunction_GetFlags(func);
|
||||||
|
@ -2643,8 +2654,9 @@ call_builtin(PyObject *func, PyObject *arg, PyObject *kw)
|
||||||
if (flags & METH_KEYWORDS)
|
if (flags & METH_KEYWORDS)
|
||||||
return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
|
return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
|
||||||
if (kw != NULL && PyDict_Size(kw) != 0) {
|
if (kw != NULL && PyDict_Size(kw) != 0) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"this function takes no keyword arguments");
|
"%.200s() takes no keyword arguments",
|
||||||
|
f->m_ml->ml_name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return (*meth)(self, arg);
|
return (*meth)(self, arg);
|
||||||
|
@ -2653,11 +2665,13 @@ call_builtin(PyObject *func, PyObject *arg, PyObject *kw)
|
||||||
return PyInstance_New(func, arg, kw);
|
return PyInstance_New(func, arg, kw);
|
||||||
}
|
}
|
||||||
if (PyInstance_Check(func)) {
|
if (PyInstance_Check(func)) {
|
||||||
PyObject *res, *call = PyObject_GetAttrString(func,"__call__");
|
PyObject *res, *call = PyObject_GetAttrString(func, "__call__");
|
||||||
if (call == NULL) {
|
if (call == NULL) {
|
||||||
|
PyInstanceObject *inst = (PyInstanceObject*) func;
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
PyErr_SetString(PyExc_AttributeError,
|
PyErr_Format(PyExc_AttributeError,
|
||||||
"no __call__ method defined");
|
"%.200s instance has no __call__ method",
|
||||||
|
PyString_AsString(inst->in_class->cl_name));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
res = PyEval_CallObjectWithKeywords(call, arg, kw);
|
res = PyEval_CallObjectWithKeywords(call, arg, kw);
|
||||||
|
@ -2703,7 +2717,7 @@ call_function(PyObject *func, PyObject *arg, PyObject *kw)
|
||||||
}
|
}
|
||||||
if (self == NULL) {
|
if (self == NULL) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"unbound method must be called with class instance 1st argument");
|
"unbound method must be called with instance as first argument");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Py_INCREF(arg);
|
Py_INCREF(arg);
|
||||||
|
@ -2849,7 +2863,7 @@ _PyEval_SliceIndex(PyObject *v, int *pi)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"slice index must be int");
|
"slice indices must be integers");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* Truncate -- very long indices are truncated anyway */
|
/* Truncate -- very long indices are truncated anyway */
|
||||||
|
@ -2935,7 +2949,7 @@ import_from(PyObject *v, PyObject *name)
|
||||||
PyObject *w, *x;
|
PyObject *w, *x;
|
||||||
if (!PyModule_Check(v)) {
|
if (!PyModule_Check(v)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"import-from requires module object");
|
"import-from requires a module object");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
w = PyModule_GetDict(v); /* TDB: can this not fail ? */
|
w = PyModule_GetDict(v); /* TDB: can this not fail ? */
|
||||||
|
@ -2958,7 +2972,7 @@ import_all_from(PyObject *locals, PyObject *v)
|
||||||
|
|
||||||
if (!PyModule_Check(v)) {
|
if (!PyModule_Check(v)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"import-from requires module object");
|
"import-from requires a module object");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
w = PyModule_GetDict(v); /* TBD: can this not fail ? */
|
w = PyModule_GetDict(v); /* TBD: can this not fail ? */
|
||||||
|
@ -3068,12 +3082,17 @@ exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals,
|
||||||
!PyCode_Check(prog) &&
|
!PyCode_Check(prog) &&
|
||||||
!PyFile_Check(prog)) {
|
!PyFile_Check(prog)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"exec 1st arg must be string, code or file object");
|
"exec: arg 1 must be a string, file, or code object");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!PyDict_Check(globals) || !PyDict_Check(locals)) {
|
if (!PyDict_Check(globals)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"exec 2nd/3rd args must be dict or None");
|
"exec: arg 2 must be a dictionary or None");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (!PyDict_Check(locals)) {
|
||||||
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
"exec: arg 3 must be a dictionary or None");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (PyDict_GetItemString(globals, "__builtins__") == NULL)
|
if (PyDict_GetItemString(globals, "__builtins__") == NULL)
|
||||||
|
|
|
@ -224,7 +224,7 @@ int
|
||||||
PyErr_BadArgument(void)
|
PyErr_BadArgument(void)
|
||||||
{
|
{
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"illegal argument type for built-in operation");
|
"bad argument type for built-in operation");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,7 @@ get_self(PyObject *args)
|
||||||
/* Watch out for being called to early in the bootstrapping process */
|
/* Watch out for being called to early in the bootstrapping process */
|
||||||
if (PyExc_TypeError) {
|
if (PyExc_TypeError) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"unbound method must be called with class instance 1st argument");
|
"unbound method must be called with instance as first argument");
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue