@@ -2668,6 +2668,10 @@ SimpleExtendsException(PyExc_ValueError, UnicodeError,
26682668 "Unicode related error." );
26692669
26702670
2671+ /*
2672+ * Check the validity of 'attr' as a unicode or bytes object depending
2673+ * on 'as_bytes' and return a new reference on it if it is the case.
2674+ */
26712675static PyObject *
26722676as_unicode_error_attribute (PyObject * attr , const char * name , int as_bytes )
26732677{
@@ -2689,6 +2693,11 @@ as_unicode_error_attribute(PyObject *attr, const char *name, int as_bytes)
26892693}
26902694
26912695
2696+ /*
2697+ * Return the underlying (str) 'encoding' attribute of a Unicode Error object.
2698+ *
2699+ * The caller is responsible to ensure that 'self' is a PyUnicodeErrorObject.
2700+ */
26922701static inline PyObject *
26932702unicode_error_get_encoding_impl (PyObject * self )
26942703{
@@ -2699,6 +2708,12 @@ unicode_error_get_encoding_impl(PyObject *self)
26992708}
27002709
27012710
2711+ /*
2712+ * Return the underlying 'object' attribute of a Unicode Error object
2713+ * as a bytes or a string instance, depending on the 'as_bytes' flag.
2714+ *
2715+ * The caller is responsible to ensure that 'self' is a PyUnicodeErrorObject.
2716+ */
27022717static inline PyObject *
27032718unicode_error_get_object_impl (PyObject * self , int as_bytes )
27042719{
@@ -2709,6 +2724,11 @@ unicode_error_get_object_impl(PyObject *self, int as_bytes)
27092724}
27102725
27112726
2727+ /*
2728+ * Return the underlying (str) 'reason' attribute of a Unicode Error object.
2729+ *
2730+ * The caller is responsible to ensure that 'self' is a PyUnicodeErrorObject.
2731+ */
27122732static inline PyObject *
27132733unicode_error_get_reason_impl (PyObject * self )
27142734{
@@ -2719,6 +2739,13 @@ unicode_error_get_reason_impl(PyObject *self)
27192739}
27202740
27212741
2742+ /*
2743+ * Set the underlying (str) 'reason' attribute of a Unicode Error object.
2744+ *
2745+ * The caller is responsible to ensure that 'self' is a PyUnicodeErrorObject.
2746+ *
2747+ * Return 0 on success and -1 on failure.
2748+ */
27222749static inline int
27232750unicode_error_set_reason_impl (PyObject * self , const char * reason )
27242751{
@@ -2734,7 +2761,19 @@ unicode_error_set_reason_impl(PyObject *self, const char *reason)
27342761}
27352762
27362763
2737- static inline int
2764+ /*
2765+ * Get the underlying 'object' attribute of a Unicode Error object
2766+ * as a bytes or a string instance, depending on the 'as_bytes' flag.
2767+ *
2768+ * The result is stored in 'result' and its size in 'size',
2769+ * which can be NULL to indicate that the value would be
2770+ * discarded after the call.
2771+ *
2772+ * The caller is responsible to ensure that 'self' is a PyUnicodeErrorObject.
2773+ *
2774+ * Return 0 on success and -1 on failure.
2775+ */
2776+ static int
27382777unicode_error_get_object_and_size (PyObject * self ,
27392778 PyObject * * result , Py_ssize_t * size ,
27402779 int as_bytes )
@@ -2808,6 +2847,13 @@ unicode_error_adjust_end(Py_ssize_t end, Py_ssize_t objlen)
28082847}
28092848
28102849
2850+ /*
2851+ * Retrieve and adjust the 'start' attribute of a Unicode Error object.
2852+ *
2853+ * The caller is responsible to ensure that 'self' is a PyUnicodeErrorObject.
2854+ *
2855+ * Return 0 on success and -1 on failure.
2856+ */
28112857static inline int
28122858unicode_error_get_start_impl (PyObject * self , Py_ssize_t * start , int as_bytes )
28132859{
@@ -2825,6 +2871,13 @@ unicode_error_get_start_impl(PyObject *self, Py_ssize_t *start, int as_bytes)
28252871}
28262872
28272873
2874+ /*
2875+ * Set the 'start' attribute of a Unicode Error object.
2876+ *
2877+ * The caller is responsible to ensure that 'self' is a PyUnicodeErrorObject.
2878+ *
2879+ * Return 0 on success and -1 on failure.
2880+ */
28282881static inline int
28292882unicode_error_set_start_impl (PyObject * self , Py_ssize_t start )
28302883{
@@ -2836,6 +2889,13 @@ unicode_error_set_start_impl(PyObject *self, Py_ssize_t start)
28362889}
28372890
28382891
2892+ /*
2893+ * Retrieve and adjust the 'end' attribute of a Unicode Error object.
2894+ *
2895+ * The caller is responsible to ensure that 'self' is a PyUnicodeErrorObject.
2896+ *
2897+ * Return 0 on success and -1 on failure.
2898+ */
28392899static inline int
28402900unicode_error_get_end_impl (PyObject * self , Py_ssize_t * end , int as_bytes )
28412901{
@@ -2853,6 +2913,13 @@ unicode_error_get_end_impl(PyObject *self, Py_ssize_t *end, int as_bytes)
28532913}
28542914
28552915
2916+ /*
2917+ * Set the 'end' attribute of a Unicode Error object.
2918+ *
2919+ * The caller is responsible to ensure that 'self' is a PyUnicodeErrorObject.
2920+ *
2921+ * Return 0 on success and -1 on failure.
2922+ */
28562923static inline int
28572924unicode_error_set_end_impl (PyObject * self , Py_ssize_t end )
28582925{
0 commit comments