|
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,
|
@@ -5137,7 +5127,7 @@ static PyObject *b_complete_struct_or_union(PyObject *self, PyObject *args)
|
5137 | 5127 | if (!(sflags & SF_GCC_ARM_BITFIELDS) && fbitsize >= 0) {
|
5138 | 5128 | if (!(sflags & SF_MSVC_BITFIELDS)) {
|
5139 | 5129 | /* GCC: anonymous bitfields (of any size) don't cause alignment */
|
5140 |
| - do_align = PyText_GetSize(fname) > 0; |
| 5130 | + do_align = PyUnicode_GetLength(fname) > 0; |
5141 | 5131 | }
|
5142 | 5132 | else {
|
5143 | 5133 | /* MSVC: zero-sized bitfields don't cause alignment */
|
@@ -5181,7 +5171,7 @@ static PyObject *b_complete_struct_or_union(PyObject *self, PyObject *args)
|
5181 | 5171 | byteoffset = foffset;
|
5182 | 5172 | }
|
5183 | 5173 |
|
5184 |
| - if (PyText_GetSize(fname) == 0 && |
| 5174 | + if (PyUnicode_GetLength(fname) == 0 && |
5185 | 5175 | ftype->ct_flags & (CT_STRUCT|CT_UNION)) {
|
5186 | 5176 | /* a nested anonymous struct or union */
|
5187 | 5177 | CFieldObject *cfsrc = (CFieldObject *)ftype->ct_extra;
|
@@ -5252,7 +5242,7 @@ static PyObject *b_complete_struct_or_union(PyObject *self, PyObject *args)
|
5252 | 5242 | field_offset_bytes &= ~(falign - 1);
|
5253 | 5243 |
|
5254 | 5244 | if (fbitsize == 0) {
|
5255 |
| - if (PyText_GetSize(fname) > 0) { |
| 5245 | + if (PyUnicode_GetLength(fname) > 0) { |
5256 | 5246 | PyErr_Format(PyExc_TypeError,
|
5257 | 5247 | "field '%s.%s' is declared with :0",
|
5258 | 5248 | ct->ct_name, PyUnicode_AsUTF8(fname));
|
@@ -5341,7 +5331,7 @@ static PyObject *b_complete_struct_or_union(PyObject *self, PyObject *args)
|
5341 | 5331 | if (sflags & SF_GCC_BIG_ENDIAN)
|
5342 | 5332 | bitshift = 8 * ftype->ct_size - fbitsize - bitshift;
|
5343 | 5333 |
|
5344 |
| - if (PyText_GetSize(fname) > 0) { |
| 5334 | + if (PyUnicode_GetLength(fname) > 0) { |
5345 | 5335 |
|
5346 | 5336 | *previous = _add_field(interned_fields, fname, ftype,
|
5347 | 5337 | field_offset_bytes, bitshift, fbitsize,
|
@@ -5996,7 +5986,6 @@ static void _my_PyErr_WriteUnraisable(PyObject *t, PyObject *v, PyObject *tb,
|
5996 | 5986 | char *extra_error_line)
|
5997 | 5987 | {
|
5998 | 5988 | /* like PyErr_WriteUnraisable(), but write a full traceback */
|
5999 |
| -#ifdef USE_WRITEUNRAISABLEMSG |
6000 | 5989 |
|
6001 | 5990 | /* PyErr_WriteUnraisable actually writes the full traceback anyway
|
6002 | 5991 | from Python 3.4, but we can't really get the formatting of the
|
@@ -6033,34 +6022,6 @@ static void _my_PyErr_WriteUnraisable(PyObject *t, PyObject *v, PyObject *tb,
|
6033 | 6022 | else
|
6034 | 6023 | PyErr_WriteUnraisable(obj); /* best effort */
|
6035 | 6024 | PyErr_Clear();
|
6036 |
| - |
6037 |
| -#else |
6038 |
| - |
6039 |
| - /* version for Python 2.7 and < 3.8 */ |
6040 |
| - PyObject *f; |
6041 |
| - /* jump through hoops to ensure the tb is attached to v, on Python 3 */ |
6042 |
| - PyErr_NormalizeException(&t, &v, &tb); |
6043 |
| - if (tb == NULL) { |
6044 |
| - tb = Py_None; |
6045 |
| - Py_INCREF(tb); |
6046 |
| - } |
6047 |
| - PyException_SetTraceback(v, tb); |
6048 |
| - f = PySys_GetObject("stderr"); |
6049 |
| - if (f != NULL) { |
6050 |
| - if (obj != NULL) { |
6051 |
| - PyFile_WriteString(objdescr, f); |
6052 |
| - PyFile_WriteObject(obj, f, 0); |
6053 |
| - PyFile_WriteString(":\n", f); |
6054 |
| - } |
6055 |
| - if (extra_error_line != NULL) |
6056 |
| - PyFile_WriteString(extra_error_line, f); |
6057 |
| - PyErr_Display(t, v, tb); |
6058 |
| - } |
6059 |
| - Py_XDECREF(t); |
6060 |
| - Py_XDECREF(v); |
6061 |
| - Py_XDECREF(tb); |
6062 |
| - |
6063 |
| -#endif |
6064 | 6025 | }
|
6065 | 6026 |
|
6066 | 6027 | static void general_invoke_callback(int decode_args_from_libffi,
|
@@ -6110,11 +6071,7 @@ static void general_invoke_callback(int decode_args_from_libffi,
|
6110 | 6071 | goto error;
|
6111 | 6072 | if (convert_from_object_fficallback(result, SIGNATURE(1), py_res,
|
6112 | 6073 | decode_args_from_libffi) < 0) {
|
6113 |
| -#ifdef USE_WRITEUNRAISABLEMSG |
6114 | 6074 | extra_error_line = ", trying to convert the result back to C";
|
6115 |
| -#else |
6116 |
| - extra_error_line = "Trying to convert the result back to C:\n"; |
6117 |
| -#endif |
6118 | 6075 | goto error;
|
6119 | 6076 | }
|
6120 | 6077 | done:
|
@@ -6166,16 +6123,9 @@ static void general_invoke_callback(int decode_args_from_libffi,
|
6166 | 6123 | _my_PyErr_WriteUnraisable(exc1, val1, tb1,
|
6167 | 6124 | "From cffi callback ", py_ob,
|
6168 | 6125 | extra_error_line);
|
6169 |
| -#ifdef USE_WRITEUNRAISABLEMSG |
6170 | 6126 | _my_PyErr_WriteUnraisable(exc2, val2, tb2,
|
6171 | 6127 | "during handling of the above exception by 'onerror'",
|
6172 | 6128 | NULL, NULL);
|
6173 |
| -#else |
6174 |
| - extra_error_line = ("\nDuring the call to 'onerror', " |
6175 |
| - "another exception occurred:\n\n"); |
6176 |
| - _my_PyErr_WriteUnraisable(exc2, val2, tb2, |
6177 |
| - NULL, NULL, extra_error_line); |
6178 |
| -#endif |
6179 | 6129 | _cffi_stop_error_capture(ecap);
|
6180 | 6130 | }
|
6181 | 6131 | }
|
@@ -6243,14 +6193,6 @@ static PyObject *prepare_callback_info_tuple(CTypeDescrObject *ct,
|
6243 | 6193 | infotuple = Py_BuildValue("OOOO", ct, ob, py_rawerr, onerror_ob);
|
6244 | 6194 | Py_DECREF(py_rawerr);
|
6245 | 6195 |
|
6246 |
| -#if defined(WITH_THREAD) && PY_VERSION_HEX < 0x03070000 |
6247 |
| - /* We must setup the GIL here, in case the callback is invoked in |
6248 |
| - some other non-Pythonic thread. This is the same as ctypes. |
6249 |
| - But PyEval_InitThreads() is always a no-op from CPython 3.7 |
6250 |
| - (the call from ctypes was removed some time later I think). */ |
6251 |
| - PyEval_InitThreads(); |
6252 |
| -#endif |
6253 |
| - |
6254 | 6196 | return infotuple;
|
6255 | 6197 | }
|
6256 | 6198 |
|
|
0 commit comments