diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst index 2f0a9bd8be8815..d5ad1bfdf729f4 100644 --- a/Doc/library/functools.rst +++ b/Doc/library/functools.rst @@ -548,7 +548,7 @@ The :mod:`functools` module defines the following functions: attribute:: >>> fun.registry.keys() - dict_keys([, , , + dict_keys([, , , , , ]) >>> fun.registry[float] diff --git a/Doc/library/multiprocessing.shared_memory.rst b/Doc/library/multiprocessing.shared_memory.rst index 76046b34610abe..56684a129cf029 100644 --- a/Doc/library/multiprocessing.shared_memory.rst +++ b/Doc/library/multiprocessing.shared_memory.rst @@ -300,7 +300,7 @@ instance: >>> from multiprocessing import shared_memory >>> a = shared_memory.ShareableList(['howdy', b'HoWdY', -273.154, 100, None, True, 42]) >>> [ type(entry) for entry in a ] - [, , , , , , ] + [, , , , , , ] >>> a[2] -273.154 >>> a[2] = -78.5 diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index e009f303fef317..d0b66b3464fa3e 100644 --- a/Doc/library/unittest.mock.rst +++ b/Doc/library/unittest.mock.rst @@ -890,7 +890,7 @@ object:: ... >>> mock = MagicMock(async_func) >>> mock - + >>> mock() # doctest: +SKIP diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py index 6e87370c2065ba..7aade8c8554d18 100644 --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -1989,6 +1989,13 @@ def test_builtin_types(self): s = self.dumps(t, proto) self.assertIs(self.loads(s), t) + def test_types_types(self): + for t in types.__dict__.values(): + if isinstance(t, type): + for proto in protocols: + s = self.dumps(t, proto) + self.assertIs(self.loads(s), t) + def test_builtin_exceptions(self): for t in builtins.__dict__.values(): if isinstance(t, type) and issubclass(t, BaseException): diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py index 51ba151505fb54..c9fa7184989362 100644 --- a/Lib/test/test_complex.py +++ b/Lib/test/test_complex.py @@ -395,7 +395,7 @@ def split_zeros(x): self.assertRaises(TypeError, float, 5+3j) self.assertRaises(ValueError, complex, "") self.assertRaises(TypeError, complex, None) - self.assertRaisesRegex(TypeError, "not 'NoneType'", complex, None) + self.assertRaisesRegex(TypeError, "not 'types.NoneType'", complex, None) self.assertRaises(ValueError, complex, "\0") self.assertRaises(ValueError, complex, "3\09") self.assertRaises(TypeError, complex, "1", "2") diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py index 43a3ff0536fe28..b41ad399a06665 100644 --- a/Lib/test/test_coroutines.py +++ b/Lib/test/test_coroutines.py @@ -565,7 +565,7 @@ async def foo(): coro = foo() check = lambda: self.assertRaisesRegex( - TypeError, "'coroutine' object is not iterable") + TypeError, r"'types\.CoroutineType' object is not iterable") with check(): list(coro) @@ -597,7 +597,7 @@ async def foo(): await bar() check = lambda: self.assertRaisesRegex( - TypeError, "'coroutine' object is not iterable") + TypeError, r"'types\.CoroutineType' object is not iterable") coro = foo() with check(): @@ -958,7 +958,7 @@ def test_corotype_1(self): self.assertIn('in coroutine', ct.throw.__doc__) self.assertIn('of the coroutine', ct.__dict__['__name__'].__doc__) self.assertIn('of the coroutine', ct.__dict__['__qualname__'].__doc__) - self.assertEqual(ct.__name__, 'coroutine') + self.assertEqual(ct.__name__, 'CoroutineType') async def f(): pass c = f() diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py index 8289ddb1c3a54f..efea82a9a6c09e 100644 --- a/Lib/test/test_csv.py +++ b/Lib/test/test_csv.py @@ -1040,7 +1040,7 @@ class mydialect(csv.Dialect): with self.assertRaises(csv.Error) as cm: mydialect() self.assertEqual(str(cm.exception), - '"delimiter" must be string, not NoneType') + '"delimiter" must be string, not types.NoneType') def test_escapechar(self): class mydialect(csv.Dialect): diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index cbc020d1d3904a..a50d692a90fbad 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -4832,11 +4832,11 @@ class X: def test_qualname(self): descriptors = [str.lower, complex.real, float.real, int.__add__] - types = ['method', 'member', 'getset', 'wrapper'] + types = ['Method', 'Member', 'GetSet', 'Wrapper'] # make sure we have an example of each type of descriptor for d, n in zip(descriptors, types): - self.assertEqual(type(d).__name__, n + '_descriptor') + self.assertEqual(type(d).__name__, n + 'DescriptorType') for d in descriptors: qualname = d.__objclass__.__qualname__ + '.' + d.__name__ diff --git a/Lib/test/test_extcall.py b/Lib/test/test_extcall.py index d9d85fe79af883..41dcaa76b25d2f 100644 --- a/Lib/test/test_extcall.py +++ b/Lib/test/test_extcall.py @@ -263,73 +263,71 @@ ... TypeError: h() got an unexpected keyword argument 'e' - >>> h(*h) + >>> h(*1) Traceback (most recent call last): ... - TypeError: test.test_extcall.h() argument after * must be an iterable, not function + TypeError: test.test_extcall.h() argument after * must be an iterable, not int - >>> h(1, *h) + >>> h(1, *2) Traceback (most recent call last): ... - TypeError: Value after * must be an iterable, not function + TypeError: Value after * must be an iterable, not int - >>> h(*[1], *h) + >>> h(*[1], *2) Traceback (most recent call last): ... - TypeError: Value after * must be an iterable, not function + TypeError: Value after * must be an iterable, not int - >>> dir(*h) + >>> dir(*1) Traceback (most recent call last): ... - TypeError: dir() argument after * must be an iterable, not function + TypeError: dir() argument after * must be an iterable, not int >>> nothing = None - >>> nothing(*h) + >>> nothing(*1) Traceback (most recent call last): ... - TypeError: None argument after * must be an iterable, \ -not function + TypeError: None argument after * must be an iterable, not int - >>> h(**h) + >>> h(**1) Traceback (most recent call last): ... - TypeError: test.test_extcall.h() argument after ** must be a mapping, not function + TypeError: test.test_extcall.h() argument after ** must be a mapping, not int >>> h(**[]) Traceback (most recent call last): ... TypeError: test.test_extcall.h() argument after ** must be a mapping, not list - >>> h(a=1, **h) + >>> h(a=1, **2) Traceback (most recent call last): ... - TypeError: test.test_extcall.h() argument after ** must be a mapping, not function + TypeError: test.test_extcall.h() argument after ** must be a mapping, not int >>> h(a=1, **[]) Traceback (most recent call last): ... TypeError: test.test_extcall.h() argument after ** must be a mapping, not list - >>> h(**{'a': 1}, **h) + >>> h(**{'a': 1}, **2) Traceback (most recent call last): ... - TypeError: test.test_extcall.h() argument after ** must be a mapping, not function + TypeError: test.test_extcall.h() argument after ** must be a mapping, not int >>> h(**{'a': 1}, **[]) Traceback (most recent call last): ... TypeError: test.test_extcall.h() argument after ** must be a mapping, not list - >>> dir(**h) + >>> dir(**1) Traceback (most recent call last): ... - TypeError: dir() argument after ** must be a mapping, not function + TypeError: dir() argument after ** must be a mapping, not int - >>> nothing(**h) + >>> nothing(**1) Traceback (most recent call last): ... - TypeError: None argument after ** must be a mapping, \ -not function + TypeError: None argument after ** must be a mapping, not int >>> dir(b=1, **{'b': 1}) Traceback (most recent call last): diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py index 77977d0ae966f8..bde4e4dd62389e 100644 --- a/Lib/test/test_funcattrs.py +++ b/Lib/test/test_funcattrs.py @@ -112,7 +112,7 @@ def f(): print(a) self.assertIsInstance(c, tuple) self.assertEqual(len(c), 1) # don't have a type object handy - self.assertEqual(c[0].__class__.__name__, "cell") + self.assertEqual(c[0].__class__.__name__, "CellType") self.cannot_set_attr(f, "__closure__", c, AttributeError) def test_cell_new(self): diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py index 0f39b8f45714ad..a652b7071abe82 100644 --- a/Lib/test/test_gdb.py +++ b/Lib/test/test_gdb.py @@ -756,7 +756,7 @@ def test_pyup_command(self): self.assertMultilineMatches(bt, r'''^.* #[0-9]+ Frame 0x-?[0-9a-f]+, for file , line 12, in baz \(args=\(1, 2, 3\)\) -#[0-9]+ +#[0-9]+ $''') @unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands") @@ -785,7 +785,7 @@ def test_up_then_down(self): self.assertMultilineMatches(bt, r'''^.* #[0-9]+ Frame 0x-?[0-9a-f]+, for file , line 12, in baz \(args=\(1, 2, 3\)\) -#[0-9]+ +#[0-9]+ #[0-9]+ Frame 0x-?[0-9a-f]+, for file , line 12, in baz \(args=\(1, 2, 3\)\) $''') @@ -799,7 +799,7 @@ def test_bt(self): self.assertMultilineMatches(bt, r'''^.* Traceback \(most recent call first\): - + File ".*gdb_sample.py", line 10, in baz id\(42\) File ".*gdb_sample.py", line 7, in bar @@ -1014,7 +1014,7 @@ def test_printing_builtin(self): bt = self.get_stack_trace(script=self.get_sample_script(), cmds_after_breakpoint=['py-up', 'py-print len']) self.assertMultilineMatches(bt, - r".*\nbuiltin 'len' = \n.*") + r".*\nbuiltin 'len' = \n.*") class PyLocalsTests(DebuggerTests): @unittest.skipIf(python_is_optimized(), diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py index 492b77a954d865..285bf5a018e410 100644 --- a/Lib/test/test_generators.py +++ b/Lib/test/test_generators.py @@ -977,10 +977,10 @@ def b(): ... yield 1 ... >>> type(g) - + >>> i = g() >>> type(i) - + >>> [s for s in dir(i) if not s.startswith('_')] ['close', 'gi_code', 'gi_frame', 'gi_running', 'gi_suspended', 'gi_yieldfrom', 'send', 'throw'] >>> from test.support import HAVE_DOCSTRINGS @@ -997,11 +997,11 @@ def b(): >>> i.gi_running 0 >>> type(i.gi_frame) - + >>> i.gi_running = 42 Traceback (most recent call last): ... -AttributeError: attribute 'gi_running' of 'generator' objects is not writable +AttributeError: attribute 'gi_running' of 'types.GeneratorType' objects is not writable >>> def g(): ... yield me.gi_running >>> me = g() @@ -1372,27 +1372,27 @@ def b(): >>> def f(): ... yield >>> type(f()) - + >>> def f(): ... if 0: ... yield >>> type(f()) - + >>> def f(): ... if 0: ... yield 1 >>> type(f()) - + >>> def f(): ... if "": ... yield None >>> type(f()) - + >>> def f(): ... return @@ -1416,7 +1416,7 @@ def b(): ... x = 1 ... return >>> type(f()) - + >>> def f(): ... if 0: @@ -1424,7 +1424,7 @@ def b(): ... yield 1 ... >>> type(f()) - + >>> def f(): ... if 0: @@ -1434,7 +1434,7 @@ def b(): ... def f(self): ... yield 2 >>> type(f()) - + >>> def f(): ... if 0: @@ -1442,7 +1442,7 @@ def b(): ... if 0: ... yield 2 >>> type(f()) - + This one caused a crash (see SF bug 567538): @@ -2093,7 +2093,7 @@ def printsolution(self, x): >>> def f(): list(i for i in [(yield 26)]) >>> type(f()) - + A yield expression with augmented assignment. @@ -2364,21 +2364,21 @@ def printsolution(self, x): >>> def f(): x += yield >>> type(f()) - + >>> def f(): x = yield >>> type(f()) - + >>> def f(): lambda x=(yield): 1 >>> type(f()) - + >>> def f(d): d[(yield "a")] = d[(yield "b")] = 27 >>> data = [1,2] >>> g = f(data) >>> type(g) - + >>> g.send(None) 'a' >>> data diff --git a/Lib/test/test_genexps.py b/Lib/test/test_genexps.py index 4f2d3cdcc7943e..2a7255d6383072 100644 --- a/Lib/test/test_genexps.py +++ b/Lib/test/test_genexps.py @@ -48,7 +48,7 @@ >>> g = (i*i for i in range(4)) >>> type(g) - + >>> list(g) [0, 1, 4, 9] diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index 58f907eac09d53..713e411f2d7040 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -1521,9 +1521,9 @@ def check(test): msg=r'indices must be integers or slices, not dict;' check('[[1, 2] [{3: 4}]]') check('[[1, 2] [{i: i for i in range(5)}]]') - msg=r'indices must be integers or slices, not generator;' + msg=r'indices must be integers or slices, not types\.GeneratorType;' check('[[1, 2] [(i for i in range(5))]]') - msg=r'indices must be integers or slices, not function;' + msg=r'indices must be integers or slices, not types\.FunctionType;' check('[[1, 2] [(lambda x, y: x)]]') msg=r'indices must be integers or slices, not str;' check('[[1, 2] [f"{x}"]]') diff --git a/Lib/test/test_json/test_fail.py b/Lib/test/test_json/test_fail.py index efc982e8b0eb04..cdd5464396f697 100644 --- a/Lib/test/test_json/test_fail.py +++ b/Lib/test/test_json/test_fail.py @@ -100,7 +100,7 @@ def test_non_string_keys_dict(self): def test_not_serializable(self): import sys with self.assertRaisesRegex(TypeError, - 'Object of type module is not JSON serializable'): + 'Object of type ModuleType is not JSON serializable'): self.dumps(sys) def test_truncated_input(self): diff --git a/Lib/test/test_richcmp.py b/Lib/test/test_richcmp.py index 58729a9fea62fa..eaaceb50011e8d 100644 --- a/Lib/test/test_richcmp.py +++ b/Lib/test/test_richcmp.py @@ -258,16 +258,16 @@ class Spam: pass tests = [ - (lambda: 42 < None, r"'<' .* of 'int' and 'NoneType'"), - (lambda: None < 42, r"'<' .* of 'NoneType' and 'int'"), - (lambda: 42 > None, r"'>' .* of 'int' and 'NoneType'"), - (lambda: "foo" < None, r"'<' .* of 'str' and 'NoneType'"), + (lambda: 42 < None, r"'<' .* of 'int' and 'types.NoneType'"), + (lambda: None < 42, r"'<' .* of 'types.NoneType' and 'int'"), + (lambda: 42 > None, r"'>' .* of 'int' and 'types.NoneType'"), + (lambda: "foo" < None, r"'<' .* of 'str' and 'types.NoneType'"), (lambda: "foo" >= 666, r"'>=' .* of 'str' and 'int'"), - (lambda: 42 <= None, r"'<=' .* of 'int' and 'NoneType'"), - (lambda: 42 >= None, r"'>=' .* of 'int' and 'NoneType'"), + (lambda: 42 <= None, r"'<=' .* of 'int' and 'types.NoneType'"), + (lambda: 42 >= None, r"'>=' .* of 'int' and 'types.NoneType'"), (lambda: 42 < [], r"'<' .* of 'int' and 'list'"), (lambda: () > [], r"'>' .* of 'tuple' and 'list'"), - (lambda: None >= None, r"'>=' .* of 'NoneType' and 'NoneType'"), + (lambda: None >= None, r"'>=' .* of 'types.NoneType' and 'types.NoneType'"), (lambda: Spam() < 42, r"'<' .* of 'Spam' and 'int'"), (lambda: 42 < Spam(), r"'<' .* of 'int' and 'Spam'"), (lambda: Spam() <= Spam(), r"'<=' .* of 'Spam' and 'Spam'"), diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index f1b4018c265e18..d8cad12d53eaa7 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -910,7 +910,7 @@ def testSendtoErrors(self): "a bytes-like object is required, not 'complex'") with self.assertRaises(TypeError) as cm: s.sendto(b'foo', None) - self.assertIn('not NoneType',str(cm.exception)) + self.assertIn('not types.NoneType',str(cm.exception)) # 3 args with self.assertRaises(TypeError) as cm: s.sendto('\u2620', 0, sockname) @@ -922,7 +922,7 @@ def testSendtoErrors(self): "a bytes-like object is required, not 'complex'") with self.assertRaises(TypeError) as cm: s.sendto(b'foo', 0, None) - self.assertIn('not NoneType', str(cm.exception)) + self.assertIn('not types.NoneType', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto(b'foo', 'bar', sockname) with self.assertRaises(TypeError) as cm: diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index 95b1bae4f60850..0776d99adbc843 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -345,7 +345,7 @@ def test_format_exception_only_exc(self): self.assertEqual(output, ["Exception: projector\n"]) def test_exception_is_None(self): - NONE_EXC_STRING = 'NoneType: None\n' + NONE_EXC_STRING = 'types.NoneType: None\n' excfile = StringIO() traceback.print_exception(None, file=excfile) self.assertEqual(excfile.getvalue(), NONE_EXC_STRING) diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index af095632a36fcb..211b9e5761e457 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -1388,7 +1388,7 @@ def __prepare__(*args): return None with self.assertRaisesRegex(TypeError, r'^BadMeta\.__prepare__\(\) must ' - r'return a mapping, not NoneType$'): + r'return a mapping, not types.NoneType$'): class Foo(metaclass=BadMeta): pass # Also test the case in which the metaclass is not a type. @@ -1398,7 +1398,7 @@ def __prepare__(*args): return None with self.assertRaisesRegex(TypeError, r'^\.__prepare__\(\) must ' - r'return a mapping, not NoneType$'): + r'return a mapping, not types.NoneType$'): class Bar(metaclass=BadMeta()): pass diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 1cae1b0de7140f..ab28e12dc9086a 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -1669,7 +1669,7 @@ def test_repr(self): u = Union[str, None] self.assertEqual(repr(u), 'typing.Optional[str]') u = Union[None, str, int] - self.assertEqual(repr(u), 'typing.Union[NoneType, str, int]') + self.assertEqual(repr(u), 'typing.Union[types.NoneType, str, int]') u = Optional[str] self.assertEqual(repr(u), 'typing.Optional[str]') diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-12-09-19-35-34.gh-issue-100129.Pb9_RV.rst b/Misc/NEWS.d/next/Core and Builtins/2022-12-09-19-35-34.gh-issue-100129.Pb9_RV.rst new file mode 100644 index 00000000000000..e403d510308594 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-12-09-19-35-34.gh-issue-100129.Pb9_RV.rst @@ -0,0 +1,4 @@ +All builtin types exposed in the :mod:`types` module now have attributes +``__module__``, ``__qualname__`` and ``__name__`` which allow to resolve +them in the corresponding module. As result, all these types (but not +neccessary their instances) are now pickleable. diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 35c895d9ceb2a1..4b3a6dfa2b40c1 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -629,7 +629,7 @@ test_get_type_name(PyObject *self, PyObject *Py_UNUSED(ignored)) Py_DECREF(tp_name); tp_name = PyType_GetName(&PyModule_Type); - assert(strcmp(PyUnicode_AsUTF8(tp_name), "module") == 0); + assert(strcmp(PyUnicode_AsUTF8(tp_name), "ModuleType") == 0); Py_DECREF(tp_name); PyObject *HeapTypeNameType = PyType_FromSpec(&HeapTypeNameType_Spec); diff --git a/Objects/cellobject.c b/Objects/cellobject.c index f516707f6f8086..1e9ee5c3635979 100644 --- a/Objects/cellobject.c +++ b/Objects/cellobject.c @@ -18,7 +18,7 @@ PyCell_New(PyObject *obj) } PyDoc_STRVAR(cell_new_doc, -"cell([contents])\n" +"types.CellType([contents])\n" "--\n" "\n" "Create a new cell object.\n" @@ -35,11 +35,11 @@ cell_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *return_value = NULL; PyObject *obj = NULL; - if (!_PyArg_NoKeywords("cell", kwargs)) { + if (!_PyArg_NoKeywords("CellType", kwargs)) { goto exit; } /* min = 0: we allow the cell to be empty */ - if (!PyArg_UnpackTuple(args, "cell", 0, 1, &obj)) { + if (!PyArg_UnpackTuple(args, "CellType", 0, 1, &obj)) { goto exit; } return_value = PyCell_New(obj); @@ -151,7 +151,7 @@ static PyGetSetDef cell_getsetlist[] = { PyTypeObject PyCell_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "cell", + "types.CellType", sizeof(PyCellObject), 0, (destructor)cell_dealloc, /* tp_dealloc */ diff --git a/Objects/classobject.c b/Objects/classobject.c index 2cb192e725d40d..caabfb766059b2 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -12,9 +12,9 @@ #define TP_DESCR_GET(t) ((t)->tp_descr_get) /*[clinic input] -class method "PyMethodObject *" "&PyMethod_Type" +class MethodType "PyMethodObject *" "&PyMethod_Type" [clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b16e47edf6107c23]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=23d815bbfe0db041]*/ PyObject * @@ -121,12 +121,12 @@ PyMethod_New(PyObject *func, PyObject *self) } /*[clinic input] -method.__reduce__ +MethodType.__reduce__ [clinic start generated code]*/ static PyObject * -method___reduce___impl(PyMethodObject *self) -/*[clinic end generated code: output=6c04506d0fa6fdcb input=143a0bf5e96de6e8]*/ +MethodType___reduce___impl(PyMethodObject *self) +/*[clinic end generated code: output=ce1c37b9022af4df input=c1b5dbc4739fccfb]*/ { PyObject *funcself = PyMethod_GET_SELF(self); PyObject *func = PyMethod_GET_FUNCTION(self); @@ -139,7 +139,7 @@ method___reduce___impl(PyMethodObject *self) } static PyMethodDef method_methods[] = { - METHOD___REDUCE___METHODDEF + METHODTYPE___REDUCE___METHODDEF {NULL, NULL} }; @@ -202,7 +202,7 @@ method_getattro(PyObject *obj, PyObject *name) /*[clinic input] @classmethod -method.__new__ as method_new +MethodType.__new__ as method_new function: object instance: object / @@ -212,7 +212,7 @@ Create a bound instance method object. static PyObject * method_new_impl(PyTypeObject *type, PyObject *function, PyObject *instance) -/*[clinic end generated code: output=d33ef4ebf702e1f7 input=4e32facc3c3108ae]*/ +/*[clinic end generated code: output=d33ef4ebf702e1f7 input=9e26d1b4a248c3c5]*/ { if (!PyCallable_Check(function)) { PyErr_SetString(PyExc_TypeError, @@ -318,7 +318,7 @@ method_traverse(PyMethodObject *im, visitproc visit, void *arg) PyTypeObject PyMethod_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - .tp_name = "method", + .tp_name = "types.MethodType", .tp_basicsize = sizeof(PyMethodObject), .tp_dealloc = (destructor)method_dealloc, .tp_vectorcall_offset = offsetof(PyMethodObject, vectorcall), diff --git a/Objects/clinic/classobject.c.h b/Objects/clinic/classobject.c.h index 6c449829662af3..340f203d5082d2 100644 --- a/Objects/clinic/classobject.c.h +++ b/Objects/clinic/classobject.c.h @@ -8,25 +8,25 @@ preserve #endif -PyDoc_STRVAR(method___reduce____doc__, +PyDoc_STRVAR(MethodType___reduce____doc__, "__reduce__($self, /)\n" "--\n" "\n"); -#define METHOD___REDUCE___METHODDEF \ - {"__reduce__", (PyCFunction)method___reduce__, METH_NOARGS, method___reduce____doc__}, +#define METHODTYPE___REDUCE___METHODDEF \ + {"__reduce__", (PyCFunction)MethodType___reduce__, METH_NOARGS, MethodType___reduce____doc__}, static PyObject * -method___reduce___impl(PyMethodObject *self); +MethodType___reduce___impl(PyMethodObject *self); static PyObject * -method___reduce__(PyMethodObject *self, PyObject *Py_UNUSED(ignored)) +MethodType___reduce__(PyMethodObject *self, PyObject *Py_UNUSED(ignored)) { - return method___reduce___impl(self); + return MethodType___reduce___impl(self); } PyDoc_STRVAR(method_new__doc__, -"method(function, instance, /)\n" +"MethodType(function, instance, /)\n" "--\n" "\n" "Create a bound instance method object."); @@ -43,10 +43,10 @@ method_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) if ((type == &PyMethod_Type || type->tp_init == PyMethod_Type.tp_init) && - !_PyArg_NoKeywords("method", kwargs)) { + !_PyArg_NoKeywords("MethodType", kwargs)) { goto exit; } - if (!_PyArg_CheckPositional("method", PyTuple_GET_SIZE(args), 2, 2)) { + if (!_PyArg_CheckPositional("MethodType", PyTuple_GET_SIZE(args), 2, 2)) { goto exit; } function = PyTuple_GET_ITEM(args, 0); @@ -86,4 +86,4 @@ instancemethod_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=e3294c26a71d456d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b6a95b6c0ae95a3d input=a9049054013a1b77]*/ diff --git a/Objects/clinic/codeobject.c.h b/Objects/clinic/codeobject.c.h index da33f4a6a20c1b..4f46f962b3856e 100644 --- a/Objects/clinic/codeobject.c.h +++ b/Objects/clinic/codeobject.c.h @@ -9,10 +9,10 @@ preserve PyDoc_STRVAR(code_new__doc__, -"code(argcount, posonlyargcount, kwonlyargcount, nlocals, stacksize,\n" -" flags, codestring, constants, names, varnames, filename, name,\n" -" qualname, firstlineno, linetable, exceptiontable, freevars=(),\n" -" cellvars=(), /)\n" +"CodeType(argcount, posonlyargcount, kwonlyargcount, nlocals, stacksize,\n" +" flags, codestring, constants, names, varnames, filename, name,\n" +" qualname, firstlineno, linetable, exceptiontable, freevars=(),\n" +" cellvars=(), /)\n" "--\n" "\n" "Create a code object. Not for the faint of heart."); @@ -51,10 +51,10 @@ code_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) if ((type == &PyCode_Type || type->tp_init == PyCode_Type.tp_init) && - !_PyArg_NoKeywords("code", kwargs)) { + !_PyArg_NoKeywords("CodeType", kwargs)) { goto exit; } - if (!_PyArg_CheckPositional("code", PyTuple_GET_SIZE(args), 16, 18)) { + if (!_PyArg_CheckPositional("CodeType", PyTuple_GET_SIZE(args), 16, 18)) { goto exit; } argcount = _PyLong_AsInt(PyTuple_GET_ITEM(args, 0)); @@ -82,27 +82,27 @@ code_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) goto exit; } if (!PyBytes_Check(PyTuple_GET_ITEM(args, 6))) { - _PyArg_BadArgument("code", "argument 7", "bytes", PyTuple_GET_ITEM(args, 6)); + _PyArg_BadArgument("CodeType", "argument 7", "bytes", PyTuple_GET_ITEM(args, 6)); goto exit; } code = PyTuple_GET_ITEM(args, 6); if (!PyTuple_Check(PyTuple_GET_ITEM(args, 7))) { - _PyArg_BadArgument("code", "argument 8", "tuple", PyTuple_GET_ITEM(args, 7)); + _PyArg_BadArgument("CodeType", "argument 8", "tuple", PyTuple_GET_ITEM(args, 7)); goto exit; } consts = PyTuple_GET_ITEM(args, 7); if (!PyTuple_Check(PyTuple_GET_ITEM(args, 8))) { - _PyArg_BadArgument("code", "argument 9", "tuple", PyTuple_GET_ITEM(args, 8)); + _PyArg_BadArgument("CodeType", "argument 9", "tuple", PyTuple_GET_ITEM(args, 8)); goto exit; } names = PyTuple_GET_ITEM(args, 8); if (!PyTuple_Check(PyTuple_GET_ITEM(args, 9))) { - _PyArg_BadArgument("code", "argument 10", "tuple", PyTuple_GET_ITEM(args, 9)); + _PyArg_BadArgument("CodeType", "argument 10", "tuple", PyTuple_GET_ITEM(args, 9)); goto exit; } varnames = PyTuple_GET_ITEM(args, 9); if (!PyUnicode_Check(PyTuple_GET_ITEM(args, 10))) { - _PyArg_BadArgument("code", "argument 11", "str", PyTuple_GET_ITEM(args, 10)); + _PyArg_BadArgument("CodeType", "argument 11", "str", PyTuple_GET_ITEM(args, 10)); goto exit; } if (PyUnicode_READY(PyTuple_GET_ITEM(args, 10)) == -1) { @@ -110,7 +110,7 @@ code_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } filename = PyTuple_GET_ITEM(args, 10); if (!PyUnicode_Check(PyTuple_GET_ITEM(args, 11))) { - _PyArg_BadArgument("code", "argument 12", "str", PyTuple_GET_ITEM(args, 11)); + _PyArg_BadArgument("CodeType", "argument 12", "str", PyTuple_GET_ITEM(args, 11)); goto exit; } if (PyUnicode_READY(PyTuple_GET_ITEM(args, 11)) == -1) { @@ -118,7 +118,7 @@ code_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } name = PyTuple_GET_ITEM(args, 11); if (!PyUnicode_Check(PyTuple_GET_ITEM(args, 12))) { - _PyArg_BadArgument("code", "argument 13", "str", PyTuple_GET_ITEM(args, 12)); + _PyArg_BadArgument("CodeType", "argument 13", "str", PyTuple_GET_ITEM(args, 12)); goto exit; } if (PyUnicode_READY(PyTuple_GET_ITEM(args, 12)) == -1) { @@ -130,12 +130,12 @@ code_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) goto exit; } if (!PyBytes_Check(PyTuple_GET_ITEM(args, 14))) { - _PyArg_BadArgument("code", "argument 15", "bytes", PyTuple_GET_ITEM(args, 14)); + _PyArg_BadArgument("CodeType", "argument 15", "bytes", PyTuple_GET_ITEM(args, 14)); goto exit; } linetable = PyTuple_GET_ITEM(args, 14); if (!PyBytes_Check(PyTuple_GET_ITEM(args, 15))) { - _PyArg_BadArgument("code", "argument 16", "bytes", PyTuple_GET_ITEM(args, 15)); + _PyArg_BadArgument("CodeType", "argument 16", "bytes", PyTuple_GET_ITEM(args, 15)); goto exit; } exceptiontable = PyTuple_GET_ITEM(args, 15); @@ -143,7 +143,7 @@ code_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) goto skip_optional; } if (!PyTuple_Check(PyTuple_GET_ITEM(args, 16))) { - _PyArg_BadArgument("code", "argument 17", "tuple", PyTuple_GET_ITEM(args, 16)); + _PyArg_BadArgument("CodeType", "argument 17", "tuple", PyTuple_GET_ITEM(args, 16)); goto exit; } freevars = PyTuple_GET_ITEM(args, 16); @@ -151,7 +151,7 @@ code_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) goto skip_optional; } if (!PyTuple_Check(PyTuple_GET_ITEM(args, 17))) { - _PyArg_BadArgument("code", "argument 18", "tuple", PyTuple_GET_ITEM(args, 17)); + _PyArg_BadArgument("CodeType", "argument 18", "tuple", PyTuple_GET_ITEM(args, 17)); goto exit; } cellvars = PyTuple_GET_ITEM(args, 17); @@ -162,7 +162,7 @@ code_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } -PyDoc_STRVAR(code_replace__doc__, +PyDoc_STRVAR(types_CodeType_replace__doc__, "replace($self, /, *, co_argcount=-1, co_posonlyargcount=-1,\n" " co_kwonlyargcount=-1, co_nlocals=-1, co_stacksize=-1,\n" " co_flags=-1, co_firstlineno=-1, co_code=None, co_consts=None,\n" @@ -173,23 +173,23 @@ PyDoc_STRVAR(code_replace__doc__, "\n" "Return a copy of the code object with new values for the specified fields."); -#define CODE_REPLACE_METHODDEF \ - {"replace", _PyCFunction_CAST(code_replace), METH_FASTCALL|METH_KEYWORDS, code_replace__doc__}, +#define TYPES_CODETYPE_REPLACE_METHODDEF \ + {"replace", _PyCFunction_CAST(types_CodeType_replace), METH_FASTCALL|METH_KEYWORDS, types_CodeType_replace__doc__}, static PyObject * -code_replace_impl(PyCodeObject *self, int co_argcount, - int co_posonlyargcount, int co_kwonlyargcount, - int co_nlocals, int co_stacksize, int co_flags, - int co_firstlineno, PyBytesObject *co_code, - PyObject *co_consts, PyObject *co_names, - PyObject *co_varnames, PyObject *co_freevars, - PyObject *co_cellvars, PyObject *co_filename, - PyObject *co_name, PyObject *co_qualname, - PyBytesObject *co_linetable, - PyBytesObject *co_exceptiontable); +types_CodeType_replace_impl(PyCodeObject *self, int co_argcount, + int co_posonlyargcount, int co_kwonlyargcount, + int co_nlocals, int co_stacksize, int co_flags, + int co_firstlineno, PyBytesObject *co_code, + PyObject *co_consts, PyObject *co_names, + PyObject *co_varnames, PyObject *co_freevars, + PyObject *co_cellvars, PyObject *co_filename, + PyObject *co_name, PyObject *co_qualname, + PyBytesObject *co_linetable, + PyBytesObject *co_exceptiontable); static PyObject * -code_replace(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +types_CodeType_replace(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -423,13 +423,13 @@ code_replace(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObje } co_exceptiontable = (PyBytesObject *)args[17]; skip_optional_kwonly: - return_value = code_replace_impl(self, co_argcount, co_posonlyargcount, co_kwonlyargcount, co_nlocals, co_stacksize, co_flags, co_firstlineno, co_code, co_consts, co_names, co_varnames, co_freevars, co_cellvars, co_filename, co_name, co_qualname, co_linetable, co_exceptiontable); + return_value = types_CodeType_replace_impl(self, co_argcount, co_posonlyargcount, co_kwonlyargcount, co_nlocals, co_stacksize, co_flags, co_firstlineno, co_code, co_consts, co_names, co_varnames, co_freevars, co_cellvars, co_filename, co_name, co_qualname, co_linetable, co_exceptiontable); exit: return return_value; } -PyDoc_STRVAR(code__varname_from_oparg__doc__, +PyDoc_STRVAR(types_CodeType__varname_from_oparg__doc__, "_varname_from_oparg($self, /, oparg)\n" "--\n" "\n" @@ -437,14 +437,14 @@ PyDoc_STRVAR(code__varname_from_oparg__doc__, "\n" "WARNING: this method is for internal use only and may change or go away."); -#define CODE__VARNAME_FROM_OPARG_METHODDEF \ - {"_varname_from_oparg", _PyCFunction_CAST(code__varname_from_oparg), METH_FASTCALL|METH_KEYWORDS, code__varname_from_oparg__doc__}, +#define TYPES_CODETYPE__VARNAME_FROM_OPARG_METHODDEF \ + {"_varname_from_oparg", _PyCFunction_CAST(types_CodeType__varname_from_oparg), METH_FASTCALL|METH_KEYWORDS, types_CodeType__varname_from_oparg__doc__}, static PyObject * -code__varname_from_oparg_impl(PyCodeObject *self, int oparg); +types_CodeType__varname_from_oparg_impl(PyCodeObject *self, int oparg); static PyObject * -code__varname_from_oparg(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +types_CodeType__varname_from_oparg(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -483,9 +483,9 @@ code__varname_from_oparg(PyCodeObject *self, PyObject *const *args, Py_ssize_t n if (oparg == -1 && PyErr_Occurred()) { goto exit; } - return_value = code__varname_from_oparg_impl(self, oparg); + return_value = types_CodeType__varname_from_oparg_impl(self, oparg); exit: return return_value; } -/*[clinic end generated code: output=b6c98f17c60ace53 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e2540ad099c750c9 input=a9049054013a1b77]*/ diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 1e5a92270be84e..297d444a4697a2 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -1566,13 +1566,14 @@ PyCode_GetCode(PyCodeObject *co) ******************/ /*[clinic input] -class code "PyCodeObject *" "&PyCode_Type" +module types +class types.CodeType "PyCodeObject *" "&PyCode_Type" [clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=78aa5d576683bb4b]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=5bdfe35a3b23672e]*/ /*[clinic input] @classmethod -code.__new__ as code_new +types.CodeType.__new__ as code_new argcount: int posonlyargcount: int @@ -1605,7 +1606,7 @@ code_new_impl(PyTypeObject *type, int argcount, int posonlyargcount, PyObject *qualname, int firstlineno, PyObject *linetable, PyObject *exceptiontable, PyObject *freevars, PyObject *cellvars) -/*[clinic end generated code: output=069fa20d299f9dda input=e31da3c41ad8064a]*/ +/*[clinic end generated code: output=069fa20d299f9dda input=bb23c6787f447b63]*/ { PyObject *co = NULL; PyObject *ournames = NULL; @@ -1613,7 +1614,7 @@ code_new_impl(PyTypeObject *type, int argcount, int posonlyargcount, PyObject *ourfreevars = NULL; PyObject *ourcellvars = NULL; - if (PySys_Audit("code.__new__", "OOOiiiiii", + if (PySys_Audit("types.CodeType.__new__", "OOOiiiiii", code, filename, name, argcount, posonlyargcount, kwonlyargcount, nlocals, stacksize, flags) < 0) { goto cleanup; @@ -1956,7 +1957,7 @@ code_linesiterator(PyCodeObject *code, PyObject *Py_UNUSED(args)) } /*[clinic input] -code.replace +types.CodeType.replace * co_argcount: int(c_default="self->co_argcount") = -1 @@ -1982,17 +1983,17 @@ Return a copy of the code object with new values for the specified fields. [clinic start generated code]*/ static PyObject * -code_replace_impl(PyCodeObject *self, int co_argcount, - int co_posonlyargcount, int co_kwonlyargcount, - int co_nlocals, int co_stacksize, int co_flags, - int co_firstlineno, PyBytesObject *co_code, - PyObject *co_consts, PyObject *co_names, - PyObject *co_varnames, PyObject *co_freevars, - PyObject *co_cellvars, PyObject *co_filename, - PyObject *co_name, PyObject *co_qualname, - PyBytesObject *co_linetable, - PyBytesObject *co_exceptiontable) -/*[clinic end generated code: output=b6cd9988391d5711 input=f6f68e03571f8d7c]*/ +types_CodeType_replace_impl(PyCodeObject *self, int co_argcount, + int co_posonlyargcount, int co_kwonlyargcount, + int co_nlocals, int co_stacksize, int co_flags, + int co_firstlineno, PyBytesObject *co_code, + PyObject *co_consts, PyObject *co_names, + PyObject *co_varnames, PyObject *co_freevars, + PyObject *co_cellvars, PyObject *co_filename, + PyObject *co_name, PyObject *co_qualname, + PyBytesObject *co_linetable, + PyBytesObject *co_exceptiontable) +/*[clinic end generated code: output=476976595896e057 input=71d4a98105cab87b]*/ { #define CHECK_INT_ARG(ARG) \ if (ARG < 0) { \ @@ -2020,7 +2021,7 @@ code_replace_impl(PyCodeObject *self, int co_argcount, co_code = (PyBytesObject *)code; } - if (PySys_Audit("code.__new__", "OOOiiiiii", + if (PySys_Audit("types.CodeType.__new__", "OOOiiiiii", co_code, co_filename, co_name, co_argcount, co_posonlyargcount, co_kwonlyargcount, co_nlocals, co_stacksize, co_flags) < 0) { @@ -2069,7 +2070,7 @@ code_replace_impl(PyCodeObject *self, int co_argcount, } /*[clinic input] -code._varname_from_oparg +types.CodeType._varname_from_oparg oparg: int @@ -2079,8 +2080,8 @@ WARNING: this method is for internal use only and may change or go away. [clinic start generated code]*/ static PyObject * -code__varname_from_oparg_impl(PyCodeObject *self, int oparg) -/*[clinic end generated code: output=1fd1130413184206 input=c5fa3ee9bac7d4ca]*/ +types_CodeType__varname_from_oparg_impl(PyCodeObject *self, int oparg) +/*[clinic end generated code: output=92172b43d4b576c0 input=bd29af426db28423]*/ { PyObject *name = PyTuple_GetItem(self->co_localsplusnames, oparg); if (name == NULL) { @@ -2095,15 +2096,15 @@ static struct PyMethodDef code_methods[] = { {"__sizeof__", (PyCFunction)code_sizeof, METH_NOARGS}, {"co_lines", (PyCFunction)code_linesiterator, METH_NOARGS}, {"co_positions", (PyCFunction)code_positionsiterator, METH_NOARGS}, - CODE_REPLACE_METHODDEF - CODE__VARNAME_FROM_OPARG_METHODDEF + TYPES_CODETYPE_REPLACE_METHODDEF + TYPES_CODETYPE__VARNAME_FROM_OPARG_METHODDEF {NULL, NULL} /* sentinel */ }; PyTypeObject PyCode_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "code", + "types.CodeType", offsetof(PyCodeObject, co_code_adaptive), sizeof(_Py_CODEUNIT), (destructor)code_dealloc, /* tp_dealloc */ diff --git a/Objects/descrobject.c b/Objects/descrobject.c index c545b90c6283e1..25d0424ae0843c 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -709,7 +709,7 @@ descr_traverse(PyObject *self, visitproc visit, void *arg) PyTypeObject PyMethodDescr_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "method_descriptor", + "types.MethodDescriptorType", sizeof(PyMethodDescrObject), 0, (destructor)descr_dealloc, /* tp_dealloc */ @@ -749,7 +749,7 @@ PyTypeObject PyMethodDescr_Type = { /* This is for METH_CLASS in C, not for "f = classmethod(f)" in Python! */ PyTypeObject PyClassMethodDescr_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "classmethod_descriptor", + "types.ClassMethodDescriptorType", sizeof(PyMethodDescrObject), 0, (destructor)descr_dealloc, /* tp_dealloc */ @@ -786,7 +786,7 @@ PyTypeObject PyClassMethodDescr_Type = { PyTypeObject PyMemberDescr_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "member_descriptor", + "types.MemberDescriptorType", sizeof(PyMemberDescrObject), 0, (destructor)descr_dealloc, /* tp_dealloc */ @@ -823,7 +823,7 @@ PyTypeObject PyMemberDescr_Type = { PyTypeObject PyGetSetDescr_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "getset_descriptor", + "types.GetSetDescriptorType", sizeof(PyGetSetDescrObject), 0, (destructor)descr_dealloc, /* tp_dealloc */ @@ -860,7 +860,7 @@ PyTypeObject PyGetSetDescr_Type = { PyTypeObject PyWrapperDescr_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "wrapper_descriptor", + "types.WrapperDescriptorType", sizeof(PyWrapperDescrObject), 0, (destructor)descr_dealloc, /* tp_dealloc */ @@ -1411,7 +1411,7 @@ wrapper_traverse(PyObject *self, visitproc visit, void *arg) PyTypeObject _PyMethodWrapper_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "method-wrapper", /* tp_name */ + "types.MethodWrapperType", /* tp_name */ sizeof(wrapperobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ @@ -1877,7 +1877,7 @@ property_clear(PyObject *self) PyTypeObject PyDictProxy_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "mappingproxy", /* tp_name */ + "types.MappingProxyType", /* tp_name */ sizeof(mappingproxyobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ diff --git a/Objects/frameobject.c b/Objects/frameobject.c index 74c26d8d4d96a5..90b7897880a150 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -973,7 +973,7 @@ static PyMethodDef frame_methods[] = { PyTypeObject PyFrame_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "frame", + "types.FrameType", offsetof(PyFrameObject, _f_frame_data) + offsetof(_PyInterpreterFrame, localsplus), sizeof(PyObject *), diff --git a/Objects/funcobject.c b/Objects/funcobject.c index d5cf5b9277b3f1..c7c91de3019208 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -813,7 +813,7 @@ func_descr_get(PyObject *func, PyObject *obj, PyObject *type) PyTypeObject PyFunction_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "function", + "types.FunctionType", sizeof(PyFunctionObject), 0, (destructor)func_dealloc, /* tp_dealloc */ diff --git a/Objects/genobject.c b/Objects/genobject.c index c006f1af2177f9..a620fba5ad046f 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -794,7 +794,7 @@ static PyAsyncMethods gen_as_async = { PyTypeObject PyGen_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "generator", /* tp_name */ + "types.GeneratorType", /* tp_name */ offsetof(PyGenObject, gi_iframe) + offsetof(_PyInterpreterFrame, localsplus), /* tp_basicsize */ sizeof(PyObject *), /* tp_itemsize */ @@ -1139,7 +1139,7 @@ static PyAsyncMethods coro_as_async = { PyTypeObject PyCoro_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "coroutine", /* tp_name */ + "types.CoroutineType", /* tp_name */ offsetof(PyCoroObject, cr_iframe) + offsetof(_PyInterpreterFrame, localsplus), /* tp_basicsize */ sizeof(PyObject *), /* tp_itemsize */ @@ -1542,7 +1542,7 @@ static PyAsyncMethods async_gen_as_async = { PyTypeObject PyAsyncGen_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "async_generator", /* tp_name */ + "types.AsyncGeneratorType", /* tp_name */ offsetof(PyAsyncGenObject, ag_iframe) + offsetof(_PyInterpreterFrame, localsplus), /* tp_basicsize */ sizeof(PyObject *), /* tp_itemsize */ diff --git a/Objects/methodobject.c b/Objects/methodobject.c index 51752dec3dd08c..518fd80d1d7841 100644 --- a/Objects/methodobject.c +++ b/Objects/methodobject.c @@ -328,7 +328,7 @@ meth_hash(PyCFunctionObject *a) PyTypeObject PyCFunction_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "builtin_function_or_method", + "types.BuiltinFunctionType", sizeof(PyCFunctionObject), 0, (destructor)meth_dealloc, /* tp_dealloc */ diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index 8e03f2446f6fcd..deb27406721064 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -954,7 +954,7 @@ static PyGetSetDef module_getsets[] = { PyTypeObject PyModule_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "module", /* tp_name */ + "types.ModuleType", /* tp_name */ sizeof(PyModuleObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)module_dealloc, /* tp_dealloc */ diff --git a/Objects/object.c b/Objects/object.c index 028b0edc911155..1f69c73468dcbd 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -1685,7 +1685,7 @@ static PyNumberMethods none_as_number = { PyTypeObject _PyNone_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "NoneType", + "types.NoneType", 0, 0, none_dealloc, /*tp_dealloc*/ /*never called*/ @@ -1786,7 +1786,7 @@ static PyNumberMethods notimplemented_as_number = { PyTypeObject _PyNotImplemented_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "NotImplementedType", + "types.NotImplementedType", 0, 0, notimplemented_dealloc, /*tp_dealloc*/ /*never called*/ diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c index 5694bd9c661fa5..86a3488c937875 100644 --- a/Objects/sliceobject.c +++ b/Objects/sliceobject.c @@ -48,7 +48,7 @@ static PyMethodDef ellipsis_methods[] = { PyTypeObject PyEllipsis_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "ellipsis", /* tp_name */ + "types.EllipsisType", /* tp_name */ 0, /* tp_basicsize */ 0, /* tp_itemsize */ 0, /*never called*/ /* tp_dealloc */ diff --git a/Python/traceback.c b/Python/traceback.c index da26c9b260a3bd..9a0c5856abce49 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -188,7 +188,7 @@ tb_clear(PyTracebackObject *tb) PyTypeObject PyTraceBack_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "traceback", + "types.TracebackType", sizeof(PyTracebackObject), 0, (destructor)tb_dealloc, /*tp_dealloc*/ diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py index c003c1ab4a23bd..126ff403f4eeea 100755 --- a/Tools/gdb/libpython.py +++ b/Tools/gdb/libpython.py @@ -345,11 +345,15 @@ def subclass_from_type(cls, t): name_map = {'bool': PyBoolObjectPtr, 'classobj': PyClassObjectPtr, 'NoneType': PyNoneStructPtr, + 'types.NoneType': PyNoneStructPtr, 'frame': PyFrameObjectPtr, + 'types.FrameType': PyFrameObjectPtr, 'set' : PySetObjectPtr, 'frozenset' : PySetObjectPtr, 'builtin_function_or_method' : PyCFunctionObjectPtr, + 'types.BuiltinFunctionType' : PyCFunctionObjectPtr, 'method-wrapper': wrapperobject, + 'types.MethodWrapperType': wrapperobject, } if tp_name in name_map: return name_map[tp_name]