Skip to content

Commit 386a0ce

Browse files
author
amaury.forgeotdarc
committed
Issue 2408: remove the _types module
It was only used as a helper in types.py to access types (GetSetDescriptorType and MemberDescriptorType), when they can easily be obtained with python code. These expressions even work with Jython. I don't know what the future of the types module is; (cf. discussion in http://bugs.python.org/issue1605 ) at least this change makes it simpler. git-svn-id: http://svn.python.org/projects/python/trunk@62231 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 6b19ff7 commit 386a0ce

10 files changed

Lines changed: 13 additions & 136 deletions

File tree

Doc/library/types.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,20 +233,22 @@ The module defines the following names:
233233

234234
.. data:: GetSetDescriptorType
235235

236-
The type of objects defined in extension modules with ``PyGetSetDef``, such as
237-
``FrameType.f_locals`` or ``array.array.typecode``. This constant is not
238-
defined in implementations of Python that do not have such extension types, so
239-
for portable code use ``hasattr(types, 'GetSetDescriptorType')``.
236+
The type of objects defined in extension modules with ``PyGetSetDef``, such
237+
as ``FrameType.f_locals`` or ``array.array.typecode``. This type is used as
238+
descriptor for object attributes; it has the same purpose as the
239+
:class:`property` type, but for classes defined in extension modules.
240240

241241
.. versionadded:: 2.5
242242

243243

244244
.. data:: MemberDescriptorType
245245

246-
The type of objects defined in extension modules with ``PyMemberDef``, such as
247-
``datetime.timedelta.days``. This constant is not defined in implementations of
248-
Python that do not have such extension types, so for portable code use
249-
``hasattr(types, 'MemberDescriptorType')``.
246+
The type of objects defined in extension modules with ``PyMemberDef``, such
247+
as ``datetime.timedelta.days``. This type is used as descriptor for simple C
248+
data members which use standard conversion functions; it has the same purpose
249+
as the :class:`property` type, but for classes defined in extension modules.
250+
In other implementations of Python, this type may be identical to
251+
``GetSetDescriptorType``.
250252

251253
.. versionadded:: 2.5
252254

Lib/types.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,8 @@ def _m(self): pass
8686
DictProxyType = type(TypeType.__dict__)
8787
NotImplementedType = type(NotImplemented)
8888

89-
# Extension types defined in a C helper module. XXX There may be no
90-
# equivalent in implementations other than CPython, so it seems better to
91-
# leave them undefined then to set them to e.g. None.
92-
try:
93-
import _types
94-
except ImportError:
95-
pass
96-
else:
97-
GetSetDescriptorType = type(_types.Helper.getter)
98-
MemberDescriptorType = type(_types.Helper.member)
99-
del _types
89+
# For Jython, the following two types are identical
90+
GetSetDescriptorType = type(FunctionType.func_code)
91+
MemberDescriptorType = type(FunctionType.func_globals)
10092

10193
del sys, _f, _g, _C, _x # Not for export

Makefile.pre.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ OBJECT_OBJS= \
333333
##########################################################################
334334
# objects that get linked into the Python library
335335
LIBRARY_OBJS= \
336-
Modules/_typesmodule.o \
337336
Modules/getbuildinfo.o \
338337
$(PARSER_OBJS) \
339338
$(OBJECT_OBJS) \
@@ -371,7 +370,6 @@ sharedmods: $(BUILDPYTHON)
371370
$(LIBRARY): $(LIBRARY_OBJS)
372371
-rm -f $@
373372
$(AR) cr $@ Modules/getbuildinfo.o
374-
$(AR) cr $@ Modules/_typesmodule.o
375373
$(AR) cr $@ $(PARSER_OBJS)
376374
$(AR) cr $@ $(OBJECT_OBJS)
377375
$(AR) cr $@ $(PYTHON_OBJS)

Modules/_typesmodule.c

Lines changed: 0 additions & 93 deletions
This file was deleted.

Modules/config.c.in

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ extern void PyMarshal_Init(void);
2828
extern void initimp(void);
2929
extern void initgc(void);
3030
extern void init_ast(void);
31-
extern void init_types(void);
3231

3332
struct _inittab _PyImport_Inittab[] = {
3433

@@ -43,9 +42,6 @@ struct _inittab _PyImport_Inittab[] = {
4342
/* This lives in Python/Python-ast.c */
4443
{"_ast", init_ast},
4544

46-
/* This lives in Modules/_typesmodule.c */
47-
{"_types", init_types},
48-
4945
/* These entries are here for sys.builtin_module_names */
5046
{"__main__", NULL},
5147
{"__builtin__", NULL},

PC/VC6/pythoncore.dsp

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PC/VS7.1/pythoncore.vcproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,6 @@
397397
<File
398398
RelativePath="..\..\Pc\_subprocess.c">
399399
</File>
400-
<File
401-
RelativePath="..\..\Modules\_typesmodule.c">
402-
</File>
403400
<File
404401
RelativePath="..\..\Modules\_weakref.c">
405402
</File>

PC/VS8.0/pythoncore.vcproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,10 +1022,6 @@
10221022
RelativePath="..\..\Modules\_struct.c"
10231023
>
10241024
</File>
1025-
<File
1026-
RelativePath="..\..\Modules\_typesmodule.c"
1027-
>
1028-
</File>
10291025
<File
10301026
RelativePath="..\..\Modules\_weakref.c"
10311027
>

PC/config.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ extern void init_codecs_tw(void);
6666
extern void init_subprocess(void);
6767
extern void init_lsprof(void);
6868
extern void init_ast(void);
69-
extern void init_types(void);
7069

7170
/* tools/freeze/makeconfig.py marker for additional "extern" */
7271
/* -- ADDMODULE MARKER 1 -- */
@@ -161,8 +160,6 @@ struct _inittab _PyImport_Inittab[] = {
161160
{"sys", NULL},
162161
{"exceptions", NULL},
163162

164-
{"_types", init_types},
165-
166163
/* Sentinel */
167164
{0, 0}
168165
};

PCbuild/pythoncore.vcproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,10 +1022,6 @@
10221022
RelativePath="..\Modules\_struct.c"
10231023
>
10241024
</File>
1025-
<File
1026-
RelativePath="..\Modules\_typesmodule.c"
1027-
>
1028-
</File>
10291025
<File
10301026
RelativePath="..\Modules\_weakref.c"
10311027
>

0 commit comments

Comments
 (0)