Skip to content

Commit

Permalink
Removed the new module
Browse files Browse the repository at this point in the history
Removed a lot of types from the 'types' module that are available through builtins.
  • Loading branch information
tiran committed Nov 28, 2007
1 parent ceee077 commit c9543e4
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 198 deletions.
1 change: 0 additions & 1 deletion Doc/library/datatypes.rst
Expand Up @@ -31,7 +31,6 @@ The following modules are documented in this chapter:
weakref.rst
userdict.rst
types.rst
new.rst
copy.rst
pprint.rst
repr.rst
55 changes: 0 additions & 55 deletions Doc/library/new.rst

This file was deleted.

101 changes: 4 additions & 97 deletions Doc/library/types.rst
Expand Up @@ -33,77 +33,10 @@ Accordingly, the example above should be written as follows::
else:
mylist.remove(item)

The module defines the following names:


.. data:: NoneType

The type of ``None``.


.. data:: TypeType
ClassType

.. index:: builtin: type

The type of type objects (such as returned by :func:`type`) and user-defined
classes without metaclass; alias of the built-in :class:`type`.


.. data:: ObjectType

Alias of the built-in :func:`object`.


.. data:: BooleanType

The type of the :class:`bool` values ``True`` and ``False``; alias of the
built-in :class:`bool`.


.. data:: IntType
LongType

The type of integers (e.g. ``1``); alias of the built-in :class:`int`.


.. data:: FloatType

The type of floating point numbers (e.g. ``1.0``); alias of the built-in
:class:`float`.


.. data:: ComplexType

The type of complex numbers (e.g. ``1.0j``); alias of the built-in
:class:`complex`. This is not defined if Python was built without complex
number support.


.. data:: StringType

The type of character strings (e.g. ``'Spam'``); alias of the built-in
:class:`str`.


.. data:: TupleType

The type of tuples (e.g. ``(1, 2, 3, 'Spam')``); alias of the built-in
:class:`tuple`.


.. data:: ListType

The type of lists (e.g. ``[0, 1, 2, 3]``); alias of the built-in
:class:`list`.


.. data:: DictType
DictionaryType

The type of dictionaries (e.g. ``{'Bacon': 1, 'Ham': 0}``); alias of the
built-in :class:`dict`.
Starting in Python 3.0 all types that are also available as builtins are no
longer exposed through the types module.

The module defines the following names:

.. data:: FunctionType
LambdaType
Expand Down Expand Up @@ -141,19 +74,6 @@ The module defines the following names:
The type of modules.


.. data:: SliceType

.. index:: builtin: slice

The type of objects returned by :func:`slice`; alias of the built-in
:class:`slice`.


.. data:: EllipsisType

The type of ``Ellipsis``.


.. data:: TracebackType

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


.. XXX!
.. data:: BufferType

.. index:: builtin: buffer

The type of buffer objects created by the :func:`buffer` function.


.. data:: DictProxyType

The type of dict proxies, such as ``TypeType.__dict__``.


.. data:: NotImplementedType

The type of ``NotImplemented``
The type of dict proxies, such as ``type.__dict__``.


.. data:: GetSetDescriptorType
Expand Down
14 changes: 0 additions & 14 deletions Lib/new.py

This file was deleted.

2 changes: 1 addition & 1 deletion Lib/test/test_inspect.py
Expand Up @@ -364,7 +364,7 @@ def test_getfullargspec(self):
formatted='(*arg1, arg2=1)')

self.assertFullArgSpecEquals(mod2.annotated, ['arg1'],
ann_e={'arg1':types.ListType},
ann_e={'arg1' : list},
formatted='(arg1: list)')

def test_getargspec_method(self):
Expand Down
23 changes: 1 addition & 22 deletions Lib/types.py
Expand Up @@ -9,23 +9,6 @@
# iterator. Don't check the type! Use hasattr to check for both
# "__iter__" and "__next__" attributes instead.

NoneType = type(None)
TypeType = type
ObjectType = object

IntType = int
LongType = int
FloatType = float
BooleanType = bool
try:
ComplexType = complex
except NameError:
pass

TupleType = tuple
ListType = list
DictType = DictionaryType = dict

def _f(): pass
FunctionType = type(_f)
LambdaType = type(lambda: None) # Same as FunctionType
Expand Down Expand Up @@ -53,11 +36,7 @@ def _m(self): pass
FrameType = type(tb.tb_frame)
tb = None; del tb

SliceType = slice
EllipsisType = type(Ellipsis)

DictProxyType = type(TypeType.__dict__)
NotImplementedType = type(NotImplemented)
DictProxyType = type(type.__dict__)

# Extension types defined in a C helper module. XXX There may be no
# equivalent in implementations other than CPython, so it seems better to
Expand Down
2 changes: 1 addition & 1 deletion Lib/xml/dom/domreg.py
Expand Up @@ -62,7 +62,7 @@ def getDOMImplementation(name = None, features = ()):

# User did not specify a name, try implementations in arbitrary
# order, returning the one that has the required features
if isinstance(features, StringTypes):
if isinstance(features, str):
features = _parse_feature_string(features)
for creator in registered.values():
dom = creator()
Expand Down
4 changes: 2 additions & 2 deletions Lib/xml/dom/expatbuilder.py
Expand Up @@ -918,7 +918,7 @@ def parse(file, namespaces=True):
else:
builder = ExpatBuilder()

if isinstance(file, StringTypes):
if isinstance(file, str):
fp = open(file, 'rb')
try:
result = builder.parseFile(fp)
Expand Down Expand Up @@ -952,7 +952,7 @@ def parseFragment(file, context, namespaces=True):
else:
builder = FragmentBuilder(context)

if isinstance(file, StringTypes):
if isinstance(file, str):
fp = open(file, 'rb')
try:
result = builder.parseFile(fp)
Expand Down
10 changes: 5 additions & 5 deletions Lib/xml/dom/minidom.py
Expand Up @@ -498,7 +498,7 @@ def itemsNS(self):
return L

def __contains__(self, key):
if isinstance(key, StringTypes):
if isinstance(key, str):
return key in self._attrs
else:
return key in self._attrsNS
Expand Down Expand Up @@ -531,7 +531,7 @@ def __getitem__(self, attname_or_tuple):

# same as set
def __setitem__(self, attname, value):
if isinstance(value, StringTypes):
if isinstance(value, str):
try:
node = self._attrs[attname]
except KeyError:
Expand Down Expand Up @@ -1606,15 +1606,15 @@ def createElement(self, tagName):
return e

def createTextNode(self, data):
if not isinstance(data, StringTypes):
if not isinstance(data, str):
raise TypeError("node contents must be a string")
t = Text()
t.data = data
t.ownerDocument = self
return t

def createCDATASection(self, data):
if not isinstance(data, StringTypes):
if not isinstance(data, str):
raise TypeError("node contents must be a string")
c = CDATASection()
c.data = data
Expand Down Expand Up @@ -1927,7 +1927,7 @@ def parseString(string, parser=None):

def getDOMImplementation(features=None):
if features:
if isinstance(features, StringTypes):
if isinstance(features, str):
features = domreg._parse_feature_string(features)
for f, v in features:
if not Document.implementation.hasFeature(f, v):
Expand Down
4 changes: 4 additions & 0 deletions Misc/NEWS
Expand Up @@ -67,6 +67,10 @@ Library
- The methods `os.tmpnam()`, `os.tempnam()` and `os.tmpfile()` have been
removed in favor of the tempfile module.

- Removed the 'new' module.

- Removed all types from the 'types' module that are easily accessable through
builtins.

What's New in Python 3.0a1?
==========================
Expand Down

0 comments on commit c9543e4

Please sign in to comment.