diff options
author | Christian Heimes <christian@cheimes.de> | 2007-11-28 08:28:28 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-11-28 08:28:28 (GMT) |
commit | c9543e42330e5f339d6419eba6a8c5a61a39aeca (patch) | |
tree | ee3c677e808d015b6c142e1cca28337e08839818 /Lib | |
parent | ceee0773d262bfe876e40da927b03279ed9f8419 (diff) | |
download | cpython-c9543e42330e5f339d6419eba6a8c5a61a39aeca.zip cpython-c9543e42330e5f339d6419eba6a8c5a61a39aeca.tar.gz cpython-c9543e42330e5f339d6419eba6a8c5a61a39aeca.tar.bz2 |
Removed the new module
Removed a lot of types from the 'types' module that are available through builtins.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/new.py | 14 | ||||
-rw-r--r-- | Lib/test/test_inspect.py | 2 | ||||
-rw-r--r-- | Lib/types.py | 23 | ||||
-rw-r--r-- | Lib/xml/dom/domreg.py | 2 | ||||
-rw-r--r-- | Lib/xml/dom/expatbuilder.py | 4 | ||||
-rw-r--r-- | Lib/xml/dom/minidom.py | 10 |
6 files changed, 10 insertions, 45 deletions
diff --git a/Lib/new.py b/Lib/new.py deleted file mode 100644 index 6ce9a55..0000000 --- a/Lib/new.py +++ /dev/null @@ -1,14 +0,0 @@ -"""Create new objects of various types. Deprecated. - -This module is no longer required except for backward compatibility. -Objects of most types can now be created by calling the type object. -""" -from warnings import warn as _warn -_warn("The 'new' module is not supported in 3.x, use the 'types' module " - "instead.", DeprecationWarning, 2) - -classobj = type -from types import FunctionType as function -from types import MethodType as instancemethod -from types import ModuleType as module -from types import CodeType as code diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index 4b78708..60a7ad1 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -364,7 +364,7 @@ class TestClassesAndFunctions(unittest.TestCase): 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): diff --git a/Lib/types.py b/Lib/types.py index 402fa18..72454a1 100644 --- a/Lib/types.py +++ b/Lib/types.py @@ -9,23 +9,6 @@ import sys # 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 @@ -53,11 +36,7 @@ except TypeError: 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 diff --git a/Lib/xml/dom/domreg.py b/Lib/xml/dom/domreg.py index f653563..67e0104 100644 --- a/Lib/xml/dom/domreg.py +++ b/Lib/xml/dom/domreg.py @@ -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() diff --git a/Lib/xml/dom/expatbuilder.py b/Lib/xml/dom/expatbuilder.py index fdb5598..a5354b9 100644 --- a/Lib/xml/dom/expatbuilder.py +++ b/Lib/xml/dom/expatbuilder.py @@ -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) @@ -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) diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py index 1b857a2..3087a5c 100644 --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -498,7 +498,7 @@ class NamedNodeMap(object): 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 @@ -531,7 +531,7 @@ class NamedNodeMap(object): # same as set def __setitem__(self, attname, value): - if isinstance(value, StringTypes): + if isinstance(value, str): try: node = self._attrs[attname] except KeyError: @@ -1606,7 +1606,7 @@ class Document(Node, DocumentLS): 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 @@ -1614,7 +1614,7 @@ class Document(Node, DocumentLS): 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 @@ -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): |