Index: Lib/new.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/new.py,v retrieving revision 1.1 diff -c -r1.1 new.py *** Lib/new.py 16 Jun 2002 01:22:13 -0000 1.1 --- Lib/new.py 18 Jun 2002 14:29:24 -0000 *************** *** 4,17 **** Objects of most types can now be created by calling the type object. """ ! from types import ClassType as classobj ! from types import FunctionType as function ! from types import InstanceType as instance ! from types import MethodType as instancemethod ! from types import ModuleType as module # CodeType is not accessible in restricted execution mode try: ! from types import CodeType as code except ImportError: pass --- 4,13 ---- Objects of most types can now be created by calling the type object. """ ! from types import classobj, function, instance, instancemethod, module # CodeType is not accessible in restricted execution mode try: ! from types import code except ImportError: pass Index: Lib/types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/types.py,v retrieving revision 1.29 diff -c -r1.29 types.py *** Lib/types.py 14 Jun 2002 20:41:13 -0000 1.29 --- Lib/types.py 18 Jun 2002 14:29:24 -0000 *************** *** 9,89 **** # 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 = long ! FloatType = float ! BooleanType = bool ! try: ! ComplexType = complex ! except NameError: pass ! StringType = str ! ! # StringTypes is already outdated. Instead of writing "type(x) in ! # types.StringTypes", you should use "isinstance(x, basestring)". But ! # we keep around for compatibility with Python 2.2. ! try: ! UnicodeType = unicode ! StringTypes = (StringType, UnicodeType) ! except NameError: ! StringTypes = (StringType,) ! ! BufferType = buffer ! ! TupleType = tuple ! ListType = list ! DictType = DictionaryType = dict ! def _f(): pass ! FunctionType = type(_f) ! LambdaType = type(lambda: None) # Same as FunctionType ! try: ! CodeType = type(_f.func_code) ! except RuntimeError: # Execution in restricted environment pass - def g(): - yield 1 - GeneratorType = type(g()) - del g - class _C: ! def _m(self): pass ! ClassType = type(_C) ! UnboundMethodType = type(_C._m) # Same as MethodType ! _x = _C() ! InstanceType = type(_x) ! MethodType = type(_x._m) ! ! BuiltinFunctionType = type(len) ! BuiltinMethodType = type([].append) # Same as BuiltinFunctionType ! ModuleType = type(sys) ! FileType = file ! XRangeType = xrange try: raise TypeError except TypeError: try: tb = sys.exc_info()[2] ! TracebackType = type(tb) ! FrameType = type(tb.tb_frame) except AttributeError: # In the restricted environment, exc_info returns (None, None, # None) Then, tb.tb_frame gives an attribute error pass tb = None; del tb ! SliceType = slice ! EllipsisType = type(Ellipsis) ! DictProxyType = type(TypeType.__dict__) - del sys, _f, _C, _x # Not for export --- 9,125 ---- # iterator. Don't check the type! Use hasattr to check for both # "__iter__" and "next" attributes instead. ! # builtins: ! basestring = basestring ! bool = bool ! buffer = buffer ! classmethod = classmethod ! dict = dict ! enumerate = enumerate ! file = file ! float = float ! int = int ! list = list ! long = long ! object = object ! property = property ! slice = slice ! staticmethod = staticmethod ! str = str ! super = super ! tuple = tuple ! type = type ! xrange = xrange ! ! try: ! complex = complex ! except NameError: pass ! try: ! unicode = unicode ! except NameError: ! pass ! try: ! code = type((lambda:1).func_code) ! except RuntimeError: # Execution in restricted environment pass class _C: ! def _m(self): yield 1 ! builtin_function_or_method = type(len) ! classobj = type(_C) ! dictproxy = type(type.__dict__) ! ellipsis = type(Ellipsis) ! function = type(lambda:1) ! generator = type(_C()._m()) ! instance = type(_C()) ! instancemethod = type(_C()._m) ! module = type(sys) ! NoneType = type(None) try: raise TypeError except TypeError: try: tb = sys.exc_info()[2] ! traceback = type(tb) ! frame = type(tb.tb_frame) except AttributeError: # In the restricted environment, exc_info returns (None, None, # None) Then, tb.tb_frame gives an attribute error pass tb = None; del tb ! del sys, _C, # Not for export ! ! # for backward compatibility: ! BooleanType = bool ! BufferType = buffer ! BuiltinFunctionType = builtin_function_or_method ! BuiltinMethodType = builtin_function_or_method ! ClassType = classobj ! try: ! CodeType = code ! except NameError: ! pass ! try: ! ComplexType = complex ! except NameError: ! pass ! DictProxyType = dict_proxy ! DictType = DictionaryType = dict ! EllipsisType = ellipsis ! FileType = file ! FloatType = float ! try: ! FrameType = frame ! except NameError: ! Pass ! FunctionType = function ! GeneratorType = generator ! InstanceType = instance ! IntType = int ! LambdaType = function ! ListType = list ! LongType = long ! MethodType = instancemethod ! ModuleType = module ! ObjectType = object ! SliceType = slice ! StringType = str ! TracebackType = traceback ! TupleType = tuple ! TypeType = type ! UnboundMethodType = instancemethod ! try: ! UnicodeType = unicode ! StringTypes = (str, unicode) ! except NameError: ! StringTypes = (str,) ! XRangeType = xrange