Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 23 additions & 26 deletions pythoncapi_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ extern "C" {
#if PY_VERSION_HEX < 0x030b00B4 && !defined(PYPY_VERSION)
# include "frameobject.h" // PyFrameObject, PyFrame_GetBack()
#endif
#if PY_VERSION_HEX < 0x030C00A3
# include <structmember.h> // T_SHORT, READONLY
#endif


#ifndef _Py_CAST
Expand Down Expand Up @@ -1919,33 +1916,33 @@ PyLongWriter_Finish(PyLongWriter *writer)


#if PY_VERSION_HEX < 0x030C00A3
# define Py_T_SHORT T_SHORT
# define Py_T_INT T_INT
# define Py_T_LONG T_LONG
# define Py_T_FLOAT T_FLOAT
# define Py_T_DOUBLE T_DOUBLE
# define Py_T_STRING T_STRING
# define _Py_T_OBJECT T_OBJECT
# define Py_T_CHAR T_CHAR
# define Py_T_BYTE T_BYTE
# define Py_T_UBYTE T_UBYTE
# define Py_T_USHORT T_USHORT
# define Py_T_UINT T_UINT
# define Py_T_ULONG T_ULONG
# define Py_T_STRING_INPLACE T_STRING_INPLACE
# define Py_T_BOOL T_BOOL
# define Py_T_OBJECT_EX T_OBJECT_EX
# define Py_T_LONGLONG T_LONGLONG
# define Py_T_ULONGLONG T_ULONGLONG
# define Py_T_PYSSIZET T_PYSSIZET
# define Py_T_SHORT 0
# define Py_T_INT 1
# define Py_T_LONG 2
# define Py_T_FLOAT 3
# define Py_T_DOUBLE 4
# define Py_T_STRING 5
# define _Py_T_OBJECT 6
# define Py_T_CHAR 7
# define Py_T_BYTE 8
# define Py_T_UBYTE 9
# define Py_T_USHORT 10
# define Py_T_UINT 11
# define Py_T_ULONG 12
# define Py_T_STRING_INPLACE 13
# define Py_T_BOOL 14
# define Py_T_OBJECT_EX 16
# define Py_T_LONGLONG 17
# define Py_T_ULONGLONG 18
# define Py_T_PYSSIZET 19

# if PY_VERSION_HEX >= 0x03000000 && !defined(PYPY_VERSION)
# define _Py_T_NONE T_NONE
# define _Py_T_NONE 20
# endif

# define Py_READONLY READONLY
# define Py_AUDIT_READ READ_RESTRICTED
# define _Py_WRITE_RESTRICTED PY_WRITE_RESTRICTED
# define Py_READONLY 1
# define Py_AUDIT_READ 2
# define _Py_WRITE_RESTRICTED 4
#endif


Expand Down
49 changes: 25 additions & 24 deletions tests/test_pythoncapi_compat_cext.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#undef NDEBUG

#include "pythoncapi_compat.h"
#include <structmember.h> // T_SHORT, READONLY

#ifdef NDEBUG
# error "assertions must be enabled"
Expand Down Expand Up @@ -2118,32 +2119,32 @@ test_long_stdint(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
static PyObject *
test_structmember(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
{
assert(Py_T_SHORT >= 0);
assert(Py_T_INT >= 0);
assert(Py_T_LONG >= 0);
assert(Py_T_FLOAT >= 0);
assert(Py_T_DOUBLE >= 0);
assert(Py_T_STRING >= 0);
assert(_Py_T_OBJECT >= 0);
assert(Py_T_CHAR >= 0);
assert(Py_T_BYTE >= 0);
assert(Py_T_UBYTE >= 0);
assert(Py_T_USHORT >= 0);
assert(Py_T_UINT >= 0);
assert(Py_T_ULONG >= 0);
assert(Py_T_STRING_INPLACE >= 0);
assert(Py_T_BOOL >= 0);
assert(Py_T_OBJECT_EX >= 0);
assert(Py_T_LONGLONG >= 0);
assert(Py_T_ULONGLONG >= 0);
assert(Py_T_PYSSIZET >= 0);
assert(Py_T_SHORT == T_SHORT);
assert(Py_T_SHORT == T_SHORT);
assert(Py_T_INT == T_INT);
assert(Py_T_LONG == T_LONG);
assert(Py_T_FLOAT == T_FLOAT);
assert(Py_T_DOUBLE == T_DOUBLE);
assert(Py_T_STRING == T_STRING);
assert(_Py_T_OBJECT == T_OBJECT);
assert(Py_T_CHAR == T_CHAR);
assert(Py_T_BYTE == T_BYTE);
assert(Py_T_UBYTE == T_UBYTE);
assert(Py_T_USHORT == T_USHORT);
assert(Py_T_UINT == T_UINT);
assert(Py_T_ULONG == T_ULONG);
assert(Py_T_STRING_INPLACE == T_STRING_INPLACE);
assert(Py_T_BOOL == T_BOOL);
assert(Py_T_OBJECT_EX == T_OBJECT_EX);
assert(Py_T_LONGLONG == T_LONGLONG);
assert(Py_T_ULONGLONG == T_ULONGLONG);
assert(Py_T_PYSSIZET == T_PYSSIZET);
#if PY_VERSION_HEX >= 0x03000000 && !defined(PYPY_VERSION)
assert(_Py_T_NONE >= 0);
assert(_Py_T_NONE == T_NONE);
#endif

assert(Py_READONLY >= 0);
assert(Py_AUDIT_READ >= 0);
assert(_Py_WRITE_RESTRICTED >= 0);
assert(Py_READONLY == READONLY);
assert(Py_AUDIT_READ == READ_RESTRICTED);
assert(_Py_WRITE_RESTRICTED == PY_WRITE_RESTRICTED);

Py_RETURN_NONE;
}
Expand Down