mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Make test_base64 pass.
Change binascii.Error to derive from ValueError and raise binascii.Error everywhere where values are bad (why on earth did the old code use TypeError?!?).
This commit is contained in:
parent
0e225aa09b
commit
4581ae5fa2
5 changed files with 268 additions and 232 deletions
|
|
@ -1000,7 +1000,7 @@ binascii_unhexlify(PyObject *self, PyObject *args)
|
|||
* raise an exception.
|
||||
*/
|
||||
if (arglen % 2) {
|
||||
PyErr_SetString(PyExc_TypeError, "Odd-length string");
|
||||
PyErr_SetString(Error, "Odd-length string");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1013,7 +1013,7 @@ binascii_unhexlify(PyObject *self, PyObject *args)
|
|||
int top = to_int(Py_CHARMASK(argbuf[i]));
|
||||
int bot = to_int(Py_CHARMASK(argbuf[i+1]));
|
||||
if (top == -1 || bot == -1) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
PyErr_SetString(Error,
|
||||
"Non-hexadecimal digit found");
|
||||
goto finally;
|
||||
}
|
||||
|
|
@ -1371,7 +1371,7 @@ initbinascii(void)
|
|||
PyDict_SetItemString(d, "__doc__", x);
|
||||
Py_XDECREF(x);
|
||||
|
||||
Error = PyErr_NewException("binascii.Error", NULL, NULL);
|
||||
Error = PyErr_NewException("binascii.Error", PyExc_ValueError, NULL);
|
||||
PyDict_SetItemString(d, "Error", Error);
|
||||
Incomplete = PyErr_NewException("binascii.Incomplete", NULL, NULL);
|
||||
PyDict_SetItemString(d, "Incomplete", Incomplete);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue