summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-10-24 19:57:45 (GMT)
committerFred Drake <fdrake@acm.org>2000-10-24 19:57:45 (GMT)
commit661ea26b3d8621ad0acc0ed2f2036ab29355f8ff (patch)
treefcfe10c4656a3e18911cd3b41b7d8c942d707786 /Modules
parentbd6f4fba1bc66a18cc15d50ffdd33faedff5ac4c (diff)
downloadcpython-661ea26b3d8621ad0acc0ed2f2036ab29355f8ff.zip
cpython-661ea26b3d8621ad0acc0ed2f2036ab29355f8ff.tar.gz
cpython-661ea26b3d8621ad0acc0ed2f2036ab29355f8ff.tar.bz2
Ka-Ping Yee <ping@lfw.org>:
Changes to error messages to increase consistency & clarity. This (mostly) closes SourceForge patch #101839.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/dbmmodule.c6
-rw-r--r--Modules/parsermodule.c42
-rw-r--r--Modules/posixmodule.c56
3 files changed, 52 insertions, 52 deletions
diff --git a/Modules/dbmmodule.c b/Modules/dbmmodule.c
index 7e16d9b..6847364 100644
--- a/Modules/dbmmodule.c
+++ b/Modules/dbmmodule.c
@@ -140,7 +140,7 @@ dbm_ass_sub(dbmobject *dp, PyObject *v, PyObject *w)
if ( dbm_store(dp->di_dbm, krec, drec, DBM_REPLACE) < 0 ) {
dbm_clearerr(dp->di_dbm);
PyErr_SetString(DbmError,
- "Cannot add item to database");
+ "cannot add item to database");
return -1;
}
}
@@ -255,7 +255,7 @@ dbm_setdefault(register dbmobject *dp, PyObject *args)
val.dsize = PyString_GET_SIZE(defvalue);
if (dbm_store(dp->di_dbm, key, val, DBM_INSERT) < 0) {
dbm_clearerr(dp->di_dbm);
- PyErr_SetString(DbmError, "Cannot add item to database");
+ PyErr_SetString(DbmError, "cannot add item to database");
return NULL;
}
return defvalue;
@@ -325,7 +325,7 @@ dbmopen(PyObject *self, PyObject *args)
iflags = O_RDWR|O_CREAT|O_TRUNC;
else {
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 newdbmobject(name, iflags, mode);
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
index 3ffe693..e6e1456 100644
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -508,7 +508,7 @@ parser_do_parse(PyObject *args, PyObject *kw, char *argspec, int type)
if (n != 0)
res = parser_newastobject(n, type);
else
- err_string("Could not parse string.");
+ err_string("could not parse string");
}
return (res);
}
@@ -611,14 +611,14 @@ parser_tuple2ast(PyAST_Object *self, PyObject *args, PyObject *kw)
else {
/* This is a fragment, at best. */
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
* get this, but we'd do well to be sure something is done.
*/
if ((ast == 0) && !PyErr_Occurred())
- err_string("Unspecified ast error occurred.");
+ err_string("unspecified AST error occurred");
return (ast);
}
@@ -670,7 +670,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
PyObject *temp;
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;
}
temp = PySequence_GetItem(elem, 1);
@@ -678,8 +678,8 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
return 0;
if (!PyString_Check(temp)) {
PyErr_Format(parser_error,
- "Second item in terminal node must be a string,"
- " found %s.",
+ "second item in terminal node must be a string,"
+ " found %s",
((PyTypeObject*)PyObject_Type(temp))->tp_name);
Py_DECREF(temp);
return 0;
@@ -691,8 +691,8 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
*line_num = PyInt_AS_LONG(o);
else {
PyErr_Format(parser_error,
- "Third item in terminal node must be an"
- " integer, found %s.",
+ "third item in terminal node must be an"
+ " integer, found %s",
((PyTypeObject*)PyObject_Type(temp))->tp_name);
Py_DECREF(o);
Py_DECREF(temp);
@@ -713,7 +713,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
* Throw an exception.
*/
PyErr_SetObject(parser_error,
- Py_BuildValue("os", elem, "Unknown node type."));
+ Py_BuildValue("os", elem, "unknown node type."));
Py_XDECREF(elem);
return (0);
}
@@ -1566,7 +1566,7 @@ validate_dotted_as_name(node *tree)
&& validate_name(CHILD(tree, 2), NULL));
else {
res = 0;
- err_string("Illegal number of children for dotted_as_name.");
+ err_string("illegal number of children for dotted_as_name");
}
}
return res;
@@ -1655,7 +1655,7 @@ validate_exec_stmt(node *tree)
&& validate_expr(CHILD(tree, 1)));
if (!res && !PyErr_Occurred())
- err_string("Illegal exec statement.");
+ err_string("illegal exec statement");
if (res && (nch > 2))
res = (validate_name(CHILD(tree, 2), "in")
&& validate_test(CHILD(tree, 3)));
@@ -1682,7 +1682,7 @@ validate_assert_stmt(node *tree)
&& validate_test(CHILD(tree, 1)));
if (!res && !PyErr_Occurred())
- err_string("Illegal assert statement.");
+ err_string("illegal assert statement");
if (res && (nch > 2))
res = (validate_comma(CHILD(tree, 2))
&& validate_test(CHILD(tree, 3)));
@@ -1778,7 +1778,7 @@ validate_try(node *tree)
res = ((strcmp(STR(CHILD(tree, pos)), "except") == 0)
|| (strcmp(STR(CHILD(tree, pos)), "else") == 0));
if (!res)
- err_string("Illegal trailing triple in try statement.");
+ err_string("illegal trailing triple in try statement");
}
else if (nch == (pos + 6)) {
res = (validate_name(CHILD(tree, pos), "except")
@@ -1912,11 +1912,11 @@ validate_comp_op(node *tree)
|| (strcmp(STR(tree), "is") == 0));
if (!res) {
PyErr_Format(parser_error,
- "Illegal operator: '%s'.", STR(tree));
+ "illegal operator '%s'", STR(tree));
}
break;
default:
- err_string("Illegal comparison operator type.");
+ err_string("illegal comparison operator type");
break;
}
}
@@ -1928,7 +1928,7 @@ validate_comp_op(node *tree)
|| ((strcmp(STR(CHILD(tree, 0)), "not") == 0)
&& (strcmp(STR(CHILD(tree, 1)), "in") == 0))));
if (!res && !PyErr_Occurred())
- err_string("Unknown comparison operator.");
+ err_string("unknown comparison operator");
}
return (res);
}
@@ -2075,7 +2075,7 @@ validate_power(node *tree)
res = validate_trailer(CHILD(tree, pos++));
if (res && (pos < nch)) {
if (!is_even(nch - pos)) {
- err_string("Illegal number of nodes for 'power'.");
+ err_string("illegal number of nodes for 'power'");
return (0);
}
for ( ; res && (pos < (nch - 1)); pos += 2)
@@ -2532,7 +2532,7 @@ validate_node(node *tree)
if (res)
next = CHILD(tree, 0);
else if (nch == 1)
- err_string("Illegal flow_stmt type.");
+ err_string("illegal flow_stmt type");
break;
/*
* Compound statements.
@@ -2654,7 +2654,7 @@ validate_node(node *tree)
default:
/* Hopefully never reached! */
- err_string("Unrecogniged node type.");
+ err_string("unrecognized node type");
res = 0;
break;
}
@@ -2670,7 +2670,7 @@ validate_expr_tree(node *tree)
int res = validate_eval_input(tree);
if (!res && !PyErr_Occurred())
- err_string("Could not validate expression tuple.");
+ err_string("could not validate expression tuple");
return (res);
}
@@ -2698,7 +2698,7 @@ validate_file_input(node *tree)
* this, we have some debugging to do.
*/
if (!res && !PyErr_Occurred())
- err_string("VALIDATION FAILURE: report this to the maintainer!.");
+ err_string("VALIDATION FAILURE: report this to the maintainer!");
return (res);
}
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 8544f6a..a2251b1 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -1226,7 +1226,7 @@ posix_utime(PyObject *self, PyObject *args)
}
else if (!PyArg_Parse(arg, "(ll)", &atime, &mtime)) {
PyErr_SetString(PyExc_TypeError,
- "Second argument must be a 2-tuple of numbers.");
+ "utime() arg 2 must be a tuple (atime, mtime)");
return NULL;
}
else {
@@ -1294,12 +1294,12 @@ posix_execv(PyObject *self, PyObject *args)
getitem = PyTuple_GetItem;
}
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;
}
if (argc == 0) {
- PyErr_SetString(PyExc_ValueError, "empty argument list");
+ PyErr_SetString(PyExc_ValueError, "execv() arg 2 must not be empty");
return NULL;
}
@@ -1310,7 +1310,7 @@ posix_execv(PyObject *self, PyObject *args)
if (!PyArg_Parse((*getitem)(argv, i), "s", &argvlist[i])) {
PyMem_DEL(argvlist);
PyErr_SetString(PyExc_TypeError,
- "all arguments must be strings");
+ "execv() arg 2 must contain only strings");
return NULL;
}
@@ -1364,17 +1364,17 @@ posix_execve(PyObject *self, PyObject *args)
getitem = PyTuple_GetItem;
}
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;
}
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;
}
if (argc == 0) {
PyErr_SetString(PyExc_ValueError,
- "empty argument list");
+ "execve() arg 2 must not be empty");
return NULL;
}
@@ -1385,7 +1385,7 @@ posix_execve(PyObject *self, PyObject *args)
}
for (i = 0; i < argc; i++) {
if (!PyArg_Parse((*getitem)(argv, i),
- "s;argv must be list of strings",
+ "s;execve() arg 2 must contain only strings",
&argvlist[i]))
{
goto fail_1;
@@ -1413,8 +1413,8 @@ posix_execve(PyObject *self, PyObject *args)
if (!key || !val)
goto fail_2;
- if (!PyArg_Parse(key, "s;non-string key in env", &k) ||
- !PyArg_Parse(val, "s;non-string value in env", &v))
+ if (!PyArg_Parse(key, "s;execve() arg 3 contains a non-string key", &k) ||
+ !PyArg_Parse(val, "s;execve() arg 3 contains a non-string value", &v))
{
goto fail_2;
}
@@ -1493,7 +1493,7 @@ posix_spawnv(PyObject *self, PyObject *args)
getitem = PyTuple_GetItem;
}
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;
}
@@ -1504,7 +1504,7 @@ posix_spawnv(PyObject *self, PyObject *args)
if (!PyArg_Parse((*getitem)(argv, i), "s", &argvlist[i])) {
PyMem_DEL(argvlist);
PyErr_SetString(PyExc_TypeError,
- "all arguments must be strings");
+ "spawnv() arg 2 must contain only strings");
return NULL;
}
}
@@ -1563,11 +1563,11 @@ posix_spawnve(PyObject *self, PyObject *args)
getitem = PyTuple_GetItem;
}
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;
}
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;
}
@@ -1578,7 +1578,7 @@ posix_spawnve(PyObject *self, PyObject *args)
}
for (i = 0; i < argc; i++) {
if (!PyArg_Parse((*getitem)(argv, i),
- "s;argv must be list of strings",
+ "s;spawnve() arg 2 must contain only strings",
&argvlist[i]))
{
goto fail_1;
@@ -1606,8 +1606,8 @@ posix_spawnve(PyObject *self, PyObject *args)
if (!key || !val)
goto fail_2;
- if (!PyArg_Parse(key, "s;non-string key in env", &k) ||
- !PyArg_Parse(val, "s;non-string value in env", &v))
+ if (!PyArg_Parse(key, "s;spawnve() arg 3 contains a non-string key", &k) ||
+ !PyArg_Parse(val, "s;spawnve() arg 3 contains a non-string value", &v))
{
goto fail_2;
}
@@ -2150,13 +2150,13 @@ posix_popen(PyObject *self, PyObject *args)
if (*mode == 'r')
tm = _O_RDONLY;
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;
} else
tm = _O_WRONLY;
if (bufsize != -1) {
- PyErr_SetString(PyExc_ValueError, "bufsize must be -1");
+ PyErr_SetString(PyExc_ValueError, "popen() arg 3 must be -1");
return NULL;
}
@@ -2191,13 +2191,13 @@ win32_popen2(PyObject *self, PyObject *args)
if (*mode == 't')
tm = _O_TEXT;
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;
} else
tm = _O_BINARY;
if (bufsize != -1) {
- PyErr_SetString(PyExc_ValueError, "bufsize must be -1");
+ PyErr_SetString(PyExc_ValueError, "popen2() arg 3 must be -1");
return NULL;
}
@@ -2228,13 +2228,13 @@ win32_popen3(PyObject *self, PyObject *args)
if (*mode == 't')
tm = _O_TEXT;
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;
} else
tm = _O_BINARY;
if (bufsize != -1) {
- PyErr_SetString(PyExc_ValueError, "bufsize must be -1");
+ PyErr_SetString(PyExc_ValueError, "popen3() arg 3 must be -1");
return NULL;
}
@@ -2265,13 +2265,13 @@ win32_popen4(PyObject *self, PyObject *args)
if (*mode == 't')
tm = _O_TEXT;
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;
} else
tm = _O_BINARY;
if (bufsize != -1) {
- PyErr_SetString(PyExc_ValueError, "bufsize must be -1");
+ PyErr_SetString(PyExc_ValueError, "popen4() arg 3 must be -1");
return NULL;
}
@@ -2727,13 +2727,13 @@ static int _PyPclose(FILE *file)
* an exception. Just die.
*/
Py_FatalError("unable to allocate interpreter state "
- "when closing popen object.");
+ "when closing popen object");
return -1; /* unreachable */
}
pThreadState = PyThreadState_New(pInterpreterState);
if (!pThreadState) {
Py_FatalError("unable to allocate thread state "
- "when closing popen object.");
+ "when closing popen object");
return -1; /* unreachable */
}
/* Grab the global lock. Note that this will deadlock if the
@@ -3761,7 +3761,7 @@ posix_strerror(PyObject *self, PyObject *args)
message = strerror(code);
if (message == NULL) {
PyErr_SetString(PyExc_ValueError,
- "strerror code out of range");
+ "strerror() argument out of range");
return NULL;
}
return PyString_FromString(message);