Commits

David Schneider committed 574a2ac Merge

merge heads

Comments (0)

Files changed (158)

lib-python/2.7/distutils/command/build_ext.py

 
 __revision__ = "$Id$"
 
-import sys, os, string, re
+import sys, os, string, re, imp
 from types import *
 from site import USER_BASE, USER_SITE
 from distutils.core import Command
     from distutils.ccompiler import show_compilers
     show_compilers()
 
+def _get_c_extension_suffix():
+    for ext, mod, typ in imp.get_suffixes():
+        if typ == imp.C_EXTENSION:
+            return ext
+
 
 class build_ext (Command):
 
         # OS/2 has an 8 character module (extension) limit :-(
         if os.name == "os2":
             ext_path[len(ext_path) - 1] = ext_path[len(ext_path) - 1][:8]
+        # PyPy tweak: first try to get the C extension suffix from
+        # 'imp'.  If it fails we fall back to the 'SO' config var, like
+        # the previous version of this code did.  This should work for
+        # CPython too.  The point is that on PyPy with cpyext, the
+        # config var 'SO' is just ".so" but we want to return
+        # ".pypy-VERSION.so" instead.
+        so_ext = _get_c_extension_suffix()
+        if so_ext is None:
+            so_ext = get_config_var('SO')     # fall-back
         # extensions in debug_mode are named 'module_d.pyd' under windows
-        so_ext = get_config_var('SO')
         if os.name == 'nt' and self.debug:
-            return os.path.join(*ext_path) + '_d' + so_ext
+            so_ext = '_d.pyd'
         return os.path.join(*ext_path) + so_ext
 
     def get_export_symbols (self, ext):

lib-python/2.7/distutils/sysconfig_pypy.py

 
 import sys
 import os
-import imp
 
 from distutils.errors import DistutilsPlatformError
 
 
 _config_vars = None
 
-def _get_so_extension():
-    for ext, mod, typ in imp.get_suffixes():
-        if typ == imp.C_EXTENSION:
-            return ext
-
 def _init_posix():
     """Initialize the module as appropriate for POSIX systems."""
     g = {}
     g['EXE'] = ""
-    g['SO'] = _get_so_extension() or ".so"
+    g['SO'] = ".so"
     g['SOABI'] = g['SO'].rsplit('.')[0]
     g['LIBDIR'] = os.path.join(sys.prefix, 'lib')
     g['CC'] = "gcc -pthread" # -pthread might not be valid on OS/X, check
     """Initialize the module as appropriate for NT"""
     g = {}
     g['EXE'] = ".exe"
-    g['SO'] = _get_so_extension() or ".pyd"
+    g['SO'] = ".pyd"
     g['SOABI'] = g['SO'].rsplit('.')[0]
 
     global _config_vars

lib-python/2.7/logging/__init__.py

     'DEBUG': DEBUG,
     'NOTSET': NOTSET,
 }
+_levelNames = dict(_levelToName)
+_levelNames.update(_nameToLevel)   # backward compatibility
 
 def getLevelName(level):
     """

lib-python/2.7/opcode.py

 hasname.append(201)
 def_op('CALL_METHOD', 202)            # #args not including 'self'
 def_op('BUILD_LIST_FROM_ARG', 203)
+jrel_op('JUMP_IF_NOT_DEBUG', 204)     # jump over assert statements
 
 del def_op, name_op, jrel_op, jabs_op

lib-python/2.7/socket.py

 
 
 _realsocket = socket
+_type = type
 
 # WSA error codes
 if sys.platform.lower().startswith("win"):
 
     __doc__ = _realsocket.__doc__
 
+    __slots__ = ["_sock", "__weakref__"]
+
     def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None):
         if _sock is None:
             _sock = _realsocket(family, type, proto)
+        elif _type(_sock) is _realsocket:
+            _sock._reuse()
+        # PyPy note about refcounting: implemented with _reuse()/_drop()
+        # on the class '_socket.socket'.  Python 3 did it differently
+        # with a reference counter on this class 'socket._socketobject'
+        # instead, but it is a less compatible change (breaks eventlet).
         self._sock = _sock
-        self._io_refs = 0
-        self._closed = False
 
     def send(self, data, flags=0):
-        return self._sock.send(data, flags=flags)
+        return self._sock.send(data, flags)
     send.__doc__ = _realsocket.send.__doc__
 
     def recv(self, buffersize, flags=0):
-        return self._sock.recv(buffersize, flags=flags)
+        return self._sock.recv(buffersize, flags)
     recv.__doc__ = _realsocket.recv.__doc__
 
     def recv_into(self, buffer, nbytes=0, flags=0):
-        return self._sock.recv_into(buffer, nbytes=nbytes, flags=flags)
+        return self._sock.recv_into(buffer, nbytes, flags)
     recv_into.__doc__ = _realsocket.recv_into.__doc__
 
     def recvfrom(self, buffersize, flags=0):
-        return self._sock.recvfrom(buffersize, flags=flags)
+        return self._sock.recvfrom(buffersize, flags)
     recvfrom.__doc__ = _realsocket.recvfrom.__doc__
 
     def recvfrom_into(self, buffer, nbytes=0, flags=0):
-        return self._sock.recvfrom_into(buffer, nbytes=nbytes, flags=flags)
+        return self._sock.recvfrom_into(buffer, nbytes, flags)
     recvfrom_into.__doc__ = _realsocket.recvfrom_into.__doc__
 
     def sendto(self, data, param2, param3=None):
     sendto.__doc__ = _realsocket.sendto.__doc__
 
     def close(self):
-        # This function should not reference any globals. See issue #808164.
+        s = self._sock
+        if type(s) is _realsocket:
+            s._drop()
         self._sock = _closedsocket()
     close.__doc__ = _realsocket.close.__doc__
 
     def accept(self):
         sock, addr = self._sock.accept()
-        return _socketobject(_sock=sock), addr
+        sockobj = _socketobject(_sock=sock)
+        sock._drop()    # already a copy in the _socketobject()
+        return sockobj, addr
     accept.__doc__ = _realsocket.accept.__doc__
 
     def dup(self):
 
         Return a regular file object corresponding to the socket.  The mode
         and bufsize arguments are as for the built-in open() function."""
