E574 Rename new macros to conform to naming rules (function macros have "P… · python/cpython@4cb0de2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4cb0de2

Browse files
committed
Rename new macros to conform to naming rules (function macros have "Py" prefix, not "PY").
1 parent 5ce1b0d commit 4cb0de2

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

Include/Python.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
160160
#define PyDoc_STR(str) ""
161161
#endif
162162

163-
#define PY_ARRAY_LENGTH(array) (sizeof(array) / sizeof((array)[0]))
163+
#define Py_ARRAY_LENGTH(array) (sizeof(array) / sizeof((array)[0]))
164164

165-
#define PY_MIN(x, y) (((x) > (y)) ? (y) : (x))
166-
#define PY_MAX(x, y) (((x) > (y)) ? (x) : (y))
165+
#define Py_MIN(x, y) (((x) > (y)) ? (y) : (x))
166+
#define Py_MAX(x, y) (((x) > (y)) ? (x) : (y))
167167

168168
#endif /* !Py_PYTHON_H */

Modules/arraymodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2810,7 +2810,7 @@ PyMODINIT_FUNC
28102810
PyInit_array(void)
28112811
{
28122812
PyObject *m;
2813-
char buffer[PY_ARRAY_LENGTH(descriptors)], *p;
2813+
char buffer[Py_ARRAY_LENGTH(descriptors)], *p;
28142814
PyObject *typecodes;
28152815
Py_ssize_t size = 0;
28162816
struct arraydescr *descr;

Modules/zipimport.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ zipimporter_init(ZipImporter *self, PyObject *args, PyObject *kwds)
8888
"archive path too long");
8989
goto error;
9090
}
91-
if (!PyUnicode_AsUCS4(pathobj, buf, PY_ARRAY_LENGTH(buf), 1))
91+
if (!PyUnicode_AsUCS4(pathobj, buf, Py_ARRAY_LENGTH(buf), 1))
9292
goto error;
9393

9494
#ifdef ALTSEP
@@ -473,7 +473,7 @@ zipimporter_get_data(PyObject *obj, PyObject *args)
473473
PyErr_SetString(ZipImportError, "path too long");
474474
return NULL;
475475
}
476-
if (!PyUnicode_AsUCS4(pathobj, buf, PY_ARRAY_LENGTH(buf), 1))
476+
if (!PyUnicode_AsUCS4(pathobj, buf, Py_ARRAY_LENGTH(buf), 1))
477477
return NULL;
478478
path = buf;
479479
#ifdef ALTSEP
@@ -484,7 +484,7 @@ zipimporter_get_data(PyObject *obj, PyObject *args)
484484
#endif
485485
len = PyUnicode_GET_LENGTH(self->archive);
486486
if ((size_t)len < Py_UCS4_strlen(path)) {
487-
if (!PyUnicode_AsUCS4(self->archive, archive, PY_ARRAY_LENGTH(archive), 1))
487+
if (!PyUnicode_AsUCS4(self->archive, archive, Py_ARRAY_LENGTH(archive), 1))
488488
return NULL;
489489
if (Py_UCS4_strncmp(path, archive, len) == 0 &&
490490
path[len] == SEP) {
@@ -771,7 +771,7 @@ read_directory(PyObject *archive)
771771
"Zip path name is too long");
772772
return NULL;
773773
}
774-
if (!PyUnicode_AsUCS4(archive, path, PY_ARRAY_LENGTH(path), 1))
774+
if (!PyUnicode_AsUCS4(archive, path, Py_ARRAY_LENGTH(path), 1))
775775
return NULL;
776776

777777
fp = _Py_fopen(archive, "rb");

