Skip to content

Commit be0d500

Browse files
GH-90699: Remove remaining _Py_IDENTIFIER stdlib usage (GH-99067)
1 parent 1438b77 commit be0d500

7 files changed

+110
-53
lines changed

Include/internal/pycore_global_strings.h

+13-5
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ extern "C" {
1111
// The data structure & init here are inspired by Tools/build/deepfreeze.py.
1212

1313
// All field names generated by ASCII_STR() have a common prefix,
14-
// to help avoid collisions with keywords, etc.
14+
// to help avoid collisions with keywords, macros, etc.
1515

1616
#define STRUCT_FOR_ASCII_STR(LITERAL) \
1717
struct { \
1818
PyASCIIObject _ascii; \
1919
uint8_t _data[sizeof(LITERAL)]; \
2020
}
2121
#define STRUCT_FOR_STR(NAME, LITERAL) \
22-
STRUCT_FOR_ASCII_STR(LITERAL) _ ## NAME;
22+
STRUCT_FOR_ASCII_STR(LITERAL) _py_ ## NAME;
2323
#define STRUCT_FOR_ID(NAME) \
24-
STRUCT_FOR_ASCII_STR(#NAME) _ ## NAME;
24+
STRUCT_FOR_ASCII_STR(#NAME) _py_ ## NAME;
2525

2626
// XXX Order by frequency of use?
2727

@@ -246,6 +246,7 @@ struct _Py_global_strings {
246246
STRUCT_FOR_ID(_showwarnmsg)
247247
STRUCT_FOR_ID(_shutdown)
248248
STRUCT_FOR_ID(_slotnames)
249+
STRUCT_FOR_ID(_strptime_datetime)
249250
STRUCT_FOR_ID(_swappedbytes_)
250251
STRUCT_FOR_ID(_type_)
251252
STRUCT_FOR_ID(_uninitialized_submodules)
@@ -264,6 +265,7 @@ struct _Py_global_strings {
264265
STRUCT_FOR_ID(argdefs)
265266
STRUCT_FOR_ID(arguments)
266267
STRUCT_FOR_ID(argv)
268+
STRUCT_FOR_ID(as_integer_ratio)
267269
STRUCT_FOR_ID(attribute)
268270
STRUCT_FOR_ID(authorizer_callback)
269271
STRUCT_FOR_ID(b)
@@ -403,6 +405,8 @@ struct _Py_global_strings {
403405
STRUCT_FOR_ID(frequency)
404406
STRUCT_FOR_ID(from_param)
405407
STRUCT_FOR_ID(fromlist)
408+
STRUCT_FOR_ID(fromtimestamp)
409+
STRUCT_FOR_ID(fromutc)
406410
STRUCT_FOR_ID(fset)
407411
STRUCT_FOR_ID(func)
408412
STRUCT_FOR_ID(future)
@@ -448,6 +452,7 @@ struct _Py_global_strings {
448452
STRUCT_FOR_ID(intersection)
449453
STRUCT_FOR_ID(isatty)
450454
STRUCT_FOR_ID(isinstance)
455+
STRUCT_FOR_ID(isoformat)
451456
STRUCT_FOR_ID(isolation_level)
452457
STRUCT_FOR_ID(istext)
453458
STRUCT_FOR_ID(item)
@@ -636,6 +641,7 @@ struct _Py_global_strings {
636641
STRUCT_FOR_ID(step)
637642
STRUCT_FOR_ID(store_name)
638643
STRUCT_FOR_ID(strategy)
644+
STRUCT_FOR_ID(strftime)
639645
STRUCT_FOR_ID(strict)
640646
STRUCT_FOR_ID(strict_mode)
641647
STRUCT_FOR_ID(string)
@@ -658,6 +664,7 @@ struct _Py_global_strings {
658664
STRUCT_FOR_ID(throw)
659665
STRUCT_FOR_ID(timeout)
660666
STRUCT_FOR_ID(times)
667+
STRUCT_FOR_ID(timetuple)
661668
STRUCT_FOR_ID(top)
662669
STRUCT_FOR_ID(trace_callback)
663670
STRUCT_FOR_ID(traceback)
@@ -669,6 +676,7 @@ struct _Py_global_strings {
669676
STRUCT_FOR_ID(txt)
670677
STRUCT_FOR_ID(type)
671678
STRUCT_FOR_ID(tz)
679+
STRUCT_FOR_ID(tzname)
672680
STRUCT_FOR_ID(uid)
673681
STRUCT_FOR_ID(unlink)
674682
STRUCT_FOR_ID(unraisablehook)
@@ -708,9 +716,9 @@ struct _Py_global_strings {
708716

709717

710718
#define _Py_ID(NAME) \
711-
(_Py_SINGLETON(strings.identifiers._ ## NAME._ascii.ob_base))
719+
(_Py_SINGLETON(strings.identifiers._py_ ## NAME._ascii.ob_base))
712720
#define _Py_STR(NAME) \
713-
(_Py_SINGLETON(strings.literals._ ## NAME._ascii.ob_base))
721+
(_Py_SINGLETON(strings.literals._py_ ## NAME._ascii.ob_base))
714722

715723
/* _Py_DECLARE_STR() should precede all uses of _Py_STR() in a function.
716724

Include/internal/pycore_runtime_init.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ extern "C" {
110110
._data = (LITERAL) \
111111
}
112112
#define INIT_STR(NAME, LITERAL) \
113-
._ ## NAME = _PyASCIIObject_INIT(LITERAL)
113+
._py_ ## NAME = _PyASCIIObject_INIT(LITERAL)
114114
#define INIT_ID(NAME) \
115-
._ ## NAME = _PyASCIIObject_INIT(#NAME)
115+
._py_ ## NAME = _PyASCIIObject_INIT(#NAME)
116116
#define _PyUnicode_LATIN1_INIT(LITERAL, UTF8) \
117117
{ \
118118
._latin1 = { \

Include/internal/pycore_runtime_init_generated.h

+56
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)