Skip to content

Commit c9543e4

Browse files
committed
Removed the new module
Removed a lot of types from the 'types' module that are available through builtins.
1 parent ceee077 commit c9543e4

File tree

10 files changed

+18
-198
lines changed

10 files changed

+18
-198
lines changed

Doc/library/datatypes.rst

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ The following modules are documented in this chapter:
3131
weakref.rst
3232
userdict.rst
3333
types.rst
34-
new.rst
3534
copy.rst
3635
pprint.rst
3736
repr.rst

Doc/library/new.rst

-55
This file was deleted.

Doc/library/types.rst

+4-97
Original file line numberDiff line numberDiff line change
@@ -33,77 +33,10 @@ Accordingly, the example above should be written as follows::
3333
else:
3434
mylist.remove(item)
3535

36-
The module defines the following names:
37-
38-
39-
.. data:: NoneType
40-
41-
The type of ``None``.
42-
43-
44-
.. data:: TypeType
45-
ClassType
46-
47-
.. index:: builtin: type
48-
49-
The type of type objects (such as returned by :func:`type`) and user-defined
50-
classes without metaclass; alias of the built-in :class:`type`.
51-
52-
53-
.. data:: ObjectType
54-
55-
Alias of the built-in :func:`object`.
56-
57-
58-
.. data:: BooleanType
59-
60-
The type of the :class:`bool` values ``True`` and ``False``; alias of the
61-
built-in :class:`bool`.
62-
63-
64-
.. data:: IntType
65-
LongType
66-
67-
The type of integers (e.g. ``1``); alias of the built-in :class:`int`.
68-
69-
70-
.. data:: FloatType
71-
72-
The type of floating point numbers (e.g. ``1.0``); alias of the built-in
73-
:class:`float`.
74-
75-
76-
.. data:: ComplexType
77-
78-
The type of complex numbers (e.g. ``1.0j``); alias of the built-in
79-
:class:`complex`. This is not defined if Python was built without complex
80-
number support.
81-
82-
83-
.. data:: StringType
84-
85-
The type of character strings (e.g. ``'Spam'``); alias of the built-in
86-
:class:`str`.
87-
88-
89-
.. data:: TupleType
90-
91-
The type of tuples (e.g. ``(1, 2, 3, 'Spam')``); alias of the built-in
92-
:class:`tuple`.
93-
94-
95-
.. data:: ListType
96-
97-
The type of lists (e.g. ``[0, 1, 2, 3]``); alias of the built-in
98-
:class:`list`.
99-
100-
101-
.. data:: DictType
102-
DictionaryType
103-
104-
The type of dictionaries (e.g. ``{'Bacon': 1, 'Ham': 0}``); alias of the
105-
built-in :class:`dict`.
36+
Starting in Python 3.0 all types that are also available as builtins are no
37+
longer exposed through the types module.
10638

39+
The module defines the following names:
10740

10841
.. data:: FunctionType
10942
LambdaType
@@ -141,19 +74,6 @@ The module defines the following names:
14174
The type of modules.
14275

14376

144-
.. data:: SliceType
145-
146-
.. index:: builtin: slice
147-
148-
The type of objects returned by :func:`slice`; alias of the built-in
149-
:class:`slice`.
150-
151-
152-
.. data:: EllipsisType
153-
154-
The type of ``Ellipsis``.
155-
156-
15777
.. data:: TracebackType
15878

15979
The type of traceback objects such as found in ``sys.exc_info()[2]``.
@@ -165,22 +85,9 @@ The module defines the following names:
16585
traceback object.
16686

16787

168-
.. XXX!
169-
.. data:: BufferType
170-
171-
.. index:: builtin: buffer
172-
173-
The type of buffer objects created by the :func:`buffer` function.
174-
175-
17688
.. data:: DictProxyType
17789

178-
The type of dict proxies, such as ``TypeType.__dict__``.
179-
180-
181-
.. data:: NotImplementedType
182-
183-
The type of ``NotImplemented``
90+
The type of dict proxies, such as ``type.__dict__``.
18491

18592

18693
.. data:: GetSetDescriptorType

Lib/new.py

-14
This file was deleted.

Lib/test/test_inspect.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def test_getfullargspec(self):
364364
formatted='(*arg1, arg2=1)')
365365

366366
self.assertFullArgSpecEquals(mod2.annotated, ['arg1'],
367-
ann_e={'arg1':types.ListType},
367+
ann_e={'arg1' : list},
368368
formatted='(arg1: list)')
369369

370370
def test_getargspec_method(self):

Lib/types.py

+1-22
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,6 @@
99
# iterator. Don't check the type! Use hasattr to check for both
1010
# "__iter__" and "__next__" attributes instead.
1111

12-
NoneType = type(None)
13-
TypeType = type
14-
ObjectType = object
15-
16-
IntType = int
17-
LongType = int
18-
FloatType = float
19-
BooleanType = bool
20-
try:
21-
ComplexType = complex
22-
except NameError:
23-
pass
24-
25-
TupleType = tuple
26-
ListType = list
27-
DictType = DictionaryType = dict
28-
2912
def _f(): pass
3013
FunctionType = type(_f)
3114
LambdaType = type(lambda: None) # Same as FunctionType
@@ -53,11 +36,7 @@ def _m(self): pass
5336
FrameType = type(tb.tb_frame)
5437
tb = None; del tb
5538

56-
SliceType = slice
57-
EllipsisType = type(Ellipsis)
58-
59-
DictProxyType = type(TypeType.__dict__)
60-
NotImplementedType = type(NotImplemented)
39+
DictProxyType = type(type.__dict__)
6140

6241
# Extension types defined in a C helper module. XXX There may be no
6342
# equivalent in implementations other than CPython, so it seems better to

Lib/xml/dom/domreg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def getDOMImplementation(name = None, features = ()):
6262

6363
# User did not specify a name, try implementations in arbitrary
6464
# order, returning the one that has the required features
65-
if isinstance(features, StringTypes):
65+
if isinstance(features, str):
6666
features = _parse_feature_string(features)
6767
for creator in registered.values():
6868
dom = creator()

Lib/xml/dom/expatbuilder.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ def parse(file, namespaces=True):
918918
else:
919919
builder = ExpatBuilder()
920920

921-
if isinstance(file, StringTypes):
921+
if isinstance(file, str):
922922
fp = open(file, 'rb')
923923
try:
924924
result = builder.parseFile(fp)
@@ -952,7 +952,7 @@ def parseFragment(file, context, namespaces=True):
952952
else:
953953
builder = FragmentBuilder(context)
954954

955-
if isinstance(file, StringTypes):
955+
if isinstance(file, str):
956956
fp = open(file, 'rb')
957957
try:
958958
result = builder.parseFile(fp)

Lib/xml/dom/minidom.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ def itemsNS(self):
498498
return L
499499

500500
def __contains__(self, key):
501-
if isinstance(key, StringTypes):
501+
if isinstance(key, str):
502502
return key in self._attrs
503503
else:
504504
return key in self._attrsNS
@@ -531,7 +531,7 @@ def __getitem__(self, attname_or_tuple):
531531

532532
# same as set
533533
def __setitem__(self, attname, value):
534-
if isinstance(value, StringTypes):
534+
if isinstance(value, str):
535535
try:
536536
node = self._attrs[attname]
537537
except KeyError:
@@ -1606,15 +1606,15 @@ def createElement(self, tagName):
16061606
return e
16071607

16081608
def createTextNode(self, data):
1609-
if not isinstance(data, StringTypes):
1609+
if not isinstance(data, str):
16101610
raise TypeError("node contents must be a string")
16111611
t = Text()
16121612
t.data = data
16131613
t.ownerDocument = self
16141614
return t
16151615

16161616
def createCDATASection(self, data):
1617-
if not isinstance(data, StringTypes):
1617+
if not isinstance(data, str):
16181618
raise TypeError("node contents must be a string")
16191619
c = CDATASection()
16201620
c.data = data
@@ -1927,7 +1927,7 @@ def parseString(string, parser=None):
19271927

19281928
def getDOMImplementation(features=None):
19291929
if features:
1930-
if isinstance(features, StringTypes):
1930+
if isinstance(features, str):
19311931
features = domreg._parse_feature_string(features)
19321932
for f, v in features:
19331933
if not Document.implementation.hasFeature(f, v):

Misc/NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ Library
6767
- The methods `os.tmpnam()`, `os.tempnam()` and `os.tmpfile()` have been
6868
removed in favor of the tempfile module.
6969

70+
- Removed the 'new' module.
71+
72+
- Removed all types from the 'types' module that are easily accessable through
73+
builtins.
7074

7175
What's New in Python 3.0a1?
7276
==========================

0 commit comments

Comments
 (0)