mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
bpo-40989: PyObject_INIT() becomes an alias to PyObject_Init() (GH-20901)
The PyObject_INIT() and PyObject_INIT_VAR() macros become aliases to, respectively, PyObject_Init() and PyObject_InitVar() functions. Rename _PyObject_INIT() and _PyObject_INIT_VAR() static inline functions to, respectively, _PyObject_Init() and _PyObject_InitVar(), and move them to pycore_object.h. Remove their return value: their return type becomes void. The _datetime module is now built with the Py_BUILD_CORE_MODULE macro defined. Remove an outdated comment on _Py_tracemalloc_config.
This commit is contained in:
parent
7ab92d54b5
commit
04fc4f2a46
17 changed files with 113 additions and 117 deletions
|
@ -8,6 +8,7 @@
|
|||
#define _PY_DATETIME_IMPL
|
||||
|
||||
#include "Python.h"
|
||||
#include "pycore_object.h" // _PyObject_Init()
|
||||
#include "datetime.h"
|
||||
#include "structmember.h" // PyMemberDef
|
||||
|
||||
|
@ -638,30 +639,24 @@ normalize_datetime(int *year, int *month, int *day,
|
|||
static PyObject *
|
||||
time_alloc(PyTypeObject *type, Py_ssize_t aware)
|
||||
{
|
||||
PyObject *self;
|
||||
|
||||
self = (PyObject *)
|
||||
PyObject_MALLOC(aware ?
|
||||
sizeof(PyDateTime_Time) :
|
||||
sizeof(_PyDateTime_BaseTime));
|
||||
if (self == NULL)
|
||||
return (PyObject *)PyErr_NoMemory();
|
||||
(void)PyObject_INIT(self, type);
|
||||
size_t size = aware ? sizeof(PyDateTime_Time) : sizeof(_PyDateTime_BaseTime);
|
||||
PyObject *self = (PyObject *)PyObject_Malloc(size);
|
||||
if (self == NULL) {
|
||||
return PyErr_NoMemory();
|
||||
}
|
||||
_PyObject_Init(self, type);
|
||||
return self;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
datetime_alloc(PyTypeObject *type, Py_ssize_t aware)
|
||||
{
|
||||
PyObject *self;
|
||||
|
||||
self = (PyObject *)
|
||||
PyObject_MALLOC(aware ?
|
||||
sizeof(PyDateTime_DateTime) :
|
||||
sizeof(_PyDateTime_BaseDateTime));
|
||||
if (self == NULL)
|
||||
return (PyObject *)PyErr_NoMemory();
|
||||
(void)PyObject_INIT(self, type);
|
||||
size_t size = aware ? sizeof(PyDateTime_DateTime) : sizeof(_PyDateTime_BaseDateTime);
|
||||
PyObject *self = (PyObject *)PyObject_Malloc(size);
|
||||
if (self == NULL) {
|
||||
return PyErr_NoMemory();
|
||||
}
|
||||
_PyObject_Init(self, type);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue