|
141 | 141 | #include "malloc_closure.h"
|
142 | 142 |
|
143 | 143 |
|
144 |
| -#if PY_VERSION_HEX >= 0x03030000 |
145 |
| -# define PyText_GetSize PyUnicode_GetLength |
146 |
| -#else |
147 |
| -# define PyText_GetSize PyUnicode_GetSize |
148 |
| -#endif |
149 |
| - |
150 | 144 | #if PY_VERSION_HEX < 0x030900a4
|
151 | 145 | # define Py_SET_REFCNT(obj, val) (Py_REFCNT(obj) = (val))
|
152 | 146 | #endif
|
153 | 147 |
|
154 |
| -#if PY_VERSION_HEX >= 0x03080000 |
155 |
| -# define USE_WRITEUNRAISABLEMSG |
156 |
| -#endif |
157 |
| - |
158 | 148 | /************************************************************/
|
159 | 149 |
|
160 | 150 | /* base type flag: exactly one of the following: */
|
@@ -4431,7 +4421,7 @@ static void *b_do_dlopen(PyObject *args, const char **p_printable_filename,
|
4431 | 4421 | if (*p_printable_filename == NULL)
|
4432 | 4422 | return NULL;
|
4433 | 4423 |
|
4434 |
| - sz1 = PyText_GetSize(filename_unicode) + 1; |
| 4424 | + sz1 = PyUnicode_GetLength(filename_unicode) + 1; |
4435 | 4425 | sz1 *= 2; /* should not be needed, but you never know */
|
4436 | 4426 | w1 = alloca(sizeof(wchar_t) * sz1);
|
4437 | 4427 | sz1 = PyUnicode_AsWideChar(filename_unicode,
|
@@ -5141,7 +5131,7 @@ static PyObject *b_complete_struct_or_union(PyObject *self, PyObject *args)
|
5141 | 5131 | if (!(sflags & SF_GCC_ARM_BITFIELDS) && fbitsize >= 0) {
|
5142 | 5132 | if (!(sflags & SF_MSVC_BITFIELDS)) {
|
5143 | 5133 | /* GCC: anonymous bitfields (of any size) don't cause alignment */
|
5144 |
| - do_align = PyText_GetSize(fname) > 0; |
| 5134 | + do_align = PyUnicode_GetLength(fname) > 0; |
5145 | 5135 | }
|
5146 | 5136 | else {
|
5147 | 5137 | /* MSVC: zero-sized bitfields don't cause alignment */
|
@@ -5185,7 +5175,7 @@ static PyObject *b_complete_struct_or_union(PyObject *self, PyObject *args)
|
5185 | 5175 | byteoffset = foffset;
|
5186 | 5176 | }
|
5187 | 5177 |
|
5188 |
| - if (PyText_GetSize(fname) == 0 && |
| 5178 | + if (PyUnicode_GetLength(fname) == 0 && |
5189 | 5179 | ftype->ct_flags & (CT_STRUCT|CT_UNION)) {
|
5190 | 5180 | /* a nested anonymous struct or union */
|
5191 | 5181 | CFieldObject *cfsrc = (CFieldObject *)ftype->ct_extra;
|
@@ -5256,7 +5246,7 @@ static PyObject *b_complete_struct_or_union(PyObject *self, PyObject *args)
|
5256 | 5246 | field_offset_bytes &= ~(falign - 1);
|
5257 | 5247 |
|
5258 | 5248 | if (fbitsize == 0) {
|
5259 |
| - if (PyText_GetSize(fname) > 0) { |
| 5249 | + if (PyUnicode_GetLength(fname) > 0) { |
5260 | 5250 | PyErr_Format(PyExc_TypeError,
|
5261 | 5251 | "field '%s.%s' is declared with :0",
|
5262 | 5252 | ct->ct_name, PyUnicode_AsUTF8(fname));
|
@@ -5345,7 +5335,7 @@ static PyObject *b_complete_struct_or_union(PyObject *self, PyObject *args)
|
5345 | 5335 | if (sflags & SF_GCC_BIG_ENDIAN)
|
5346 | 5336 | bitshift = 8 * ftype->ct_size - fbitsize - bitshift;
|
5347 | 5337 |
|
5348 |
| - if (PyText_GetSize(fname) > 0) { |
| 5338 | + if (PyUnicode_GetLength(fname) > 0) { |
5349 | 5339 |
|
5350 | 5340 | *previous = _add_field(interned_fields, fname, ftype,
|
5351 | 5341 | field_offset_bytes, bitshift, fbitsize,
|
@@ -6000,7 +5990,6 @@ static void _my_PyErr_WriteUnraisable(PyObject *t, PyObject *v, PyObject *tb,
|
6000 | 5990 | char *extra_error_line)
|
6001 | 5991 | {
|
6002 | 5992 | /* like PyErr_WriteUnraisable(), but write a full traceback */
|
6003 |
| -#ifdef USE_WRITEUNRAISABLEMSG |
6004 | 5993 |
|
6005 | 5994 | /* PyErr_WriteUnraisable actually writes the full traceback anyway
|
6006 | 5995 | from Python 3.4, but we can't really get the formatting of the
|
@@ -6037,34 +6026,6 @@ static void _my_PyErr_WriteUnraisable(PyObject *t, PyObject *v, PyObject *tb,
|
6037 | 6026 | else
|
6038 | 6027 | PyErr_WriteUnraisable(obj); /* best effort */
|
6039 | 6028 | PyErr_Clear();
|
6040 |
| - |
6041 |
| -#else |
6042 |
| - |
6043 |
| - /* version for Python 2.7 and < 3.8 */ |
6044 |
| - PyObject *f; |
6045 |
| - /* jump through hoops to ensure the tb is attached to v, on Python 3 */ |
6046 |
| - PyErr_NormalizeException(&t, &v, &tb); |
6047 |
| - if (tb == NULL) { |
6048 |
| - tb = Py_None; |
6049 |
| - Py_INCREF(tb); |
6050 |
| - } |
6051 |
| - PyException_SetTraceback(v, tb); |
6052 |
| - f = PySys_GetObject("stderr"); |
6053 |
| - if (f != NULL) { |
6054 |
| - if (obj != NULL) { |
6055 |
| - PyFile_WriteString(objdescr, f); |
6056 |
| - PyFile_WriteObject(obj, f, 0); |
6057 |
| - PyFile_WriteString(":\n", f); |
6058 |
| - } |
6059 |
| - if (extra_error_line != NULL) |
6060 |
| - PyFile_WriteString(extra_error_line, f); |
6061 |
| - PyErr_Display(t, v, tb); |
6062 |
| - } |
6063 |
| - Py_XDECREF(t); |
6064 |
| - Py_XDECREF(v); |
6065 |
| - Py_XDECREF(tb); |
6066 |
| - |
6067 |
| -#endif |
6068 | 6029 | }
|
6069 | 6030 |
|
6070 | 6031 | static void general_invoke_callback(int decode_args_from_libffi,
|
@@ -6114,11 +6075,7 @@ static void general_invoke_callback(int decode_args_from_libffi,
|
6114 | 6075 | goto error;
|
6115 | 6076 | if (convert_from_object_fficallback(result, SIGNATURE(1), py_res,
|
6116 | 6077 | decode_args_from_libffi) < 0) {
|
6117 |
| -#ifdef USE_WRITEUNRAISABLEMSG |
6118 | 6078 | extra_error_line = ", trying to convert the result back to C";
|
6119 |
| -#else |
6120 |
| - extra_error_line = "Trying to convert the result back to C:\n"; |
6121 |
| -#endif |
6122 | 6079 | goto error;
|
6123 | 6080 | }
|
6124 | 6081 | done:
|
@@ -6170,16 +6127,9 @@ static void general_invoke_callback(int decode_args_from_libffi,
|
6170 | 6127 | _my_PyErr_WriteUnraisable(exc1, val1, tb1,
|
6171 | 6128 | "From cffi callback ", py_ob,
|
6172 | 6129 | extra_error_line);
|
6173 |
| -#ifdef USE_WRITEUNRAISABLEMSG |
6174 | 6130 | _my_PyErr_WriteUnraisable(exc2, val2, tb2,
|
6175 | 6131 | "during handling of the above exception by 'onerror'",
|
6176 | 6132 | NULL, NULL);
|
6177 |
| -#else |
6178 |
| - extra_error_line = ("\nDuring the call to 'onerror', " |
6179 |
| - "another exception occurred:\n\n"); |
6180 |
| - _my_PyErr_WriteUnraisable(exc2, val2, tb2, |
6181 |
| - NULL, NULL, extra_error_line); |
6182 |
| -#endif |
6183 | 6133 | _cffi_stop_error_capture(ecap);
|
6184 | 6134 | }
|
6185 | 6135 | }
|
@@ -6247,14 +6197,6 @@ static PyObject *prepare_callback_info_tuple(CTypeDescrObject *ct,
|
6247 | 6197 | infotuple = Py_BuildValue("OOOO", ct, ob, py_rawerr, onerror_ob);
|
6248 | 6198 | Py_DECREF(py_rawerr);
|
6249 | 6199 |
|
6250 |
| -#if defined(WITH_THREAD) && PY_VERSION_HEX < 0x03070000 |
6251 |
| - /* We must setup the GIL here, in case the callback is invoked in |
6252 |
| - some other non-Pythonic thread. This is the same as ctypes. |
6253 |
| - But PyEval_InitThreads() is always a no-op from CPython 3.7 |
6254 |
| - (the call from ctypes was removed some time later I think). */ |
6255 |
| - PyEval_InitThreads(); |
6256 |
| -#endif |
6257 |
| - |
6258 | 6200 | return infotuple;
|
6259 | 6201 | }
|
6260 | 6202 |
|
|
0 commit comments