Skip to content

Commit ba84635

Browse files
Commit
1 parent 9cecc71 commit ba84635

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

Lib/test/test_exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ def testAttributes(self):
502502
'start' : 0, 'reason' : 'ordinal not in range'}),
503503
(UnicodeDecodeError, ('ascii', bytearray(b'\xff'), 0, 1,
504504
'ordinal not in range'), {},
505-
{'args' : ('ascii', bytearray(b'\xff'), 0, 1,
505+
{'args' : ('ascii', (b'\xff'), 0, 1,
506506
'ordinal not in range'),
507507
'encoding' : 'ascii', 'object' : b'\xff',
508508
'start' : 0, 'reason' : 'ordinal not in range'}),

Objects/exceptions.c

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2973,31 +2973,8 @@ SimpleExtendsException(PyExc_Exception, ValueError,
29732973
* UnicodeError extends ValueError
29742974
*/
29752975

2976-
#define PyUnicodeError_Check(PTR) \
2977-
PyObject_TypeCheck((PTR), (PyTypeObject *)PyExc_UnicodeError)
2978-
#define PyUnicodeErrorObject_CAST(op) \
2979-
(assert(PyUnicodeError_Check(op)), ((PyUnicodeErrorObject *)(op)))
2980-
2981-
static PyObject *
2982-
UnicodeError_args_get(PyObject *op, void *context)
2983-
{
2984-
PyUnicodeErrorObject *self = PyUnicodeErrorObject_CAST(op);
2985-
return Py_BuildValue("(OOnnO)",
2986-
self->encoding ? self->encoding : Py_None,
2987-
self->object ? self->object : Py_None,
2988-
self->start,
2989-
self->end,
2990-
self->reason ? self->reason : Py_None);
2991-
}
2992-
2993-
static PyGetSetDef UnicodeError_getset[] = {
2994-
{"args", UnicodeError_args_get, NULL, NULL},
2995-
{NULL}
2996-
};
2997-
2998-
ComplexExtendsException(PyExc_ValueError, UnicodeError, BaseException,
2999-
BaseException_new, 0, 0, UnicodeError_getset,
3000-
0, "Unicode related error.");
2976+
SimpleExtendsException(PyExc_ValueError, UnicodeError,
2977+
"Unicode related error.");
30012978

30022979

30032980
/*
@@ -3241,6 +3218,28 @@ unicode_error_adjust_end(Py_ssize_t end, Py_ssize_t objlen)
32413218
return end;
32423219
}
32433220

3221+
#define PyUnicodeError_Check(PTR) \
3222+
PyObject_TypeCheck((PTR), (PyTypeObject *)PyExc_UnicodeError)
3223+
#define PyUnicodeErrorObject_CAST(op) \
3224+
(assert(PyUnicodeError_Check(op)), ((PyUnicodeErrorObject *)(op)))
3225+
3226+
static PyObject *
3227+
UnicodeError_args_get(PyObject *op, void *context)
3228+
{
3229+
PyUnicodeErrorObject *self = PyUnicodeErrorObject_CAST(op);
3230+
return Py_BuildValue("(OOnnO)",
3231+
self->encoding ? self->encoding : Py_None,
3232+
self->object ? self->object : Py_None,
3233+
self->start,
3234+
self->end,
3235+
self->reason ? self->reason : Py_None);
3236+
}
3237+
3238+
static PyGetSetDef UnicodeError_getset[] = {
3239+
{"args", UnicodeError_args_get, NULL, NULL},
3240+
{NULL}
3241+
};
3242+
32443243
/* Assert some properties of the adjusted 'end' value. */
32453244
#ifndef NDEBUG
32463245
static void

0 commit comments

Comments
 (0)