diff options
author | Victor Stinner <vstinner@python.org> | 2023-07-25 13:28:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-25 13:28:30 (GMT) |
commit | 1a3faba9f15e0c03c6cc0d225d377b8910b5379f (patch) | |
tree | 0aebe4139933835899fd5f618c023bceb9de0389 /Objects/exceptions.c | |
parent | ed082383272c2c238e364e9cc83229234aee23cc (diff) | |
download | cpython-1a3faba9f15e0c03c6cc0d225d377b8910b5379f.zip cpython-1a3faba9f15e0c03c6cc0d225d377b8910b5379f.tar.gz cpython-1a3faba9f15e0c03c6cc0d225d377b8910b5379f.tar.bz2 |
gh-106869: Use new PyMemberDef constant names (#106871)
* Remove '#include "structmember.h"'.
* If needed, add <stddef.h> to get offsetof() function.
* Update Parser/asdl_c.py to regenerate Python/Python-ast.c.
* Replace:
* T_SHORT => Py_T_SHORT
* T_INT => Py_T_INT
* T_LONG => Py_T_LONG
* T_FLOAT => Py_T_FLOAT
* T_DOUBLE => Py_T_DOUBLE
* T_STRING => Py_T_STRING
* T_OBJECT => _Py_T_OBJECT
* T_CHAR => Py_T_CHAR
* T_BYTE => Py_T_BYTE
* T_UBYTE => Py_T_UBYTE
* T_USHORT => Py_T_USHORT
* T_UINT => Py_T_UINT
* T_ULONG => Py_T_ULONG
* T_STRING_INPLACE => Py_T_STRING_INPLACE
* T_BOOL => Py_T_BOOL
* T_OBJECT_EX => Py_T_OBJECT_EX
* T_LONGLONG => Py_T_LONGLONG
* T_ULONGLONG => Py_T_ULONGLONG
* T_PYSSIZET => Py_T_PYSSIZET
* T_NONE => _Py_T_NONE
* READONLY => Py_READONLY
* PY_AUDIT_READ => Py_AUDIT_READ
* READ_RESTRICTED => Py_AUDIT_READ
* PY_WRITE_RESTRICTED => _Py_WRITE_RESTRICTED
* RESTRICTED => (READ_RESTRICTED | _Py_WRITE_RESTRICTED)
Diffstat (limited to 'Objects/exceptions.c')
-rw-r--r-- | Objects/exceptions.c | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 42c5317..62a4423 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -12,7 +12,7 @@ #include "pycore_exceptions.h" // struct _Py_exc_state #include "pycore_initconfig.h" #include "pycore_object.h" -#include "structmember.h" // PyMemberDef + #include "osdefs.h" // SEP @@ -439,7 +439,7 @@ PyExceptionClass_Name(PyObject *ob) } static struct PyMemberDef BaseException_members[] = { - {"__suppress_context__", T_BOOL, + {"__suppress_context__", Py_T_BOOL, offsetof(PyBaseExceptionObject, suppress_context)}, {NULL} }; @@ -569,7 +569,7 @@ SimpleExtendsException(PyExc_Exception, StopAsyncIteration, */ static PyMemberDef StopIteration_members[] = { - {"value", T_OBJECT, offsetof(PyStopIterationObject, value), 0, + {"value", _Py_T_OBJECT, offsetof(PyStopIterationObject, value), 0, PyDoc_STR("generator return value")}, {NULL} /* Sentinel */ }; @@ -671,7 +671,7 @@ SystemExit_traverse(PySystemExitObject *self, visitproc visit, void *arg) } static PyMemberDef SystemExit_members[] = { - {"code", T_OBJECT, offsetof(PySystemExitObject, code), 0, + {"code", _Py_T_OBJECT, offsetof(PySystemExitObject, code), 0, PyDoc_STR("exception code")}, {NULL} /* Sentinel */ }; @@ -1477,9 +1477,9 @@ PyUnstable_Exc_PrepReraiseStar(PyObject *orig, PyObject *excs) } static PyMemberDef BaseExceptionGroup_members[] = { - {"message", T_OBJECT, offsetof(PyBaseExceptionGroupObject, msg), READONLY, + {"message", _Py_T_OBJECT, offsetof(PyBaseExceptionGroupObject, msg), Py_READONLY, PyDoc_STR("exception message")}, - {"exceptions", T_OBJECT, offsetof(PyBaseExceptionGroupObject, excs), READONLY, + {"exceptions", _Py_T_OBJECT, offsetof(PyBaseExceptionGroupObject, excs), Py_READONLY, PyDoc_STR("nested exceptions")}, {NULL} /* Sentinel */ }; @@ -1654,13 +1654,13 @@ ImportError_reduce(PyImportErrorObject *self, PyObject *Py_UNUSED(ignored)) } static PyMemberDef ImportError_members[] = { - {"msg", T_OBJECT, offsetof(PyImportErrorObject, msg), 0, + {"msg", _Py_T_OBJECT, offsetof(PyImportErrorObject, msg), 0, PyDoc_STR("exception message")}, - {"name", T_OBJECT, offsetof(PyImportErrorObject, name), 0, + {"name", _Py_T_OBJECT, offsetof(PyImportErrorObject, name), 0, PyDoc_STR("module name")}, - {"path", T_OBJECT, offsetof(PyImportErrorObject, path), 0, + {"path", _Py_T_OBJECT, offsetof(PyImportErrorObject, path), 0, PyDoc_STR("module path")}, - {"name_from", T_OBJECT, offsetof(PyImportErrorObject, name_from), 0, + {"name_from", _Py_T_OBJECT, offsetof(PyImportErrorObject, name_from), 0, PyDoc_STR("name imported from module")}, {NULL} /* Sentinel */ }; @@ -2103,16 +2103,16 @@ OSError_written_set(PyOSErrorObject *self, PyObject *arg, void *context) } static PyMemberDef OSError_members[] = { - {"errno", T_OBJECT, offsetof(PyOSErrorObject, myerrno), 0, + {"errno", _Py_T_OBJECT, offsetof(PyOSErrorObject, myerrno), 0, PyDoc_STR("POSIX exception code")}, - {"strerror", T_OBJECT, offsetof(PyOSErrorObject, strerror), 0, + {"strerror", _Py_T_OBJECT, offsetof(PyOSErrorObject, strerror), 0, PyDoc_STR("exception strerror")}, - {"filename", T_OBJECT, offsetof(PyOSErrorObject, filename), 0, + {"filename", _Py_T_OBJECT, offsetof(PyOSErrorObject, filename), 0, PyDoc_STR("exception filename")}, - {"filename2", T_OBJECT, offsetof(PyOSErrorObject, filename2), 0, + {"filename2", _Py_T_OBJECT, offsetof(PyOSErrorObject, filename2), 0, PyDoc_STR("second exception filename")}, #ifdef MS_WINDOWS - {"winerror", T_OBJECT, offsetof(PyOSErrorObject, winerror), 0, + {"winerror", _Py_T_OBJECT, offsetof(PyOSErrorObject, winerror), 0, PyDoc_STR("Win32 exception code")}, #endif {NULL} /* Sentinel */ @@ -2249,7 +2249,7 @@ NameError_traverse(PyNameErrorObject *self, visitproc visit, void *arg) } static PyMemberDef NameError_members[] = { - {"name", T_OBJECT, offsetof(PyNameErrorObject, name), 0, PyDoc_STR("name")}, + {"name", _Py_T_OBJECT, offsetof(PyNameErrorObject, name), 0, PyDoc_STR("name")}, {NULL} /* Sentinel */ }; @@ -2368,8 +2368,8 @@ AttributeError_reduce(PyAttributeErrorObject *self, PyObject *Py_UNUSED(ignored) } static PyMemberDef AttributeError_members[] = { - {"name", T_OBJECT, offsetof(PyAttributeErrorObject, name), 0, PyDoc_STR("attribute name")}, - {"obj", T_OBJECT, offsetof(PyAttributeErrorObject, obj), 0, PyDoc_STR("object")}, + {"name", _Py_T_OBJECT, offsetof(PyAttributeErrorObject, name), 0, PyDoc_STR("attribute name")}, + {"obj", _Py_T_OBJECT, offsetof(PyAttributeErrorObject, obj), 0, PyDoc_STR("object")}, {NULL} /* Sentinel */ }; @@ -2541,21 +2541,21 @@ SyntaxError_str(PySyntaxErrorObject *self) } static PyMemberDef SyntaxError_members[] = { - {"msg", T_OBJECT, offsetof(PySyntaxErrorObject, msg), 0, + {"msg", _Py_T_OBJECT, offsetof(PySyntaxErrorObject, msg), 0, PyDoc_STR("exception msg")}, - {"filename", T_OBJECT, offsetof(PySyntaxErrorObject, filename), 0, + {"filename", _Py_T_OBJECT, offsetof(PySyntaxErrorObject, filename), 0, PyDoc_STR("exception filename")}, - {"lineno", T_OBJECT, offsetof(PySyntaxErrorObject, lineno), 0, + {"lineno", _Py_T_OBJECT, offsetof(PySyntaxErrorObject, lineno), 0, PyDoc_STR("exception lineno")}, - {"offset", T_OBJECT, offsetof(PySyntaxErrorObject, offset), 0, + {"offset", _Py_T_OBJECT, offsetof(PySyntaxErrorObject, offset), 0, PyDoc_STR("exception offset")}, - {"text", T_OBJECT, offsetof(PySyntaxErrorObject, text), 0, + {"text", _Py_T_OBJECT, offsetof(PySyntaxErrorObject, text), 0, PyDoc_STR("exception text")}, - {"end_lineno", T_OBJECT, offsetof(PySyntaxErrorObject, end_lineno), 0, + {"end_lineno", _Py_T_OBJECT, offsetof(PySyntaxErrorObject, end_lineno), 0, PyDoc_STR("exception end lineno")}, - {"end_offset", T_OBJECT, offsetof(PySyntaxErrorObject, end_offset), 0, + {"end_offset", _Py_T_OBJECT, offsetof(PySyntaxErrorObject, end_offset), 0, PyDoc_STR("exception end offset")}, - {"print_file_and_line", T_OBJECT, + {"print_file_and_line", _Py_T_OBJECT, offsetof(PySyntaxErrorObject, print_file_and_line), 0, PyDoc_STR("exception print_file_and_line")}, {NULL} /* Sentinel */ @@ -2910,15 +2910,15 @@ UnicodeError_traverse(PyUnicodeErrorObject *self, visitproc visit, void *arg) } static PyMemberDef UnicodeError_members[] = { - {"encoding", T_OBJECT, offsetof(PyUnicodeErrorObject, encoding), 0, + {"encoding", _Py_T_OBJECT, offsetof(PyUnicodeErrorObject, encoding), 0, PyDoc_STR("exception encoding")}, - {"object", T_OBJECT, offsetof(PyUnicodeErrorObject, object), 0, + {"object", _Py_T_OBJECT, offsetof(PyUnicodeErrorObject, object), 0, PyDoc_STR("exception object")}, - {"start", T_PYSSIZET, offsetof(PyUnicodeErrorObject, start), 0, + {"start", Py_T_PYSSIZET, offsetof(PyUnicodeErrorObject, start), 0, PyDoc_STR("exception start")}, - {"end", T_PYSSIZET, offsetof(PyUnicodeErrorObject, end), 0, + {"end", Py_T_PYSSIZET, offsetof(PyUnicodeErrorObject, end), 0, PyDoc_STR("exception end")}, - {"reason", T_OBJECT, offsetof(PyUnicodeErrorObject, reason), 0, + {"reason", _Py_T_OBJECT, offsetof(PyUnicodeErrorObject, reason), 0, PyDoc_STR("exception reason")}, {NULL} /* Sentinel */ }; |