-        self._io_refs += 1
-        return _fileobject(self, mode, bufsize)
-
-    def _decref_socketios(self):
-        if self._io_refs > 0:
-            self._io_refs -= 1
-        if self._closed:
-            self.close()
-
-    def _real_close(self):
-        # This function should not reference any globals. See issue #808164.
-        self._sock.close()
-
-    def close(self):
-        # This function should not reference any globals. See issue #808164.
-        self._closed = True
-        if self._io_refs <= 0:
-            self._real_close()
+        return _fileobject(self._sock, mode, bufsize)
 
     family = property(lambda self: self._sock.family, doc="the socket family")
     type = property(lambda self: self._sock.type, doc="the socket type")
                  "_close"]
 
     def __init__(self, sock, mode='rb', bufsize=-1, close=False):
+        if type(sock) is _realsocket:
+            sock._reuse()
         self._sock = sock
         self.mode = mode # Not actually used in this version
         if bufsize < 0:
             if self._sock:
                 self.flush()
         finally:
-            if self._sock:
-                if self._close:
-                    self._sock.close()
-                else:
-                    try:
-                        self._sock._decref_socketios()
-                    except AttributeError:
-                        pass  # bah, someone built a _fileobject manually
-                              # with some unexpected replacement of the
-                              # _socketobject class
+            s = self._sock
+            if type(s) is _realsocket:
+                s._drop()
+            if self._close:
+                self._sock.close()
             self._sock = None
 
     def __del__(self):

lib-python/2.7/test/test_code.py

 cellvars: ()
 freevars: ()
 nlocals: 0
-flags: 67
+flags: 1048643
 consts: ("'doc string'", 'None')
 
 """

lib-python/2.7/test/test_dis.py

     pass
 
 dis_bug1333982 = """\
- %-4d         0 LOAD_CONST               1 (0)
-              3 POP_JUMP_IF_TRUE        41
-              6 LOAD_GLOBAL              0 (AssertionError)
-              9 LOAD_FAST                0 (x)
-             12 BUILD_LIST_FROM_ARG      0
-             15 GET_ITER
-        >>   16 FOR_ITER                12 (to 31)
-             19 STORE_FAST               1 (s)
-             22 LOAD_FAST                1 (s)
-             25 LIST_APPEND              2
-             28 JUMP_ABSOLUTE           16
+ %-4d         0 JUMP_IF_NOT_DEBUG       41 (to 44)
+              3 LOAD_CONST               1 (0)
+              6 POP_JUMP_IF_TRUE        44
+              9 LOAD_GLOBAL              0 (AssertionError)
+             12 LOAD_FAST                0 (x)
+             15 BUILD_LIST_FROM_ARG      0
+             18 GET_ITER
+        >>   19 FOR_ITER                12 (to 34)
+             22 STORE_FAST               1 (s)
+             25 LOAD_FAST                1 (s)
+             28 LIST_APPEND              2
+             31 JUMP_ABSOLUTE           19
 
- %-4d   >>   31 LOAD_CONST               2 (1)
-             34 BINARY_ADD
-             35 CALL_FUNCTION            1
-             38 RAISE_VARARGS            1
+ %-4d   >>   34 LOAD_CONST               2 (1)
+             37 BINARY_ADD
+             38 CALL_FUNCTION            1
+             41 RAISE_VARARGS            1
 