Objects/unicodeobject.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
15211521
case 'c':
15221522
{
15231523
Py_UCS4 ordinal = va_arg(count, int);
1524-
maxchar = PY_MAX(maxchar, ordinal);
1524+
maxchar = Py_MAX(maxchar, ordinal);
15251525
n++;
15261526
break;
15271527
}
@@ -1617,7 +1617,7 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
16171617
/* since PyUnicode_DecodeUTF8 returns already flexible
16181618
unicode objects, there is no need to call ready on them */
16191619
argmaxchar = PyUnicode_MAX_CHAR_VALUE(str);
1620-
maxchar = PY_MAX(maxchar, argmaxchar);
1620+
maxchar = Py_MAX(maxchar, argmaxchar);
16211621
n += PyUnicode_GET_LENGTH(str);
16221622
/* Remember the str and switch to the next slot */
16231623
*callresult++ = str;
@@ -1630,7 +1630,7 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
16301630
if (PyUnicode_READY(obj) == -1)
16311631
goto fail;
16321632
argmaxchar = PyUnicode_MAX_CHAR_VALUE(obj);
1633-
maxchar = PY_MAX(maxchar, argmaxchar);
1633+
maxchar = Py_MAX(maxchar, argmaxchar);
16341634
n += PyUnicode_GET_LENGTH(obj);
16351635
break;
16361636
}
@@ -1645,7 +1645,7 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
16451645
if (PyUnicode_READY(obj) == -1)
16461646
goto fail;
16471647
argmaxchar = PyUnicode_MAX_CHAR_VALUE(obj);
1648-
maxchar = PY_MAX(maxchar, argmaxchar);
1648+
maxchar = Py_MAX(maxchar, argmaxchar);
16491649
n += PyUnicode_GET_LENGTH(obj);
16501650
*callresult++ = NULL;
16511651
}
@@ -1654,7 +1654,7 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
16541654
if (!str_obj)
16551655
goto fail;
16561656
argmaxchar = PyUnicode_MAX_CHAR_VALUE(str_obj);
1657-
maxchar = PY_MAX(maxchar, argmaxchar);
1657+
maxchar = Py_MAX(maxchar, argmaxchar);
16581658
n += PyUnicode_GET_LENGTH(str_obj);
16591659
*callresult++ = str_obj;
16601660
}
@@ -1669,7 +1669,7 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
16691669
if (!str || PyUnicode_READY(str) == -1)
16701670
goto fail;
16711671
argmaxchar = PyUnicode_MAX_CHAR_VALUE(str);
1672-
maxchar = PY_MAX(maxchar, argmaxchar);
1672+
maxchar = Py_MAX(maxchar, argmaxchar);
16731673
n += PyUnicode_GET_LENGTH(str);
16741674
/* Remember the str and switch to the next slot */
16751675
*callresult++ = str;
@@ -1684,7 +1684,7 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
16841684
if (!repr || PyUnicode_READY(repr) == -1)
16851685
goto fail;
16861686
argmaxchar = PyUnicode_MAX_CHAR_VALUE(repr);
1687-
maxchar = PY_MAX(maxchar, argmaxchar);
1687+
maxchar = Py_MAX(maxchar, argmaxchar);
16881688
n += PyUnicode_GET_LENGTH(repr);
16891689
/* Remember the repr and switch to the next slot */
16901690
*callresult++ = repr;
@@ -1699,7 +1699,7 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
16991699
if (!ascii || PyUnicode_READY(ascii) == -1)
17001700
goto fail;
17011701
argmaxchar = PyUnicode_MAX_CHAR_VALUE(ascii);
1702-
maxchar = PY_MAX(maxchar, argmaxchar);
1702+
maxchar = Py_MAX(maxchar, argmaxchar);
17031703
n += PyUnicode_GET_LENGTH(ascii);
17041704
/* Remember the repr and switch to the next slot */
17051705
*callresult++ = ascii;
@@ -11051,7 +11051,7 @@ PyUnicode_RPartition(PyObject *str_in, PyObject *sep_in)
1105111051

1105211052
kind1 = PyUnicode_KIND(str_in);
1105311053
kind2 = PyUnicode_KIND(sep_obj);
11054-
kind = PY_MAX(kind1, kind2);
11054+
kind = Py_MAX(kind1, kind2);
1105511055
buf1 = PyUnicode_DATA(str_in);
1105611056
if (kind1 != kind)
1105711057
buf1 = _PyUnicode_AsKind(str_in, kind);

Python/import.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,7 @@ find_module_path(PyObject *fullname, PyObject *name, PyObject *path,
17841784
return 0;
17851785

17861786
len = PyUnicode_GET_LENGTH(path_unicode);
1787-
if (!PyUnicode_AsUCS4(path_unicode, buf, PY_ARRAY_LENGTH(buf), 1)) {
1787+
if (!PyUnicode_AsUCS4(path_unicode, buf, Py_ARRAY_LENGTH(buf), 1)) {
17881788
Py_DECREF(path_unicode);
17891789
PyErr_Clear();
17901790
return 0;
@@ -1828,7 +1828,7 @@ find_module_path(PyObject *fullname, PyObject *name, PyObject *path,
18281828
#endif
18291829
)
18301830
buf[len++] = SEP;
1831-
if (!PyUnicode_AsUCS4(name, buf+len, PY_ARRAY_LENGTH(buf)-len, 1)) {
1831+
if (!PyUnicode_AsUCS4(name, buf+len, Py_ARRAY_LENGTH(buf)-len, 1)) {
18321832
PyErr_Clear();
18331833
return 0;
18341834
}
@@ -2787,7 +2787,7 @@ import_module_level(PyObject *name, PyObject *globals, PyObject *locals,
27872787
if (PyUnicode_READY(parent_name))
27882788
return NULL;
27892789
buflen = PyUnicode_GET_LENGTH(parent_name);
2790-
if (!PyUnicode_AsUCS4(parent_name, buf, PY_ARRAY_LENGTH(buf), 1)) {
2790+
if (!PyUnicode_AsUCS4(parent_name, buf, Py_ARRAY_LENGTH(b 48FB uf), 1)) {
27912791
Py_DECREF(parent_name);
27922792
PyErr_SetString(PyExc_ValueError,
27932793
"Module name too long");

0 commit comments

Comments
 (0)
0