gh-87347: Fix PyObject_NEW() regression (#94234)

Don't add parenthesis around the type parameter.

Add unit tests on PyObject_NEW() and similar functions.
This commit is contained in:
Victor Stinner 2022-06-26 12:40:17 +02:00 committed by GitHub
parent 17ed560fcd
commit 44c8e68b8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 2 deletions

View file

@ -135,14 +135,14 @@ PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
// Alias to PyObject_New(). In Python 3.8, PyObject_NEW() called directly
// PyObject_MALLOC() with _PyObject_SIZE().
#define PyObject_NEW(type, typeobj) PyObject_New((type), (typeobj))
#define PyObject_NEW(type, typeobj) PyObject_New(type, (typeobj))
#define PyObject_NewVar(type, typeobj, n) \
( (type *) _PyObject_NewVar((typeobj), (n)) )
// Alias to PyObject_NewVar(). In Python 3.8, PyObject_NEW_VAR() called
// directly PyObject_MALLOC() with _PyObject_VAR_SIZE().
#define PyObject_NEW_VAR(type, typeobj, n) PyObject_NewVar((type), (typeobj), (n))
#define PyObject_NEW_VAR(type, typeobj, n) PyObject_NewVar(type, (typeobj), (n))
/*