Staging
v0.5.1
https://github.com/python/cpython
Revision c8267ead691e5ded30b3ef94fa6bde40787ed9e4 authored by Éric Araujo on 12 November 2010, 22:26:37 UTC, committed by Éric Araujo on 12 November 2010, 22:26:37 UTC
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r86438 | eric.araujo | 2010-11-12 23:25:23 +0100 (ven., 12 nov. 2010) | 2 lines

  And now for something completely different: Finish fixing #10252 again.
........
1 parent e84e72f
Raw File
Tip revision: c8267ead691e5ded30b3ef94fa6bde40787ed9e4 authored by Éric Araujo on 12 November 2010, 22:26:37 UTC
Merged revisions 86438 via svnmerge from
Tip revision: c8267ea
types.py
"""
Define names for built-in types that aren't directly accessible as a builtin.
"""
import sys

# Iterators in Python aren't a matter of type but of protocol.  A large
# and changing number of builtin types implement *some* flavor of
# iterator.  Don't check the type!  Use hasattr to check for both
# "__iter__" and "__next__" attributes instead.

def _f(): pass
FunctionType = type(_f)
LambdaType = type(lambda: None)         # Same as FunctionType
CodeType = type(_f.__code__)

def _g():
    yield 1
GeneratorType = type(_g())

class _C:
    def _m(self): pass
MethodType = type(_C()._m)

BuiltinFunctionType = type(len)
BuiltinMethodType = type([].append)     # Same as BuiltinFunctionType

ModuleType = type(sys)

try:
    raise TypeError
except TypeError:
    tb = sys.exc_info()[2]
    TracebackType = type(tb)
    FrameType = type(tb.tb_frame)
    tb = None; del tb

# For Jython, the following two types are identical
GetSetDescriptorType = type(FunctionType.__code__)
MemberDescriptorType = type(FunctionType.__globals__)

del sys, _f, _g, _C,                              # Not for export
back to top