"'abc", # quote is not closed
"'abc\"", # open quote and close quote don't match
"'abc' ?", # junk after close quote
+ "'\\'", # trailing backslash
# some tests of the quoting rules
#"'abc\"\''",
#"'\\\\a\'\'\'\\\'\\\\\''",
continue;
}
s++;
+ if (s==end) {
+ PyErr_SetString(PyExc_ValueError,
+ "Trailing \\ in string");
+ goto failed;
+ }
switch (*s++) {
/* XXX This assumes ASCII! */
case '\n': break;
break;
}
if (!errors || strcmp(errors, "strict") == 0) {
- Py_DECREF(v);
PyErr_SetString(PyExc_ValueError,
"invalid \\x escape");
- return NULL;
+ goto failed;
}
if (strcmp(errors, "replace") == 0) {
*p++ = '?';
"decoding error; "
"unknown error handling code: %.400s",
errors);
- return NULL;
+ goto failed;
}
#ifndef Py_USING_UNICODE
case 'u':
case 'U':
case 'N':
if (unicode) {
- Py_DECREF(v);
com_error(com, PyExc_ValueError,
"Unicode escapes not legal "
"when Unicode disabled");
- return NULL;
+ goto failed;
}
#endif
default: