Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Merge branch 'main' into pymodule-add4b
  • Loading branch information
serhiy-storchaka committed Jul 18, 2023
commit 63fa1ba9bbdf2479436ff3c4121249131c04e03c
1 change: 0 additions & 1 deletion Include/internal/pycore_modsupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ extern PyObject ** _Py_VaBuildStack(
Py_ssize_t *p_nargs);

extern PyObject* _PyModule_CreateInitialized(PyModuleDef*, int apiver);
PyAPI_FUNC(int) _PyModule_AddNew(PyObject *, const char *, PyObject *);

#ifdef __cplusplus
}
Expand Down
9 changes: 4 additions & 5 deletions Modules/_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#define OPENSSL_NO_DEPRECATED 1

#include "Python.h"
#include "pycore_modsupport.h" // _PyModule_AddNew()
#include "pycore_weakref.h" // _PyWeakref_GET_REF()

/* Include symbols from _socket module */
Expand Down Expand Up @@ -6119,22 +6118,22 @@ sslmodule_init_versioninfo(PyObject *m)
*/
libver = OpenSSL_version_num();
r = PyLong_FromUnsignedLong(libver);
if (_PyModule_AddNew(m, "OPENSSL_VERSION_NUMBER", r) < 0)
if (PyModule_Add(m, "OPENSSL_VERSION_NUMBER", r) < 0)
return -1;

parse_openssl_version(libver, &major, &minor, &fix, &patch, &status);
r = Py_BuildValue("IIIII", major, minor, fix, patch, status);
if (_PyModule_AddNew(m, "OPENSSL_VERSION_INFO", r) < 0)
if (PyModule_Add(m, "OPENSSL_VERSION_INFO", r) < 0)
return -1;

r = PyUnicode_FromString(OpenSSL_version(OPENSSL_VERSION));
if (_PyModule_AddNew(m, "OPENSSL_VERSION", r) < 0)
if (PyModule_Add(m, "OPENSSL_VERSION", r) < 0)
return -1;

libver = OPENSSL_VERSION_NUMBER;
parse_openssl_version(libver, &major, &minor, &fix, &patch, &status);
r = Py_BuildValue("IIIII", major, minor, fix, patch, status);
if (_PyModule_AddNew(m, "_OPENSSL_API_VERSION", r) < 0)
if (PyModule_Add(m, "_OPENSSL_API_VERSION", r) < 0)
return -1;

return 0;
Expand Down
11 changes: 3 additions & 8 deletions Modules/_stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
*
*/

#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include "pycore_modsupport.h" // _PyModule_AddNew()

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -596,15 +591,15 @@ stat_exec(PyObject *module)
ADD_INT_MACRO(module, FILE_ATTRIBUTE_TEMPORARY);
ADD_INT_MACRO(module, FILE_ATTRIBUTE_VIRTUAL);

if (_PyModule_AddNew(module, "IO_REPARSE_TAG_SYMLINK",
if (PyModule_Add(module, "IO_REPARSE_TAG_SYMLINK",
PyLong_FromUnsignedLong(IO_REPARSE_TAG_SYMLINK)) < 0) {
return -1;
}
if (_PyModule_AddNew(module, "IO_REPARSE_TAG_MOUNT_POINT",
if (PyModule_Add(module, "IO_REPARSE_TAG_MOUNT_POINT",
PyLong_FromUnsignedLong(IO_REPARSE_TAG_MOUNT_POINT)) < 0) {
return -1;
}
if (_PyModule_AddNew(module, "IO_REPARSE_TAG_APPEXECLINK",
if (PyModule_Add(module, "IO_REPARSE_TAG_APPEXECLINK",
PyLong_FromUnsignedLong(IO_REPARSE_TAG_APPEXECLINK)) < 0) {
return -1;
}
Expand Down
5 changes: 2 additions & 3 deletions Modules/_testinternalcapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "pycore_hashtable.h" // _Py_hashtable_new()
#include "pycore_initconfig.h" // _Py_GetConfigsAsDict()
#include "pycore_interp.h" // _PyInterpreterState_GetConfigCopy()
#include "pycore_modsupport.h" // _PyModule_AddNew()
#include "pycore_pathconfig.h" // _PyPathConfig_ClearGlobal()
#include "pycore_pyerrors.h" // _Py_UTF8_Edit_Cost()
#include "pycore_pystate.h" // _PyThreadState_GET()
Expand Down Expand Up @@ -1512,12 +1511,12 @@ static PyMethodDef module_functions[] = {
static int
module_exec(PyObject *module)
{
if (_PyModule_AddNew(module, "SIZEOF_PYGC_HEAD",
if (PyModule_Add(module, "SIZEOF_PYGC_HEAD",
PyLong_FromSsize_t(sizeof(PyGC_Head))) < 0) {
return 1;
}

if (_PyModule_AddNew(module, "SIZEOF_TIME_T",
if (PyModule_Add(module, "SIZEOF_TIME_T",
PyLong_FromSsize_t(sizeof(time_t))) < 0) {
return 1;
}
Expand Down
3 changes: 1 addition & 2 deletions Modules/_threadmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "Python.h"
#include "pycore_interp.h" // _PyInterpreterState.threads.count
#include "pycore_modsupport.h" // _PyModule_AddNew()
#include "pycore_moduleobject.h" // _PyModule_GetState()
#include "pycore_pylifecycle.h"
#include "pycore_pystate.h" // _PyThreadState_SetCurrent()
Expand Down Expand Up @@ -1672,7 +1671,7 @@ thread_module_exec(PyObject *module)
// Round towards minus infinity
timeout_max = floor(timeout_max);

if (_PyModule_AddNew(module, "TIMEOUT_MAX",
if (PyModule_Add(module, "TIMEOUT_MAX",
PyFloat_FromDouble(timeout_max)) < 0) {
return -1;
}
Expand Down
15 changes: 7 additions & 8 deletions Modules/cmathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "Python.h"
#include "pycore_complexobject.h" // _Py_c_neg()
#include "pycore_modsupport.h" // _PyModule_AddNew()
#include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR
/* we need DBL_MAX, DBL_MIN, DBL_EPSILON, DBL_MANT_DIG and FLT_RADIX from
float.h. We assume that FLT_RADIX is either 2 or 16. */
Expand Down Expand Up @@ -1218,29 +1217,29 @@ static PyMethodDef cmath_methods[] = {
static int
cmath_exec(PyObject *mod)
{
if (_PyModule_AddNew(mod, "pi", PyFloat_FromDouble(Py_MATH_PI)) < 0) {
if (PyModule_Add(mod, "pi", PyFloat_FromDouble(Py_MATH_PI)) < 0) {
return -1;
}
if (_PyModule_AddNew(mod, "e", PyFloat_FromDouble(Py_MATH_E)) < 0) {
if (PyModule_Add(mod, "e", PyFloat_FromDouble(Py_MATH_E)) < 0) {
return -1;
}
// 2pi
if (_PyModule_AddNew(mod, "tau", PyFloat_FromDouble(Py_MATH_TAU)) < 0) {
if (PyModule_Add(mod, "tau", PyFloat_FromDouble(Py_MATH_TAU)) < 0) {
return -1;
}
if (_PyModule_AddNew(mod, "inf", PyFloat_FromDouble(Py_INFINITY)) < 0) {
if (PyModule_Add(mod, "inf", PyFloat_FromDouble(Py_INFINITY)) < 0) {
return -1;
}

Py_complex infj = {0.0, Py_INFINITY};
if (_PyModule_AddNew(mod, "infj", PyComplex_FromCComplex(infj)) < 0) {
if (PyModule_Add(mod, "infj", PyComplex_FromCComplex(infj)) < 0) {
return -1;
}
if (_PyModule_AddNew(mod, "nan", PyFloat_FromDouble(fabs(Py_NAN))) < 0) {
if (PyModule_Add(mod, "nan", PyFloat_FromDouble(fabs(Py_NAN))) < 0) {
return -1;
}
Py_complex nanj = {0.0, fabs(Py_NAN)};
if (_PyModule_AddNew(mod, "nanj", PyComplex_FromCComplex(nanj)) < 0) {
if (PyModule_Add(mod, "nanj", PyComplex_FromCComplex(nanj)) < 0) {
return -1;
}

Expand Down
11 changes: 5 additions & 6 deletions Modules/mathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ raised for division by zero and mod by zero.
#include "pycore_bitutils.h" // _Py_bit_length()
#include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_long.h" // _PyLong_GetZero()
#include "pycore_modsupport.h" // _PyModule_AddNew()
#include "pycore_moduleobject.h" // _PyModule_GetState()
#include "pycore_object.h" // _PyObject_LookupSpecial()
#include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR
Expand Down Expand Up @@ -4038,20 +4037,20 @@ math_exec(PyObject *module)
if (state->str___trunc__ == NULL) {
return -1;
}
if (_PyModule_AddNew(module, "pi", PyFloat_FromDouble(Py_MATH_PI)) < 0) {
if (PyModule_Add(module, "pi", PyFloat_FromDouble(Py_MATH_PI)) < 0) {
return -1;
}
if (_PyModule_AddNew(module, "e", PyFloat_FromDouble(Py_MATH_E)) < 0) {
if (PyModule_Add(module, "e", PyFloat_FromDouble(Py_MATH_E)) < 0) {
return -1;
}
// 2pi
if (_PyModule_AddNew(module, "tau", PyFloat_FromDouble(Py_MATH_TAU)) < 0) {
if (PyModule_Add(module, "tau", PyFloat_FromDouble(Py_MATH_TAU)) < 0) {
return -1;
}
if (_PyModule_AddNew(module, "inf", PyFloat_FromDouble(Py_INFINITY)) < 0) {
if (PyModule_Add(module, "inf", PyFloat_FromDouble(Py_INFINITY)) < 0) {
return -1;
}
if (_PyModule_AddNew(module, "nan", PyFloat_FromDouble(fabs(Py_NAN))) < 0) {
if (PyModule_Add(module, "nan", PyFloat_FromDouble(fabs(Py_NAN))) < 0) {
return -1;
}
return 0;
Expand Down
7 changes: 3 additions & 4 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "pycore_fileutils.h" // _Py_closerange()
#include "pycore_import.h" // _PyImport_ReInitLock()
#include "pycore_initconfig.h" // _PyStatus_EXCEPTION()
#include "pycore_modsupport.h" // _PyModule_AddNew()
#include "pycore_moduleobject.h" // _PyModule_GetState()
#include "pycore_object.h" // _PyObject_LookupSpecial()
#include "pycore_pylifecycle.h" // _PyOS_URandom()
Expand Down Expand Up @@ -13467,7 +13466,7 @@ setup_confname_table(struct constdef *table, size_t tablesize,
}
Py_DECREF(o);
}
return _PyModule_AddNew(module, tablename, d);
return PyModule_Add(module, tablename, d);
}

/* Return -1 on failure, 0 on success. */
Expand Down Expand Up @@ -16782,7 +16781,7 @@ posixmodule_exec(PyObject *m)
#endif

/* Initialize environ dictionary */
if (_PyModule_AddNew(m, "environ", convertenviron()) != 0) {
if (PyModule_Add(m, "environ", convertenviron()) != 0) {
return -1;
}

Expand Down Expand Up @@ -16899,7 +16898,7 @@ posixmodule_exec(PyObject *m)
Py_DECREF(unicode);
}

return _PyModule_AddNew(m, "_have_functions", list);
return PyModule_Add(m, "_have_functions", list);
}


Expand Down
5 changes: 2 additions & 3 deletions Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "Python.h"
#include "pycore_fileutils.h" // _Py_BEGIN_SUPPRESS_IPH
#include "pycore_modsupport.h" // _PyModule_AddNew()
#include "pycore_moduleobject.h" // _PyModule_GetState()
#include "pycore_namespace.h" // _PyNamespace_New()
#include "pycore_runtime.h" // _Py_ID()
Expand Down Expand Up @@ -1791,7 +1790,7 @@ init_timezone(PyObject *m)
return -1;
}
#endif // MS_WINDOWS
if (_PyModule_AddNew(m, "tzname", Py_BuildValue("(NN)", otz0, otz1)) < 0) {
if (PyModule_Add(m, "tzname", Py_BuildValue("(NN)", otz0, otz1)) < 0) {
return -1;
}
#else // !HAVE_DECL_TZNAME
Expand Down Expand Up @@ -1836,7 +1835,7 @@ init_timezone(PyObject *m)
PyModule_AddIntConstant(m, "daylight", janzone != julyzone);
tzname_obj = Py_BuildValue("(zz)", janname, julyname);
}
if (_PyModule_AddNew(m, "tzname", tzname_obj) < 0) {
if (PyModule_Add(m, "tzname", tzname_obj) < 0) {
return -1;
}
#endif // !HAVE_DECL_TZNAME
Expand Down
7 changes: 3 additions & 4 deletions Python/modsupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "Python.h"
#include "pycore_abstract.h" // _PyIndex_Check()
#include "pycore_modsupport.h"
#include "pycore_object.h" // _PyType_IsReady()

typedef double va_double;
Expand Down Expand Up @@ -611,7 +610,7 @@ PyModule_AddObjectRef(PyObject *mod, const char *name, PyObject *value)
}

int
_PyModule_AddNew(PyObject *mod, const char *name, PyObject *value)
PyModule_Add(PyObject *mod, const char *name, PyObject *value)
{
int res = PyModule_AddObjectRef(mod, name, value);
Py_XDECREF(value);
Expand All @@ -631,13 +630,13 @@ PyModule_AddObject(PyObject *mod, const char *name, PyObject *value)
int
PyModule_AddIntConstant(PyObject *m, const char *name, long value)
{
return _PyModule_AddNew(m, name, PyLong_FromLong(value));
return PyModule_Add(m, name, PyLong_FromLong(value));
}

int
PyModule_AddStringConstant(PyObject *m, const char *name, const char *value)
{
return _PyModule_AddNew(m, name, PyUnicode_FromString(value));
return PyModule_Add(m, name, PyUnicode_FromString(value));
}

int
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.