- %-4d   >>   41 LOAD_CONST               0 (None)
-             44 RETURN_VALUE
+ %-4d   >>   44 LOAD_CONST               0 (None)
+             47 RETURN_VALUE
 """%(bug1333982.func_code.co_firstlineno + 1,
      bug1333982.func_code.co_firstlineno + 2,
      bug1333982.func_code.co_firstlineno + 3)

lib_pypy/_ctypes/pointer.py

         return self._buffer[0] != 0
 
     contents = property(getcontents, setcontents)
+    _obj = property(getcontents) # byref interface
 
     def _as_ffi_pointer_(self, ffitype):
         return as_ffi_pointer(self, ffitype)

lib_pypy/_ctypes_test.py

-import os, sys
-import tempfile
-
-def compile_shared():
-    """Compile '_ctypes_test.c' into an extension module, and import it
-    """
-    thisdir = os.path.dirname(__file__)
-    output_dir = tempfile.mkdtemp()
-
-    from distutils.ccompiler import new_compiler
-    from distutils import sysconfig
-
-    compiler = new_compiler()
-    compiler.output_dir = output_dir
-
-    # Compile .c file
-    include_dir = os.path.join(thisdir, '..', 'include')
-    if sys.platform == 'win32':
-        ccflags = ['-D_CRT_SECURE_NO_WARNINGS']
-    else:
-        ccflags = ['-fPIC', '-Wimplicit-function-declaration']
-    res = compiler.compile([os.path.join(thisdir, '_ctypes_test.c')],
-                           include_dirs=[include_dir],
-                           extra_preargs=ccflags)
-    object_filename = res[0]
-
-    # set link options
-    output_filename = '_ctypes_test' + sysconfig.get_config_var('SO')
-    if sys.platform == 'win32':
-        # XXX libpypy-c.lib is currently not installed automatically
-        library = os.path.join(thisdir, '..', 'include', 'libpypy-c')
-        if not os.path.exists(library + '.lib'):
-            #For a nightly build
-            library = os.path.join(thisdir, '..', 'include', 'python27')
-        if not os.path.exists(library + '.lib'):
-            # For a local translation
-            library = os.path.join(thisdir, '..', 'pypy', 'goal', 'libpypy-c')
-        libraries = [library, 'oleaut32']
-        extra_ldargs = ['/MANIFEST',  # needed for VC10
-                        '/EXPORT:init_ctypes_test']
-    else:
-        libraries = []
-        extra_ldargs = []
-
-    # link the dynamic library
-    compiler.link_shared_object(
-        [object_filename],
-        output_filename,
-        libraries=libraries,
-        extra_preargs=extra_ldargs)
-
-    # Now import the newly created library, it will replace our module in sys.modules
-    import imp
-    fp, filename, description = imp.find_module('_ctypes_test', path=[output_dir])
-    imp.load_module('_ctypes_test', fp, filename, description)
-
-
+try:
+    import cpyext
+except ImportError:
+    raise ImportError("No module named '_ctypes_test'")
 try:
     import _ctypes
     _ctypes.PyObj_FromPtr = None
 except ImportError:
     pass    # obscure condition of _ctypes_test.py being imported by py.test
 else:
-    compile_shared()
+    import _pypy_testcapi
+    _pypy_testcapi.compile_shared('_ctypes_test.c', '_ctypes_test')

lib_pypy/_curses.py

 def _chtype(ch):
     return int(ffi.cast("chtype", ch))
 
+def _texttype(text):
+    if isinstance(text, str):
+        return text
+    elif isinstance(text, unicode):
+        return str(text)   # default encoding
+    else:
+        raise TypeError("str or unicode expected, got a '%s' object"
+                        % (type(text).__name__,))
+
 
 def _extract_yx(args):
     if len(args) >= 2:
 
     @_argspec(1, 1, 2)
     def addstr(self, y, x, text, attr=None):
+        text = _texttype(text)
         if attr is not None:
             attr_old = lib.getattrs(self._win)
             lib.wattrset(self._win, attr)
 
     @_argspec(2, 1, 2)
     def addnstr(self, y, x, text, n, attr=None):
+        text = _texttype(text)
         if attr is not None:
             attr_old = lib.getattrs(self._win)
             lib.wattrset(self._win, attr)
 
     @_argspec(1, 1, 2)
     def insstr(self, y, x, text, attr=None):
+        text = _texttype(text)
         if attr is not None:
             attr_old = lib.getattrs(self._win)
             lib.wattrset(self._win, attr)
 
     @_argspec(2, 1, 2)
     def insnstr(self, y, x, text, n, attr=None):
+        text = _texttype(text)
         if attr is not None:
             attr_old = lib.getattrs(self._win)
             lib.wattrset(self._win, attr)
 
 
 def putp(text):
+    text = _texttype(text)
     return _check_ERR(lib.putp(text), "putp")
 
 

lib_pypy/_pypy_irc_topic.py

-"""eclguba: flagnk naq frznagvpf bs clguba, fcrrq bs p, erfgevpgvbaf bs wnin naq pbzcvyre reebe zrffntrf nf crargenoyr nf ZHZCF
+__doc__ = """eclguba: flagnk naq frznagvpf bs clguba, fcrrq bs p, erfgevpgvbaf bs wnin naq pbzcvyre reebe zrffntrf nf crargenoyr nf ZHZCF
 pglcrf unf n fcva bs 1/3
 ' ' vf n fcnpr gbb
 Clguba 2.k rfg cerfdhr zbeg, ivir Clguba!

lib_pypy/_pypy_testcapi.py

+import os, sys, imp
+import tempfile
+
+def _get_c_extension_suffix():
+    for ext, mod, typ in imp.get_suffixes():
+        if typ == imp.C_EXTENSION:
+            return ext
+
+
+def compile_shared(csource, modulename):
+    """Compile '_testcapi.c' or '_ctypes_test.c' into an extension module,
+    and import it.
+    """
+    thisdir = os.path.dirname(__file__)
+    output_dir = tempfile.mkdtemp()
+
+    from distutils.ccompiler import new_compiler
+
+    compiler = new_compiler()
+    compiler.output_dir = output_dir
+
+    # Compile .c file
+    include_dir = os.path.join(thisdir, '..', 'include')
+    if sys.platform == 'win32':
+        ccflags = ['-D_CRT_SECURE_NO_WARNINGS']
+    else:
+        ccflags = ['-fPIC', '-Wimplicit-function-declaration']
+    res = compiler.compile([os.path.join(thisdir, csource)],
+                           include_dirs=[include_dir],
+                           extra_preargs=ccflags)
+    object_filename = res[0]
+
+    # set link options
+    output_filename = modulename + _get_c_extension_suffix()
+    if sys.platform == 'win32':
+        # XXX libpypy-c.lib is currently not installed automatically
+        library = os.path.join(thisdir, '..', 'include', 'libpypy-c')
+        if not os.path.exists(library + '.lib'):
+            #For a nightly build
+            library = os.path.join(thisdir, '..', 'include', 'python27')
+        if not os.path.exists(library + '.lib'):
+            # For a local translation
+            library = os.path.join(thisdir, '..', 'pypy', 'goal', 'libpypy-c')
+        libraries = [library, 'oleaut32']
+        extra_ldargs = ['/MANIFEST',  # needed for VC10
+                        '/EXPORT:init' + modulename]
+    else:
+        libraries = []
+        extra_ldargs = []
+
+    # link the dynamic library
+    compiler.link_shared_object(
+        [object_filename],
+        output_filename,
+        libraries=libraries,
+        extra_preargs=extra_ldargs)
+
+    # Now import the newly created library, it will replace the original
+    # module in sys.modules
+    fp, filename, description = imp.find_module(modulename, path=[output_dir])
+    imp.load_module(modulename, fp, filename, description)

lib_pypy/_testcapi.py

-import os, sys
-import tempfile
-
-def compile_shared():
-    """Compile '_testcapi.c' into an extension module, and import it
-    """
-    thisdir = os.path.dirname(__file__)
-    output_dir = tempfile.mkdtemp()
-
-    from distutils.ccompiler import new_compiler
-    from distutils import sysconfig
-
-    compiler = new_compiler()
-    compiler.output_dir = output_dir
-
-    # Compile .c file
-    include_dir = os.path.join(thisdir, '..', 'include')
-    if sys.platform == 'win32':
-        ccflags = ['-D_CRT_SECURE_NO_WARNINGS']
-    else:
-        ccflags = ['-fPIC', '-Wimplicit-function-declaration']
-    res = compiler.compile([os.path.join(thisdir, '_testcapimodule.c')],
-                           include_dirs=[include_dir],
-                           extra_preargs=ccflags)
-    object_filename = res[0]
-
-    # set link options
-    output_filename = '_testcapi' + sysconfig.get_config_var('SO')
-    if sys.platform == 'win32':
-        # XXX libpypy-c.lib is currently not installed automatically
-        library = os.path.join(thisdir, '..', 'include', 'libpypy-c')
-        if not os.path.exists(library + '.lib'):
-            #For a nightly build
-            library = os.path.join(thisdir, '..', 'include', 'python27')
-        if not os.path.exists(library + '.lib'):
-            # For a local translation
-            library = os.path.join(thisdir, '..', 'pypy', 'goal', 'libpypy-c')
-        libraries = [library, 'oleaut32']
-        extra_ldargs = ['/MANIFEST',  # needed for VC10
-                        '/EXPORT:init_testcapi']
-    else:
-        libraries = []
-        extra_ldargs = []
-
-    # link the dynamic library
-    compiler.link_shared_object(
-        [object_filename],
-        output_filename,
-        libraries=libraries,
-        extra_preargs=extra_ldargs)
-
-    # Now import the newly created library, it will replace our module in sys.modules
-    import imp
-    fp, filename, description = imp.find_module('_testcapi', path=[output_dir])
-    imp.load_module('_testcapi', fp, filename, description)
-
 try:
     import cpyext
 except ImportError:
     raise ImportError("No module named '_testcapi'")
 else:
-    compile_shared()
+    import _pypy_testcapi
+    _pypy_testcapi.compile_shared('_testcapimodule.c', '_testcapi')

lib_pypy/cffi/api.py

     backend = ffi._backend
     try:
         if '.' not in name and '/' not in name:
-            raise OSError
+            raise OSError("library not found: %r" % (name,))
         backendlib = backend.load_library(name, flags)
     except OSError:
         import ctypes.util
         path = ctypes.util.find_library(name)
         if path is None:
-            raise OSError("library not found: %r" % (name,))
+            raise     # propagate the original OSError
         backendlib = backend.load_library(path, flags)
     copied_enums = []
     #

lib_pypy/cffi/vengine_cpy.py

         class FFILibrary(object):
             _cffi_python_module = module
             _cffi_ffi = self.ffi
+            _cffi_dir = []
+            def __dir__(self):
+                return FFILibrary._cffi_dir + list(self.__dict__)
         library = FFILibrary()
         module._cffi_setup(lst, ffiplatform.VerificationError, library)
         #
             return ptr[0]
         def setter(library, value):
             ptr[0] = value
-        setattr(library.__class__, name, property(getter, setter))
+        setattr(type(library), name, property(getter, setter))
+        type(library)._cffi_dir.append(name)
 
     # ----------
 

lib_pypy/cffi/vengine_gen.py

         class FFILibrary(types.ModuleType):
             _cffi_generic_module = module
             _cffi_ffi = self.ffi
+            _cffi_dir = []
+            def __dir__(self):
+                return FFILibrary._cffi_dir
         library = FFILibrary("")
         #
         # finally, call the loaded_gen_xxx() functions.  This will set
             newfunction = self._load_constant(False, tp, name, module)
         else:
             indirections = []
-            if any(isinstance(type, model.StructOrUnion) for type in tp.args):
+            if any(isinstance(typ, model.StructOrUnion) for typ in tp.args):
                 indirect_args = []
-                for i, type in enumerate(tp.args):
-                    if isinstance(type, model.StructOrUnion):
-                        type = model.PointerType(type)
-                        indirections.append((i, type))
-                    indirect_args.append(type)
+                for i, typ in enumerate(tp.args):
+                    if isinstance(typ, model.StructOrUnion):
+                        typ = model.PointerType(typ)
+                        indirections.append((i, typ))
+                    indirect_args.append(typ)
                 tp = model.FunctionPtrType(tuple(indirect_args),
                                            tp.result, tp.ellipsis)
             BFunc = self.ffi._get_cached_btype(tp)
             wrappername = '_cffi_f_%s' % name
             newfunction = module.load_function(BFunc, wrappername)
-            for i, type in indirections:
-                newfunction = self._make_struct_wrapper(newfunction, i, type)
+            for i, typ in indirections:
+                newfunction = self._make_struct_wrapper(newfunction, i, typ)
         setattr(library, name, newfunction)
+        type(library)._cffi_dir.append(name)
 
     def _make_struct_wrapper(self, oldfunc, i, tp):
         backend = self.ffi._backend
         is_int = isinstance(tp, model.PrimitiveType) and tp.is_integer_type()
         value = self._load_constant(is_int, tp, name, module)
         setattr(library, name, value)
+        type(library)._cffi_dir.append(name)
 
     # ----------
     # enums
     def _loaded_gen_enum(self, tp, name, module, library):
         for enumerator, enumvalue in zip(tp.enumerators, tp.enumvalues):
             setattr(library, enumerator, enumvalue)
+            type(library)._cffi_dir.append(enumerator)
 
     # ----------
     # macros: for now only for integers
     def _loaded_gen_macro(self, tp, name, module, library):
         value = self._load_constant(True, tp, name, module)
         setattr(library, name, value)
+        type(library)._cffi_dir.append(name)
 
     # ----------
     # global variables
                 BArray = self.ffi._get_cached_btype(tp)
                 value = self.ffi.cast(BArray, value)
             setattr(library, name, value)
+            type(library)._cffi_dir.append(name)
             return
         # remove ptr=<cdata 'int *'> from the library instance, and replace
         # it by a property on the class, which reads/writes into ptr[0].
             return ptr[0]
         def setter(library, value):
             ptr[0] = value
-        setattr(library.__class__, name, property(getter, setter))
+        setattr(type(library), name, property(getter, setter))
+        type(library)._cffi_dir.append(name)
 
 cffimod_header = r'''
 #include <stdio.h>

lib_pypy/greenlet.egg-info

+Metadata-Version: 1.0
+Name: greenlet
+Version: 0.4.0
+Summary: Lightweight in-process concurrent programming
+Home-page: https://github.com/python-greenlet/greenlet
+Author: Ralf Schmitt (for CPython), PyPy team
+Author-email: pypy-dev@python.org
+License: MIT License
+Description: UNKNOWN
+Platform: UNKNOWN

pypy/bin/pyinteractive.py

     BoolOption("completer", "use readline commandline completer",
                default=False, cmdline="-C"),
     BoolOption("optimize",
-               "dummy optimization flag for compatibility with CPython",
+               "skip assert statements and remove docstrings when importing modules"
+               " (this is -OO in regular CPython)",
                default=False, cmdline="-O"),
     BoolOption("no_site_import", "do not 'import site' on initialization",
                default=False, cmdline="-S"),
     space.setitem(space.sys.w_dict, space.wrap('executable'),
                   space.wrap(argv[0]))
 
+    if interactiveconfig.optimize:
+        #change the optimize flag's value and set __debug__ to False
+        space.appexec([], """():
+            import sys
+            flags = list(sys.flags)
+            flags[6] = 2
+            sys.flags = type(sys.flags)(flags)
+            import __pypy__
+            __pypy__.set_debug(False)
+        """)
+
     # call pypy_find_stdlib: the side-effect is that it sets sys.prefix and
     # sys.exec_prefix
     executable = argv[0]

pypy/config/pypyoption.py

      "rctime" , "select", "zipimport", "_lsprof",
      "crypt", "signal", "_rawffi", "termios", "zlib", "bz2",
      "struct", "_hashlib", "_md5", "_sha", "_minimal_curses", "cStringIO",
-     "thread", "itertools", "pyexpat", "_ssl", "array",
+     "thread", "itertools", "pyexpat", "_ssl", "cpyext", "array",
      "binascii", "_multiprocessing", '_warnings',
      "_collections", "_multibytecodec", "micronumpy", "_ffi",
-     "_continuation", "_cffi_backend", "_csv"] # "cpyext", "cppyy"]
-# disabled until problems are fixed
+     "_continuation", "_cffi_backend", "_csv", "cppyy"]
 ))
 
 translation_modules = default_modules.copy()

pypy/doc/__pypy__-module.rst

+
+.. comment: this document is very incomplete, should we generate
+            it automatically?
+
 =======================
 The ``__pypy__`` module
 =======================

pypy/doc/getting-started-dev.rst

 interpreter is written mostly in RPython (with pieces in Python), while
 the RPython compiler is written in Python. The hard to understand part
 is that Python is a meta-programming language for RPython, that is,
-RPython is considered from live objects **after** the imports are done.
+"being valid RPython" is a question that only makes sense on the
+live objects **after** the imports are done.
 This might require more explanation. You start writing RPython from
 ``entry_point``, a good starting point is
 ``rpython/translator/goal/targetnopstandalone.py``. This does not do all that
 In this example ``entry_point`` is RPython,  ``add`` and ``sub`` are RPython,
 however, ``generator`` is not.
 
-A good introductory level articles are available:
+The following introductory level articles are available:
 
 * Laurence Tratt -- `Fast Enough VMs in Fast Enough Time`_.
 

pypy/doc/man/pypy.1.rst

     Inspect interactively after running script.
 
 -O
-    Dummy optimization flag for compatibility with C Python.
+    Skip assert statements.
+
+-OO
+    Remove docstrings when importing modules in addition to -O.
 
 -c *cmd*
     Program passed in as CMD (terminates option list).

pypy/doc/rffi.rst

 Purpose
 -------
 
-This document describes an FFI for RPython language, concentrating
+This document describes an FFI for the RPython language, concentrating
 on low-level backends like C. It describes
 how to declare and call low-level (C) functions from RPython level.
 
 ------
 
 In rffi_ there are various declared types for C-structures, like CCHARP
-(char*), SIZE_T (size_t) and others. refer to file for details. 
+(char*), SIZE_T (size_t) and others. Refer to file for details. 
 Instances of non-primitive types must be alloced by hand, with call 
 to lltype.malloc, and freed by lltype.free both with keyword argument 
 flavor='raw'. There are several helpers like string -> char*

pypy/doc/whatsnew-head.rst

 
 .. branch: on-abort-resops
 Added list of resops to the pypyjit on_abort hook.
+
+.. branch: logging-perf
+Speeds up the stdlib logging module
+
+.. branch: operrfmt-NT
+Adds a couple convenient format specifiers to operationerrfmt
+
+.. branch: win32-fixes3
+Skip and fix some non-translated (own) tests for win32 builds
+
+.. branch: ctypes-byref
+Add the '_obj' attribute on ctypes pointer() and byref() objects

pypy/doc/windows.rst

 PyPy on Windows
 ===============
 
-Pypy is supported on Windows platforms, starting with Windows 2000.
+PyPy is supported on Windows platforms, starting with Windows 2000.
 The following text gives some hints about how to translate the PyPy
 interpreter.
 
 
 or such, depending on your mingw64 download.
 
-hacking on Pypy with the mingw compiler
+hacking on PyPy with the mingw compiler
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Since hacking on Pypy means running tests, you will need a way to specify
+Since hacking on PyPy means running tests, you will need a way to specify
 the mingw compiler when hacking (as opposed to translating). As of
 March 2012, --cc is not a valid option for pytest.py. However if you set an
 environment variable CC to the compliter exe, testing will use it.

pypy/interpreter/app_main.py

 # App-level version of py.py.
 # See test/test_app_main.
 
-# Missing vs CPython: -d, -OO, -t, -v, -x, -3
-"""\
+# Missing vs CPython: -d, -t, -v, -x, -3
+USAGE1 = __doc__ = """\
 Options and arguments (and corresponding environment variables):
 -B     : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x
 -c cmd : program passed in as string (terminates option list)
 -i     : inspect interactively after running script; forces a prompt even
          if stdin does not appear to be a terminal; also PYTHONINSPECT=x
 -m mod : run library module as a script (terminates option list)
--O     : dummy optimization flag for compatibility with CPython
+-O     : skip assert statements
+-OO    : remove docstrings when importing modules in addition to -O
 -R     : ignored (see http://bugs.python.org/issue14621)
 -Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew
 -s     : don't add user site directory to sys.path; also PYTHONNOUSERSITE
 PyPy options and arguments:
 --info : print translation information about this PyPy executable
 """
