Skip to content

Commit 8435a22

Browse files
authored
pythongh-141376: Fix exported symbols (pythonGH-141377)
* pythongh-141376: Fix exported symbols * _io module: add "_Py_" prefix to "spec" variables. For example, rename bufferedrandom_spec to _Py_bufferedrandom_spec. * typevarobject.c: add "static" to "spec" and "slots" variables. * import.c: add "static" to "pkgcontext" variable. * No longer export textiowrapper_slots
1 parent 92741c5 commit 8435a22

File tree

11 files changed

+55
-55
lines changed

11 files changed

+55
-55
lines changed

Modules/_io/_iomodule.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -681,40 +681,40 @@ iomodule_exec(PyObject *m)
681681
}
682682

683683
// Base classes
684-
ADD_TYPE(m, state->PyIncrementalNewlineDecoder_Type, &nldecoder_spec, NULL);
685-
ADD_TYPE(m, state->PyBytesIOBuffer_Type, &bytesiobuf_spec, NULL);
686-
ADD_TYPE(m, state->PyIOBase_Type, &iobase_spec, NULL);
684+
ADD_TYPE(m, state->PyIncrementalNewlineDecoder_Type, &_Py_nldecoder_spec, NULL);
685+
ADD_TYPE(m, state->PyBytesIOBuffer_Type, &_Py_bytesiobuf_spec, NULL);
686+
ADD_TYPE(m, state->PyIOBase_Type, &_Py_iobase_spec, NULL);
687687

688688
// PyIOBase_Type subclasses
689-
ADD_TYPE(m, state->PyTextIOBase_Type, &textiobase_spec,
689+
ADD_TYPE(m, state->PyTextIOBase_Type, &_Py_textiobase_spec,
690690
state->PyIOBase_Type);
691-
ADD_TYPE(m, state->PyBufferedIOBase_Type, &bufferediobase_spec,
691+
ADD_TYPE(m, state->PyBufferedIOBase_Type, &_Py_bufferediobase_spec,
692692
state->PyIOBase_Type);
693-
ADD_TYPE(m, state->PyRawIOBase_Type, &rawiobase_spec,
693+
ADD_TYPE(m, state->PyRawIOBase_Type, &_Py_rawiobase_spec,
694694
state->PyIOBase_Type);
695695

696696
// PyBufferedIOBase_Type(PyIOBase_Type) subclasses
697-
ADD_TYPE(m, state->PyBytesIO_Type, &bytesio_spec, state->PyBufferedIOBase_Type);
698-
ADD_TYPE(m, state->PyBufferedWriter_Type, &bufferedwriter_spec,
697+
ADD_TYPE(m, state->PyBytesIO_Type, &_Py_bytesio_spec, state->PyBufferedIOBase_Type);
698+
ADD_TYPE(m, state->PyBufferedWriter_Type, &_Py_bufferedwriter_spec,
699699
state->PyBufferedIOBase_Type);
700-
ADD_TYPE(m, state->PyBufferedReader_Type, &bufferedreader_spec,
700+
ADD_TYPE(m, state->PyBufferedReader_Type, &_Py_bufferedreader_spec,
701701
state->PyBufferedIOBase_Type);
702-
ADD_TYPE(m, state->PyBufferedRWPair_Type, &bufferedrwpair_spec,
702+
ADD_TYPE(m, state->PyBufferedRWPair_Type, &_Py_bufferedrwpair_spec,
703703
state->PyBufferedIOBase_Type);
704-
ADD_TYPE(m, state->PyBufferedRandom_Type, &bufferedrandom_spec,
704+
ADD_TYPE(m, state->PyBufferedRandom_Type, &_Py_bufferedrandom_spec,
705705
state->PyBufferedIOBase_Type);
706706

707707
// PyRawIOBase_Type(PyIOBase_Type) subclasses
708-
ADD_TYPE(m, state->PyFileIO_Type, &fileio_spec, state->PyRawIOBase_Type);
708+
ADD_TYPE(m, state->PyFileIO_Type, &_Py_fileio_spec, state->PyRawIOBase_Type);
709709

710710
#ifdef HAVE_WINDOWS_CONSOLE_IO
711-
ADD_TYPE(m, state->PyWindowsConsoleIO_Type, &winconsoleio_spec,
711+
ADD_TYPE(m, state->PyWindowsConsoleIO_Type, &_Py_winconsoleio_spec,
712712
state->PyRawIOBase_Type);
713713
#endif
714714

715715
// PyTextIOBase_Type(PyIOBase_Type) subclasses
716-
ADD_TYPE(m, state->PyStringIO_Type, &stringio_spec, state->PyTextIOBase_Type);
717-
ADD_TYPE(m, state->PyTextIOWrapper_Type, &textiowrapper_spec,
716+
ADD_TYPE(m, state->PyStringIO_Type, &_Py_stringio_spec, state->PyTextIOBase_Type);
717+
ADD_TYPE(m, state->PyTextIOWrapper_Type, &_Py_textiowrapper_spec,
718718
state->PyTextIOBase_Type);
719719

720720
#undef ADD_TYPE

Modules/_io/_iomodule.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99
#include "structmember.h"
1010

1111
/* Type specs */
12-
extern PyType_Spec bufferediobase_spec;
13-
extern PyType_Spec bufferedrandom_spec;
14-
extern PyType_Spec bufferedreader_spec;
15-
extern PyType_Spec bufferedrwpair_spec;
16-
extern PyType_Spec bufferedwriter_spec;
17-
extern PyType_Spec bytesio_spec;
18-
extern PyType_Spec bytesiobuf_spec;
19-
extern PyType_Spec fileio_spec;
20-
extern PyType_Spec iobase_spec;
21-
extern PyType_Spec nldecoder_spec;
22-
extern PyType_Spec rawiobase_spec;
23-
extern PyType_Spec stringio_spec;
24-
extern PyType_Spec textiobase_spec;
25-
extern PyType_Spec textiowrapper_spec;
12+
extern PyType_Spec _Py_bufferediobase_spec;
13+
extern PyType_Spec _Py_bufferedrandom_spec;
14+
extern PyType_Spec _Py_bufferedreader_spec;
15+
extern PyType_Spec _Py_bufferedrwpair_spec;
16+
extern PyType_Spec _Py_bufferedwriter_spec;
17+
extern PyType_Spec _Py_bytesio_spec;
18+
extern PyType_Spec _Py_bytesiobuf_spec;
19+
extern PyType_Spec _Py_fileio_spec;
20+
extern PyType_Spec _Py_iobase_spec;
21+
extern PyType_Spec _Py_nldecoder_spec;
22+
extern PyType_Spec _Py_rawiobase_spec;
23+
extern PyType_Spec _Py_stringio_spec;
24+
extern PyType_Spec _Py_textiobase_spec;
25+
extern PyType_Spec _Py_textiowrapper_spec;
2626

2727
#ifdef HAVE_WINDOWS_CONSOLE_IO
28-
extern PyType_Spec winconsoleio_spec;
28+
extern PyType_Spec _Py_winconsoleio_spec;
2929
#endif
3030

3131
/* These functions are used as METH_NOARGS methods, are normally called

Modules/_io/bufferedio.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,7 +2537,7 @@ static PyType_Slot bufferediobase_slots[] = {
25372537
};
25382538

25392539
/* Do not set Py_TPFLAGS_HAVE_GC so that tp_traverse and tp_clear are inherited */
2540-
PyType_Spec bufferediobase_spec = {
2540+
PyType_Spec _Py_bufferediobase_spec = {
25412541
.name = "_io._BufferedIOBase",
25422542
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
25432543
Py_TPFLAGS_IMMUTABLETYPE),
@@ -2600,7 +2600,7 @@ static PyType_Slot bufferedreader_slots[] = {
26002600
{0, NULL},
26012601
};
26022602

2603-
PyType_Spec bufferedreader_spec = {
2603+
PyType_Spec _Py_bufferedreader_spec = {
26042604
.name = "_io.BufferedReader",
26052605
.basicsize = sizeof(buffered),
26062606
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
@@ -2658,7 +2658,7 @@ static PyType_Slot bufferedwriter_slots[] = {
26582658
{0, NULL},
26592659
};
26602660

2661-
PyType_Spec bufferedwriter_spec = {
2661+
PyType_Spec _Py_bufferedwriter_spec = {
26622662
.name = "_io.BufferedWriter",
26632663
.basicsize = sizeof(buffered),
26642664
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
@@ -2708,7 +2708,7 @@ static PyType_Slot bufferedrwpair_slots[] = {
27082708
{0, NULL},
27092709
};
27102710

2711-
PyType_Spec bufferedrwpair_spec = {
2711+
PyType_Spec _Py_bufferedrwpair_spec = {
27122712
.name = "_io.BufferedRWPair",
27132713
.basicsize = sizeof(rwpair),
27142714
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
@@ -2776,7 +2776,7 @@ static PyType_Slot bufferedrandom_slots[] = {
27762776
{0, NULL},
27772777
};
27782778

2779-
PyType_Spec bufferedrandom_spec = {
2779+
PyType_Spec _Py_bufferedrandom_spec = {
27802780
.name = "_io.BufferedRandom",
27812781
.basicsize = sizeof(buffered),
27822782
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |

Modules/_io/bytesio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ static PyType_Slot bytesio_slots[] = {
11561156
{0, NULL},
11571157
};
11581158

1159-
PyType_Spec bytesio_spec = {
1159+
PyType_Spec _Py_bytesio_spec = {
11601160
.name = "_io.BytesIO",
11611161
.basicsize = sizeof(bytesio),
11621162
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
@@ -1246,7 +1246,7 @@ static PyType_Slot bytesiobuf_slots[] = {
12461246
{0, NULL},
12471247
};
12481248

1249-
PyType_Spec bytesiobuf_spec = {
1249+
PyType_Spec _Py_bytesiobuf_spec = {
12501250
.name = "_io._BytesIOBuffer",
12511251
.basicsize = sizeof(bytesiobuf),
12521252
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |

Modules/_io/fileio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ static PyType_Slot fileio_slots[] = {
13291329
{0, NULL},
13301330
};
13311331

1332-
PyType_Spec fileio_spec = {
1332+
PyType_Spec _Py_fileio_spec = {
13331333
.name = "_io.FileIO",
13341334
.basicsize = sizeof(fileio),
13351335
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |

Modules/_io/iobase.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ static PyType_Slot iobase_slots[] = {
885885
{0, NULL},
886886
};
887887

888-
PyType_Spec iobase_spec = {
888+
PyType_Spec _Py_iobase_spec = {
889889
.name = "_io._IOBase",
890890
.basicsize = sizeof(iobase),
891891
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
@@ -1046,7 +1046,7 @@ static PyType_Slot rawiobase_slots[] = {
10461046
};
10471047

10481048
/* Do not set Py_TPFLAGS_HAVE_GC so that tp_traverse and tp_clear are inherited */
1049-
PyType_Spec rawiobase_spec = {
1049+
PyType_Spec _Py_rawiobase_spec = {
10501050
.name = "_io._RawIOBase",
10511051
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
10521052
Py_TPFLAGS_IMMUTABLETYPE),

Modules/_io/stringio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ static PyType_Slot stringio_slots[] = {
10941094
{0, NULL},
10951095
};
10961096

1097-
PyType_Spec stringio_spec = {
1097+
PyType_Spec _Py_stringio_spec = {
10981098
.name = "_io.StringIO",
10991099
.basicsize = sizeof(stringio),
11001100
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |

Modules/_io/textio.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ static PyType_Slot textiobase_slots[] = {
208208
};
209209

210210
/* Do not set Py_TPFLAGS_HAVE_GC so that tp_traverse and tp_clear are inherited */
211-
PyType_Spec textiobase_spec = {
211+
PyType_Spec _Py_textiobase_spec = {
212212
.name = "_io._TextIOBase",
213213
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
214214
Py_TPFLAGS_IMMUTABLETYPE),
@@ -3352,7 +3352,7 @@ static PyType_Slot nldecoder_slots[] = {
33523352
{0, NULL},
33533353
};
33543354

3355-
PyType_Spec nldecoder_spec = {
3355+
PyType_Spec _Py_nldecoder_spec = {
33563356
.name = "_io.IncrementalNewlineDecoder",
33573357
.basicsize = sizeof(nldecoder_object),
33583358
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
@@ -3404,7 +3404,7 @@ static PyGetSetDef textiowrapper_getset[] = {
34043404
{NULL}
34053405
};
34063406

3407-
PyType_Slot textiowrapper_slots[] = {
3407+
static PyType_Slot textiowrapper_slots[] = {
34083408
{Py_tp_dealloc, textiowrapper_dealloc},
34093409
{Py_tp_repr, textiowrapper_repr},
34103410
{Py_tp_doc, (void *)_io_TextIOWrapper___init____doc__},
@@ -3418,7 +3418,7 @@ PyType_Slot textiowrapper_slots[] = {
34183418
{0, NULL},
34193419
};
34203420

3421-
PyType_Spec textiowrapper_spec = {
3421+
PyType_Spec _Py_textiowrapper_spec = {
34223422
.name = "_io.TextIOWrapper",
34233423
.basicsize = sizeof(textio),
34243424
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |

Modules/_io/winconsoleio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ static PyType_Slot winconsoleio_slots[] = {
12531253
{0, NULL},
12541254
};
12551255

1256-
PyType_Spec winconsoleio_spec = {
1256+
PyType_Spec _Py_winconsoleio_spec = {
12571257
.name = "_io._WindowsConsoleIO",
12581258
.basicsize = sizeof(winconsoleio),
12591259
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |

Objects/typevarobject.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static PyType_Slot constevaluator_slots[] = {
251251
{0, NULL},
252252
};
253253

254-
PyType_Spec constevaluator_spec = {
254+
static PyType_Spec constevaluator_spec = {
255255
.name = "_typing._ConstEvaluator",
256256
.basicsize = sizeof(constevaluatorobject),
257257
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE
@@ -930,7 +930,7 @@ static PyType_Slot typevar_slots[] = {
930930
{0, NULL},
931931
};
932932

933-
PyType_Spec typevar_spec = {
933+
static PyType_Spec typevar_spec = {
934934
.name = "typing.TypeVar",
935935
.basicsize = sizeof(typevarobject),
936936
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE
@@ -1078,7 +1078,7 @@ static PyType_Slot paramspecargs_slots[] = {
10781078
{0, NULL},
10791079
};
10801080

1081-
PyType_Spec paramspecargs_spec = {
1081+
static PyType_Spec paramspecargs_spec = {
10821082
.name = "typing.ParamSpecArgs",
10831083
.basicsize = sizeof(paramspecattrobject),
10841084
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE
@@ -1158,7 +1158,7 @@ static PyType_Slot paramspeckwargs_slots[] = {
11581158
{0, NULL},
11591159
};
11601160

1161-
PyType_Spec paramspeckwargs_spec = {
1161+
static PyType_Spec paramspeckwargs_spec = {
11621162
.name = "typing.ParamSpecKwargs",
11631163
.basicsize = sizeof(paramspecattrobject),
11641164
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE
@@ -1509,7 +1509,7 @@ static PyType_Slot paramspec_slots[] = {
15091509
{0, 0},
15101510
};
15111511

1512-
PyType_Spec paramspec_spec = {
1512+
static PyType_Spec paramspec_spec = {
15131513
.name = "typing.ParamSpec",
15141514
.basicsize = sizeof(paramspecobject),
15151515
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE
@@ -1789,7 +1789,7 @@ Note that only TypeVarTuples defined in the global scope can be\n\
17891789
pickled.\n\
17901790
");
17911791

1792-
PyType_Slot typevartuple_slots[] = {
1792+
static PyType_Slot typevartuple_slots[] = {
17931793
{Py_tp_doc, (void *)typevartuple_doc},
17941794
{Py_tp_members, typevartuple_members},
17951795
{Py_tp_methods, typevartuple_methods},
@@ -1805,7 +1805,7 @@ PyType_Slot typevartuple_slots[] = {
18051805
{0, 0},
18061806
};
18071807

1808-
PyType_Spec typevartuple_spec = {
1808+
static PyType_Spec typevartuple_spec = {
18091809
.name = "typing.TypeVarTuple",
18101810
.basicsize = sizeof(typevartupleobject),
18111811
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_MANAGED_DICT
@@ -2347,7 +2347,7 @@ static PyType_Slot generic_slots[] = {
23472347
{0, NULL},
23482348
};
23492349

2350-
PyType_Spec generic_spec = {
2350+
static PyType_Spec generic_spec = {
23512351
.name = "typing.Generic",
23522352
.basicsize = sizeof(PyObject),
23532353
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,

0 commit comments

Comments
 (0)