Skip to content

Commit 9a9c5c5

Browse files
remove c-level NoExtraItems singleton
1 parent 1f23caa commit 9a9c5c5

File tree

6 files changed

+1
-66
lines changed

6 files changed

+1
-66
lines changed

Include/internal/pycore_typevarobject.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ extern int _Py_typing_type_repr(PyUnicodeWriter *, PyObject *);
2121
extern PyTypeObject _PyTypeAlias_Type;
2222
extern PyTypeObject _PyNoDefault_Type;
2323
extern PyObject _Py_NoDefaultStruct;
24-
extern PyTypeObject _PyNoExtraItems_Type;
25-
extern PyObject _Py_NoExtraItemsStruct;
2624

2725
#ifdef __cplusplus
2826
}

Lib/test/test_typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from typing import Self, LiteralString
4242
from typing import TypeAlias
4343
from typing import ParamSpec, Concatenate, ParamSpecArgs, ParamSpecKwargs
44-
from typing import TypeGuard, TypeIs, NoDefault, NoExtraItems
44+
from typing import TypeGuard, TypeIs, NoDefault
4545
import abc
4646
import textwrap
4747
import typing

Lib/typing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
Generic,
4141
Union,
4242
NoDefault,
43-
NoExtraItems,
4443
)
4544

4645
# Please keep __all__ alphabetized within each category.

Modules/_typingmodule.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ _typing_exec(PyObject *m)
7070
if (PyModule_AddObjectRef(m, "NoDefault", (PyObject *)&_Py_NoDefaultStruct) < 0) {
7171
return -1;
7272
}
73-
if (PyModule_AddObjectRef(m, "NoExtraItems", (PyObject *)&_Py_NoExtraItemsStruct) < 0) {
74-
return -1;
75-
}
7673
return 0;
7774
}
7875

Objects/typevarobject.c

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -123,63 +123,6 @@ PyTypeObject _PyNoDefault_Type = {
123123

124124
PyObject _Py_NoDefaultStruct = _PyObject_HEAD_INIT(&_PyNoDefault_Type);
125125

126-
/* NoExtraItems: a marker object for TypedDict extra_items when it's unset. */
127-
128-
static PyObject *
129-
NoExtraItems_repr(PyObject *op)
130-
{
131-
return PyUnicode_FromString("typing.NoExtraItems");
132-
}
133-
134-
static PyObject *
135-
NoExtraItems_reduce(PyObject *op, PyObject *Py_UNUSED(ignored))
136-
{
137-
return PyUnicode_FromString("NoExtraItems");
138-
}
139-
140-
static PyMethodDef noextraitems_methods[] = {
141-
{"__reduce__", NoExtraItems_reduce, METH_NOARGS, NULL},
142-
{NULL, NULL}
143-
};
144-
145-
static PyObject *
146-
noextraitems_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
147-
{
148-
if (PyTuple_GET_SIZE(args) || (kwargs && PyDict_GET_SIZE(kwargs))) {
149-
PyErr_SetString(PyExc_TypeError, "NoExtraItemsType takes no arguments");
150-
return NULL;
151-
}
152-
return (PyObject *)&_Py_NoExtraItemsStruct;
153-
}
154-
155-
static void
156-
noextraitems_dealloc(PyObject *obj)
157-
{
158-
/* This should never get called, but we also don't want to SEGV if
159-
* we accidentally decref NoExtraItems out of existence. Instead,
160-
* since NoExtraItems is an immortal object, re-set the reference count.
161-
*/
162-
_Py_SetImmortal(obj);
163-
}
164-
165-
PyDoc_STRVAR(noextraitems_doc,
166-
"NoExtraItemsType()\n"
167-
"--\n\n"
168-
"The type of the NoExtraItems singleton.");
169-
170-
PyTypeObject _PyNoExtraItems_Type = {
171-
PyVarObject_HEAD_INIT(&PyType_Type, 0)
172-
"NoExtraItemsType",
173-
.tp_dealloc = noextraitems_dealloc,
174-
.tp_repr = NoExtraItems_repr,
175-
.tp_flags = Py_TPFLAGS_DEFAULT,
176-
.tp_doc = noextraitems_doc,
177-
.tp_methods = noextraitems_methods,
178-
.tp_new = noextraitems_new,
179-
};
180-
181-
PyObject _Py_NoExtraItemsStruct = _PyObject_HEAD_INIT(&_PyNoExtraItems_Type);
182-
183126
typedef struct {
184127
PyObject_HEAD
185128
PyObject *value;

Tools/c-analyzer/cpython/ignored.tsv

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,6 @@ Objects/obmalloc.c - obmalloc_state_main -
344344
Objects/obmalloc.c - obmalloc_state_initialized -
345345
Objects/typeobject.c - name_op -
346346
Objects/typeobject.c - slotdefs -
347-
Objects/typevarobject.c - _PyNoExtraItems_Type -
348-
Objects/typevarobject.c - _Py_NoExtraItemsStruct -
349347
Objects/unicodeobject.c - stripfuncnames -
350348
Objects/unicodeobject.c - utf7_category -
351349
Objects/unicodeobject.c unicode_decode_call_errorhandler_wchar argparse -

0 commit comments

Comments
 (0)