-USAGE1 = __doc__
 # Missing vs CPython: PYTHONHOME, PYTHONCASEOK
 USAGE2 = """
 Other environment variables:
         sys.py3kwarning = bool(sys.flags.py3k_warning)
         sys.dont_write_bytecode = bool(sys.flags.dont_write_bytecode)
 
+        if sys.flags.optimize >= 1:
+            import __pypy__
+            __pypy__.set_debug(False)
+
         if sys.py3kwarning:
             print >> sys.stderr, (
                 "Warning: pypy does not implement py3k warnings")

pypy/interpreter/argument.py

             args_w = space.fixedview(w_stararg)
         except OperationError, e:
             if e.match(space, space.w_TypeError):
-                w_type = space.type(w_stararg)
-                typename = w_type.getname(space)
-                raise OperationError(
+                raise operationerrfmt(
                     space.w_TypeError,
-                    space.wrap("argument after * must be "
-                               "a sequence, not %s" % (typename,)))
+                    "argument after * must be a sequence, not %T", w_stararg)
             raise
         self.arguments_w = self.arguments_w + args_w
 
                 w_keys = space.call_method(w_starstararg, "keys")
             except OperationError, e:
                 if e.match(space, space.w_AttributeError):
-                    w_type = space.type(w_starstararg)
-                    typename = w_type.getname(space)
-                    raise OperationError(
+                    raise operationerrfmt(
                         space.w_TypeError,
-                        space.wrap("argument after ** must be "
-                                   "a mapping, not %s" % (typename,)))
+                        "argument after ** must be a mapping, not %T",
+                        w_starstararg)
                 raise
             keys_w = space.unpackiterable(w_keys)
         keywords_w = [None] * len(keys_w)

pypy/interpreter/astcompiler/assemble.py

         if w_len is None:
             w_len = space.len(self.w_consts)
             space.setitem(self.w_consts, w_key, w_len)
+        if space.int_w(w_len) == 0:
+            self.scope.doc_removable = False
         return space.int_w(w_len)
 
     def _make_key(self, obj):
     ops.JUMP_IF_FALSE_OR_POP : 0,
     ops.POP_JUMP_IF_TRUE : -1,
     ops.POP_JUMP_IF_FALSE : -1,
+    ops.JUMP_IF_NOT_DEBUG : 0,
 
     ops.BUILD_LIST_FROM_ARG: 1,
 }

pypy/interpreter/astcompiler/ast.py

 
 def Module_get_body(space, w_self):
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
 
 def Interactive_get_body(space, w_self):
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     return space.wrap(w_self.body)
 
 def Expression_set_body(space, w_self, w_new_value):
 
 def Suite_get_body(space, w_self):
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'lineno')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'lineno')
     return space.wrap(w_self.lineno)
 
 def stmt_set_lineno(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 2:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'col_offset')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'col_offset')
     return space.wrap(w_self.col_offset)
 
 def stmt_set_col_offset(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'name')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'name')
     return space.wrap(w_self.name)
 
 def FunctionDef_set_name(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'args')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'args')
     return space.wrap(w_self.args)
 
 def FunctionDef_set_args(space, w_self, w_new_value):
 
 def FunctionDef_get_body(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
 
 def FunctionDef_get_decorator_list(space, w_self):
     if not w_self.initialization_state & 32:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'decorator_list')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'decorator_list')
     if w_self.w_decorator_list is None:
         if w_self.decorator_list is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'name')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'name')
     return space.wrap(w_self.name)
 
 def ClassDef_set_name(space, w_self, w_new_value):
 
 def ClassDef_get_bases(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'bases')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'bases')
     if w_self.w_bases is None:
         if w_self.bases is None:
             list_w = []
 
 def ClassDef_get_body(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
 
 def ClassDef_get_decorator_list(space, w_self):
     if not w_self.initialization_state & 32:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'decorator_list')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'decorator_list')
     if w_self.w_decorator_list is None:
         if w_self.decorator_list is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
     return space.wrap(w_self.value)
 
 def Return_set_value(space, w_self, w_new_value):
 
 def Delete_get_targets(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'targets')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'targets')
     if w_self.w_targets is None:
         if w_self.targets is None:
             list_w = []
 
 def Assign_get_targets(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'targets')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'targets')
     if w_self.w_targets is None:
         if w_self.targets is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
     return space.wrap(w_self.value)
 
 def Assign_set_value(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'target')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'target')
     return space.wrap(w_self.target)
 
 def AugAssign_set_target(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'op')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'op')
     return operator_to_class[w_self.op - 1]()
 
 def AugAssign_set_op(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
     return space.wrap(w_self.value)
 
 def AugAssign_set_value(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'dest')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'dest')
     return space.wrap(w_self.dest)
 
 def Print_set_dest(space, w_self, w_new_value):
 
 def Print_get_values(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'values')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'values')
     if w_self.w_values is None:
         if w_self.values is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'nl')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'nl')
     return space.wrap(w_self.nl)
 
 def Print_set_nl(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'target')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'target')
     return space.wrap(w_self.target)
 
 def For_set_target(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'iter')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'iter')
     return space.wrap(w_self.iter)
 
 def For_set_iter(space, w_self, w_new_value):
 
 def For_get_body(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
 
 def For_get_orelse(space, w_self):
     if not w_self.initialization_state & 32:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'orelse')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'orelse')
     if w_self.w_orelse is None:
         if w_self.orelse is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'test')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'test')
     return space.wrap(w_self.test)
 
 def While_set_test(space, w_self, w_new_value):
 
 def While_get_body(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
 
 def While_get_orelse(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'orelse')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'orelse')
     if w_self.w_orelse is None:
         if w_self.orelse is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'test')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'test')
     return space.wrap(w_self.test)
 
 def If_set_test(space, w_self, w_new_value):
 
 def If_get_body(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
 
 def If_get_orelse(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'orelse')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'orelse')
     if w_self.w_orelse is None:
         if w_self.orelse is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'context_expr')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'context_expr')
     return space.wrap(w_self.context_expr)
 
 def With_set_context_expr(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'optional_vars')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'optional_vars')
     return space.wrap(w_self.optional_vars)
 
 def With_set_optional_vars(space, w_self, w_new_value):
 
 def With_get_body(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'type')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'type')
     return space.wrap(w_self.type)
 
 def Raise_set_type(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'inst')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'inst')
     return space.wrap(w_self.inst)
 
 def Raise_set_inst(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'tback')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'tback')
     return space.wrap(w_self.tback)
 
 def Raise_set_tback(space, w_self, w_new_value):
 
 def TryExcept_get_body(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
 
 def TryExcept_get_handlers(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'handlers')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'handlers')
     if w_self.w_handlers is None:
         if w_self.handlers is None:
             list_w = []
 
 def TryExcept_get_orelse(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'orelse')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'orelse')
     if w_self.w_orelse is None:
         if w_self.orelse is None:
             list_w = []
 
 def TryFinally_get_body(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
 
 def TryFinally_get_finalbody(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'finalbody')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'finalbody')
     if w_self.w_finalbody is None:
         if w_self.finalbody is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'test')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'test')
     return space.wrap(w_self.test)
 
 def Assert_set_test(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'msg')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'msg')
     return space.wrap(w_self.msg)
 
 def Assert_set_msg(space, w_self, w_new_value):
 
 def Import_get_names(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'names')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'names')
     if w_self.w_names is None:
         if w_self.names is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'module')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'module')
     return space.wrap(w_self.module)
 
 def ImportFrom_set_module(space, w_self, w_new_value):
 
 def ImportFrom_get_names(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'names')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'names')
     if w_self.w_names is None:
         if w_self.names is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'level')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'level')
     return space.wrap(w_self.level)
 
 def ImportFrom_set_level(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     return space.wrap(w_self.body)
 
 def Exec_set_body(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'globals')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'globals')
     return space.wrap(w_self.globals)
 
 def Exec_set_globals(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'locals')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'locals')
     return space.wrap(w_self.locals)
 
 def Exec_set_locals(space, w_self, w_new_value):
 
 def Global_get_names(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'names')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'names')
     if w_self.w_names is None:
         if w_self.names is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
     return space.wrap(w_self.value)
 
 def Expr_set_value(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'lineno')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'lineno')
     return space.wrap(w_self.lineno)
 
 def expr_set_lineno(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 2:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'col_offset')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'col_offset')
     return space.wrap(w_self.col_offset)
 
 def expr_set_col_offset(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'op')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'op')
     return boolop_to_class[w_self.op - 1]()
 
 def BoolOp_set_op(space, w_self, w_new_value):
 
 def BoolOp_get_values(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'values')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'values')
     if w_self.w_values is None:
         if w_self.values is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'left')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'left')
     return space.wrap(w_self.left)
 
 def BinOp_set_left(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'op')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'op')
     return operator_to_class[w_self.op - 1]()
 
 def BinOp_set_op(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'right')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'right')
     return space.wrap(w_self.right)
 
 def BinOp_set_right(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'op')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'op')
     return unaryop_to_class[w_self.op - 1]()
 
 def UnaryOp_set_op(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'operand')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'operand')
     return space.wrap(w_self.operand)
 
 def UnaryOp_set_operand(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'args')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'args')
     return space.wrap(w_self.args)
 
 def Lambda_set_args(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     return space.wrap(w_self.body)
 
 def Lambda_set_body(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'test')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'test')
     return space.wrap(w_self.test)
 
 def IfExp_set_test(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     return space.wrap(w_self.body)
 
 def IfExp_set_body(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'orelse')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'orelse')
     return space.wrap(w_self.orelse)
 
 def IfExp_set_orelse(space, w_self, w_new_value):
 
 def Dict_get_keys(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'keys')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'keys')
     if w_self.w_keys is None:
         if w_self.keys is None:
             list_w = []
 
 def Dict_get_values(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'values')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'values')
     if w_self.w_values is None:
         if w_self.values is None:
             list_w = []
 
 def Set_get_elts(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'elts')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'elts')
     if w_self.w_elts is None:
         if w_self.elts is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'elt')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'elt')
     return space.wrap(w_self.elt)
 
 def ListComp_set_elt(space, w_self, w_new_value):
 
 def ListComp_get_generators(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'generators')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'generators')
     if w_self.w_generators is None:
         if w_self.generators is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'elt')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'elt')
     return space.wrap(w_self.elt)
 
 def SetComp_set_elt(space, w_self, w_new_value):
 
 def SetComp_get_generators(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'generators')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'generators')
     if w_self.w_generators is None:
         if w_self.generators is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'key')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'key')
     return space.wrap(w_self.key)
 
 def DictComp_set_key(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
     return space.wrap(w_self.value)
 
 def DictComp_set_value(space, w_self, w_new_value):
 
 def DictComp_get_generators(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'generators')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'generators')
     if w_self.w_generators is None:
         if w_self.generators is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'elt')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'elt')
     return space.wrap(w_self.elt)
 
 def GeneratorExp_set_elt(space, w_self, w_new_value):
 
 def GeneratorExp_get_generators(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'generators')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'generators')
     if w_self.w_generators is None:
         if w_self.generators is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
     return space.wrap(w_self.value)
 
 def Yield_set_value(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'left')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'left')
     return space.wrap(w_self.left)
 
 def Compare_set_left(space, w_self, w_new_value):
 
 def Compare_get_ops(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'ops')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'ops')
     if w_self.w_ops is None:
         if w_self.ops is None:
             list_w = []
 
 def Compare_get_comparators(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'comparators')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'comparators')
     if w_self.w_comparators is None:
         if w_self.comparators is None:
             list_w = []
         if w_obj is not None: