[pypy-commit] pypy py3k: Merge heads

marky1991 pypy.commits at gmail.com
Mon Jun 20 18:16:37 EDT 2016


Author: Mark Young <marky1991 at gmail.com>
Branch: py3k
Changeset: r85269:b9b012bb9824
Date: 2016-05-22 14:44 -0400
http://bitbucket.org/pypy/pypy/changeset/b9b012bb9824/

Log:	Merge heads

diff --git a/lib-python/3/test/test_descr.py b/lib-python/3/test/test_descr.py
--- a/lib-python/3/test/test_descr.py
+++ b/lib-python/3/test/test_descr.py
@@ -4526,6 +4526,10 @@
 
         # make sure we have an example of each type of descriptor
         for d, n in zip(descriptors, types):
+            if (support.check_impl_detail(pypy=True) and
+                n in ('method', 'member', 'wrapper')):
+                # PyPy doesn't have these
+                continue
             self.assertEqual(type(d).__name__, n + '_descriptor')
 
         for d in descriptors:
@@ -4539,7 +4543,7 @@
 
         class X:
             pass
-        with self.assertRaises(TypeError):
+        with self.assertRaises((AttributeError, TypeError)):
             del X.__qualname__
 
         self.assertRaises(TypeError, type.__dict__['__qualname__'].__set__,
diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py
--- a/pypy/interpreter/app_main.py
+++ b/pypy/interpreter/app_main.py
@@ -277,7 +277,16 @@
     if StdErrPrinter is not None:
         sys.stderr = sys.__stderr__ = StdErrPrinter(2)
 
-    if 1:  # keep indentation
+    # Hack to avoid recursion issues during bootstrapping: pre-import
+    # the utf-8 and latin-1 codecs
+    encerr = None
+    try:
+        import encodings.utf_8
+        import encodings.latin_1
+    except ImportError as e:
+        encerr = e
+
+    try:
         if encoding and ':' in encoding:
             encoding, errors = encoding.split(':', 1)
         else:
@@ -296,6 +305,10 @@
             print("Python error: <stdin> is a directory, cannot continue",
                   file=sys.stderr)
             os._exit(1)
+    finally:
+        if encerr:
+            display_exception(encerr)
+            del encerr
 
 def create_stdio(fd, writing, name, encoding, errors, unbuffered):
     import io
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1138,12 +1138,14 @@
             old_last_exception = self.last_exception
             self.last_exception = operr
             w_traceback = self.space.wrap(operr.get_traceback())
-            w_suppress = self.call_contextmanager_exit_function(
-                w_exitfunc,
-                operr.w_type,
-                operr.get_w_value(self.space),
-                w_traceback)
-            self.last_exception = old_last_exception
+            try:
+                w_suppress = self.call_contextmanager_exit_function(
+                    w_exitfunc,
+                    operr.w_type,
+                    operr.get_w_value(self.space),
+                    w_traceback)
+            finally:
+                self.last_exception = old_last_exception
             if self.space.is_true(w_suppress):
                 # __exit__() returned True -> Swallow the exception.
                 self.settopvalue(self.space.w_None)
diff --git a/pypy/interpreter/test/test_raise.py b/pypy/interpreter/test/test_raise.py
--- a/pypy/interpreter/test/test_raise.py
+++ b/pypy/interpreter/test/test_raise.py
@@ -439,7 +439,6 @@
             fail('No exception raised')
 
     def test_context_with_suppressed(self):
-        # XXX: requires with statement's WHY_SILENCED
         class RaiseExc:
             def __init__(self, exc):
                 self.exc = exc
diff --git a/pypy/interpreter/test/test_typedef.py b/pypy/interpreter/test/test_typedef.py
--- a/pypy/interpreter/test/test_typedef.py
+++ b/pypy/interpreter/test/test_typedef.py
@@ -60,6 +60,7 @@
     def test_descr_getsetproperty(self):
         from types import FrameType
         assert FrameType.f_lineno.__name__ == 'f_lineno'
+        assert FrameType.f_lineno.__qualname__ == 'frame.f_lineno'
         assert FrameType.f_lineno.__objclass__ is FrameType
         class A(object):
             pass
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -263,6 +263,7 @@
         self.doc = doc
         self.reqcls = cls
         self.name = '<generic property>'
+        self.qualname = None
         self.objclass_getter = objclass_getter
         self.use_closure = use_closure
 
@@ -313,6 +314,21 @@
                 self.reqcls, Arguments(space, [w_obj,
                                                space.wrap(self.name)]))
 
+    def descr_get_qualname(self, space):
+        if self.qualname is None:
+            self.qualname = self._calculate_qualname(space)
+        return self.qualname
+
+    def _calculate_qualname(self, space):
+        if self.reqcls is None:
+            type_qualname = u'?'
+        else:
+            w_type = space.gettypeobject(self.reqcls.typedef)
+            type_qualname = space.unicode_w(
+                space.getattr(w_type, space.wrap('__qualname__')))
+        qualname = u"%s.%s" % (type_qualname, self.name.decode('utf-8'))
+        return space.wrap(qualname)
+
     def descr_get_objclass(space, property):
         return property.objclass_getter(space)
 
@@ -351,6 +367,7 @@
     __set__ = interp2app(GetSetProperty.descr_property_set),
     __delete__ = interp2app(GetSetProperty.descr_property_del),
     __name__ = interp_attrproperty('name', cls=GetSetProperty),
+    __qualname__ = GetSetProperty(GetSetProperty.descr_get_qualname),
     __objclass__ = GetSetProperty(GetSetProperty.descr_get_objclass),
     __doc__ = interp_attrproperty('doc', cls=GetSetProperty),
     )
diff --git a/pypy/module/__builtin__/__init__.py b/pypy/module/__builtin__/__init__.py
--- a/pypy/module/__builtin__/__init__.py
+++ b/pypy/module/__builtin__/__init__.py
@@ -72,8 +72,8 @@
         'max'           : 'functional.max',
         'reversed'      : 'functional.W_ReversedIterator',
         'super'         : 'descriptor.W_Super',
-        'staticmethod'  : 'descriptor.StaticMethod',
-        'classmethod'   : 'descriptor.ClassMethod',
+        'staticmethod'  : 'pypy.interpreter.function.StaticMethod',
+        'classmethod'   : 'pypy.interpreter.function.ClassMethod',
         'property'      : 'descriptor.W_Property',
 
         'globals'       : 'interp_inspect.globals',
diff --git a/pypy/module/__builtin__/descriptor.py b/pypy/module/__builtin__/descriptor.py
--- a/pypy/module/__builtin__/descriptor.py
+++ b/pypy/module/__builtin__/descriptor.py
@@ -1,31 +1,41 @@
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.error import OperationError, oefmt
-from pypy.interpreter.function import StaticMethod, ClassMethod
-from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
+from pypy.interpreter.gateway import WrappedDefault, interp2app, unwrap_spec
 from pypy.interpreter.typedef import (
-    TypeDef, interp_attrproperty_w, generic_new_descr, GetSetProperty)
+    GetSetProperty, TypeDef, generic_new_descr, interp_attrproperty_w)
 from pypy.objspace.descroperation import object_getattribute
 
 
 class W_Super(W_Root):
-    def __init__(self, space, w_starttype, w_objtype, w_self):
+
+    def __init__(self, space):
+        self.w_starttype = None
+        self.w_objtype = None
+        self.w_self = None
+
+    def descr_init(self, space, w_starttype=None, w_obj_or_type=None):
+        if space.is_none(w_starttype):
+            w_starttype, w_obj_or_type = _super_from_frame(space)
+        if space.is_none(w_obj_or_type):
+            w_type = None  # unbound super object
+            w_obj_or_type = space.w_None
+        else:
+            w_type = _supercheck(space, w_starttype, w_obj_or_type)
         self.w_starttype = w_starttype
-        self.w_objtype = w_objtype
-        self.w_self = w_self
+        self.w_objtype = w_type
+        self.w_self = w_obj_or_type
 
     def get(self, space, w_obj, w_type=None):
-        w = space.wrap
         if self.w_self is None or space.is_w(w_obj, space.w_None):
-            return w(self)
+            return self
         else:
             # if type(self) is W_Super:
             #     XXX write a fast path for this common case
-            w_selftype = space.type(w(self))
+            w_selftype = space.type(self)
             return space.call_function(w_selftype, self.w_starttype, w_obj)
 
-    @unwrap_spec(name=str)
-    def getattribute(self, space, name):
-        w = space.wrap
+    def getattribute(self, space, w_name):
+        name = space.str_w(w_name)
         # only use a special logic for bound super objects and not for
         # getting the __class__ of the super object itself.
         if self.w_objtype is not None and name != '__class__':
@@ -45,73 +55,68 @@
                 return space.get_and_call_function(w_get, w_value,
                                                    w_obj, self.w_objtype)
         # fallback to object.__getattribute__()
-        return space.call_function(object_getattribute(space),
-                                   w(self), w(name))
+        return space.call_function(object_getattribute(space), self, w_name)
 
-def descr_new_super(space, w_subtype, w_starttype=None, w_obj_or_type=None):
-    if space.is_none(w_starttype):
-        # Call super(), without args -- fill in from __class__
-        # and first local variable on the stack.
-        ec = space.getexecutioncontext()
-        frame = ec.gettopframe()
-        code = frame.pycode
-        if not code:
-            raise oefmt(space.w_RuntimeError, "super(): no code object")
-        if code.co_argcount == 0:
-            raise oefmt(space.w_RuntimeError, "super(): no arguments")
-        w_obj = frame.locals_cells_stack_w[0]
-        if not w_obj:
-            raise oefmt(space.w_RuntimeError, "super(): arg[0] deleted")
-        index = 0
-        for name in code.co_freevars:
-            if name == "__class__":
-                break
-            index += 1
-        else:
-            raise oefmt(space.w_RuntimeError,
-                        "super(): __class__ cell not found")
-        # a kind of LOAD_DEREF
-        cell = frame._getcell(len(code.co_cellvars) + index)
-        try:
-            w_starttype = cell.get()
-        except ValueError:
-            raise oefmt(space.w_RuntimeError, "super(): empty __class__ cell")
-        w_obj_or_type = w_obj
+def _super_from_frame(space):
+    """super() without args -- fill in from __class__ and first local
+    variable on the stack.
+    """
+    frame = space.getexecutioncontext().gettopframe()
+    code = frame.pycode
+    if not code:
+        raise oefmt(space.w_RuntimeError, "super(): no code object")
+    if code.co_argcount == 0:
+        raise oefmt(space.w_RuntimeError, "super(): no arguments")
+    w_obj = frame.locals_cells_stack_w[0]
+    if not w_obj:
+        raise oefmt(space.w_RuntimeError, "super(): arg[0] deleted")
+    for index, name in enumerate(code.co_freevars):
+        if name == "__class__":
+            break
+    else:
+        raise oefmt(space.w_RuntimeError, "super(): __class__ cell not found")
+    # a kind of LOAD_DEREF
+    cell = frame._getcell(len(code.co_cellvars) + index)
+    try:
+        w_starttype = cell.get()
+    except ValueError:
+        raise oefmt(space.w_RuntimeError, "super(): empty __class__ cell")
+    return w_starttype, w_obj
 
-    if space.is_none(w_obj_or_type):
-        w_type = None  # unbound super object
-        w_obj_or_type = space.w_None
-    else:
-        w_objtype = space.type(w_obj_or_type)
-        if space.is_true(space.issubtype(w_objtype, space.w_type)) and \
-            space.is_true(space.issubtype(w_obj_or_type, w_starttype)):
-            w_type = w_obj_or_type # special case for class methods
-        elif space.is_true(space.issubtype(w_objtype, w_starttype)):
-            w_type = w_objtype # normal case
-        else:
-            try:
-                w_type = space.getattr(w_obj_or_type, space.wrap('__class__'))
-            except OperationError as o:
-                if not o.match(space, space.w_AttributeError):
-                    raise
-                w_type = w_objtype
-            if not space.is_true(space.issubtype(w_type, w_starttype)):
-                raise oefmt(space.w_TypeError,
-                            "super(type, obj): obj must be an instance or "
-                            "subtype of type")
-    # XXX the details of how allocate_instance() should be used are not
-    # really well defined
-    w_result = space.allocate_instance(W_Super, w_subtype)
-    W_Super.__init__(w_result, space, w_starttype, w_type, w_obj_or_type)
-    return w_result
+def _supercheck(space, w_starttype, w_obj_or_type):
+    """Check that the super() call makes sense. Returns a type"""
+    w_objtype = space.type(w_obj_or_type)
+
+    if (space.is_true(space.issubtype(w_objtype, space.w_type)) and
+        space.is_true(space.issubtype(w_obj_or_type, w_starttype))):
+        # special case for class methods
+        return w_obj_or_type
+
+    if space.is_true(space.issubtype(w_objtype, w_starttype)):
+        # normal case
+        return w_objtype
+
+    try:
+        w_type = space.getattr(w_obj_or_type, space.wrap('__class__'))
+    except OperationError as e:
+        if not e.match(space, space.w_AttributeError):
+            raise
+        w_type = w_objtype
+
+    if space.is_true(space.issubtype(w_type, w_starttype)):
+        return w_type
+    raise oefmt(space.w_TypeError,
+                "super(type, obj): obj must be an instance or subtype of type")
 
 W_Super.typedef = TypeDef(
     'super',
-    __new__          = interp2app(descr_new_super),
+    __new__          = generic_new_descr(W_Super),
+    __init__         = interp2app(W_Super.descr_init),
     __thisclass__    = interp_attrproperty_w("w_starttype", W_Super),
     __getattribute__ = interp2app(W_Super.getattribute),
     __get__          = interp2app(W_Super.get),
-    __doc__          =     """super(type) -> unbound super object
+    __doc__          =     """\
+super(type) -> unbound super object
 super(type, obj) -> bound super object; requires isinstance(obj, type)
 super(type, type2) -> bound super object; requires issubclass(type2, type)
 
@@ -129,10 +134,10 @@
     def __init__(self, space):
         pass
 
-    @unwrap_spec(w_fget = WrappedDefault(None),
-                 w_fset = WrappedDefault(None),
-                 w_fdel = WrappedDefault(None),
-                 w_doc = WrappedDefault(None))
+    @unwrap_spec(w_fget=WrappedDefault(None),
+                 w_fset=WrappedDefault(None),
+                 w_fdel=WrappedDefault(None),
+                 w_doc=WrappedDefault(None))
     def init(self, space, w_fget=None, w_fset=None, w_fdel=None, w_doc=None):
         self.w_fget = w_fget
         self.w_fset = w_fset
@@ -142,18 +147,17 @@
         # our __doc__ comes from the getter if we don't have an explicit one
         if (space.is_w(self.w_doc, space.w_None) and
             not space.is_w(self.w_fget, space.w_None)):
-            w_getter_doc = space.findattr(self.w_fget, space.wrap("__doc__"))
+            w_getter_doc = space.findattr(self.w_fget, space.wrap('__doc__'))
             if w_getter_doc is not None:
                 if type(self) is W_Property:
                     self.w_doc = w_getter_doc
                 else:
-                    space.setattr(space.wrap(self), space.wrap("__doc__"),
-                                  w_getter_doc)
+                    space.setattr(self, space.wrap('__doc__'), w_getter_doc)
                 self.getter_doc = True
 
     def get(self, space, w_obj, w_objtype=None):
         if space.is_w(w_obj, space.w_None):
-            return space.wrap(self)
+            return self
         if space.is_w(self.w_fget, space.w_None):
             raise oefmt(space.w_AttributeError, "unreadable attribute")
         return space.call_function(self.w_fget, w_obj)
@@ -191,7 +195,8 @@
         else:
             w_doc = self.w_doc
         w_type = self.getclass(space)
-        return space.call_function(w_type, w_getter, w_setter, w_deleter, w_doc)
+        return space.call_function(w_type, w_getter, w_setter, w_deleter,
+                                   w_doc)
 
     def descr_isabstract(self, space):
         return space.newbool(space.isabstractmethod_w(self.w_fget) or
@@ -200,7 +205,8 @@
 
 W_Property.typedef = TypeDef(
     'property',
-    __doc__ = '''property(fget=None, fset=None, fdel=None, doc=None) -> property attribute
+    __doc__ = '''\
+property(fget=None, fset=None, fdel=None, doc=None) -> property attribute
 
 fget is a function to be used for getting an attribute value, and likewise
 fset is a function for setting, and fdel a function for deleting, an
diff --git a/pypy/module/_cffi_backend/ctypeobj.py b/pypy/module/_cffi_backend/ctypeobj.py
--- a/pypy/module/_cffi_backend/ctypeobj.py
+++ b/pypy/module/_cffi_backend/ctypeobj.py
@@ -233,10 +233,9 @@
     # __________ app-level attributes __________
     def dir(self):
         space = self.space
-        w_self = space.wrap(self)
         lst = [space.wrap(name)
                   for name in _name_of_attributes
-                  if space.findattr(w_self, space.wrap(name)) is not None]
+                  if space.findattr(self, space.wrap(name)) is not None]
         return space.newlist(lst)
 
     def _fget(self, attrchar):
diff --git a/pypy/module/_codecs/test/test_codecs.py b/pypy/module/_codecs/test/test_codecs.py
--- a/pypy/module/_codecs/test/test_codecs.py
+++ b/pypy/module/_codecs/test/test_codecs.py
@@ -141,8 +141,6 @@
 
 class AppTestPartialEvaluation:
     spaceconfig = dict(usemodules=['array',])
-    if sys.platform == 'win32':
-        spaceconfig['usemodules'].append('_winreg')
 
     def test_partial_utf8(self):
         import _codecs
@@ -767,7 +765,7 @@
         try:
             # test for non-latin1 codepage, more general test needed
             import winreg
-            key = winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
+            key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
                         r'System\CurrentControlSet\Control\Nls\CodePage')
             if winreg.QueryValueEx(key, 'ACP')[0] == u'1255':  # non-latin1
                 toencode = u'caf\xbf',b'caf\xbf'
diff --git a/pypy/module/_collections/interp_deque.py b/pypy/module/_collections/interp_deque.py
--- a/pypy/module/_collections/interp_deque.py
+++ b/pypy/module/_collections/interp_deque.py
@@ -389,20 +389,18 @@
     def copy(self):
         "Return a shallow copy of a deque."
         space = self.space
-        w_self = space.wrap(self)
         if self.maxlen == sys.maxint:
-            return space.call_function(space.type(w_self), w_self)
+            return space.call_function(space.type(self), self)
         else:
-            return space.call_function(space.type(w_self), w_self,
+            return space.call_function(space.type(self), self,
                                        space.wrap(self.maxlen))
 
     def reduce(self):
         "Return state information for pickling."
         space = self.space
-        w_self = space.wrap(self)
-        w_type = space.type(w_self)
-        w_dict = space.findattr(w_self, space.wrap('__dict__'))
-        w_list = space.call_function(space.w_list, w_self)
+        w_type = space.type(self)
+        w_dict = space.findattr(self, space.wrap('__dict__'))
+        w_list = space.call_function(space.w_list, self)
         if w_dict is None:
             if self.maxlen == sys.maxint:
                 result = [
diff --git a/pypy/module/_weakref/interp__weakref.py b/pypy/module/_weakref/interp__weakref.py
--- a/pypy/module/_weakref/interp__weakref.py
+++ b/pypy/module/_weakref/interp__weakref.py
@@ -156,12 +156,12 @@
 
 
 class W_WeakrefBase(W_Root):
-    def __init__(w_self, space, w_obj, w_callable):
+    def __init__(self, space, w_obj, w_callable):
         assert w_callable is not space.w_None    # should be really None
-        w_self.space = space
+        self.space = space
         assert w_obj is not None
-        w_self.w_obj_weak = weakref.ref(w_obj)
-        w_self.w_callable = w_callable
+        self.w_obj_weak = weakref.ref(w_obj)
+        self.w_callable = w_callable
 
     @jit.dont_look_inside
     def dereference(self):
@@ -171,8 +171,8 @@
     def clear(self):
         self.w_obj_weak = dead_ref
 
-    def activate_callback(w_self):
-        w_self.space.call_function(w_self.w_callable, w_self)
+    def activate_callback(self):
+        self.space.call_function(self.w_callable, self)
 
     def descr__repr__(self, space):
         w_obj = self.dereference()
@@ -189,9 +189,9 @@
 
 
 class W_Weakref(W_WeakrefBase):
-    def __init__(w_self, space, w_obj, w_callable):
-        W_WeakrefBase.__init__(w_self, space, w_obj, w_callable)
-        w_self.w_hash = None
+    def __init__(self, space, w_obj, w_callable):
+        W_WeakrefBase.__init__(self, space, w_obj, w_callable)
+        self.w_hash = None
 
     def descr__init__weakref(self, space, w_obj, w_callable=None,
                              __args__=None):
diff --git a/pypy/module/_winreg/test/test_winreg.py b/pypy/module/_winreg/test/test_winreg.py
--- a/pypy/module/_winreg/test/test_winreg.py
+++ b/pypy/module/_winreg/test/test_winreg.py
@@ -19,7 +19,7 @@
     canSaveKey = True
 
 class AppTestHKey:
-    spaceconfig = dict(usemodules=('_winreg',))
+    #spaceconfig = dict(usemodules=('_winreg',))
 
     def test_repr(self):
         import winreg
@@ -27,7 +27,7 @@
         assert str(k) == "<PyHKEY:0x123>"
 
 class AppTestFfi:
-    spaceconfig = dict(usemodules=('_winreg',))
+    #spaceconfig = dict(usemodules=('_winreg',))
 
     def setup_class(cls):
         import _winreg
@@ -53,9 +53,9 @@
         w_test_data.append(w_btest)
 
     def teardown_class(cls):
-        import _winreg
+        import winreg
         try:
-            _winreg.DeleteKey(cls.root_key, cls.test_key_name)
+            winreg.DeleteKey(cls.root_key, cls.test_key_name)
         except WindowsError:
             pass
 
diff --git a/pypy/module/bz2/interp_bz2.py b/pypy/module/bz2/interp_bz2.py
--- a/pypy/module/bz2/interp_bz2.py
+++ b/pypy/module/bz2/interp_bz2.py
@@ -349,7 +349,7 @@
     compress = interp2app(W_BZ2Compressor.compress),
     flush = interp2app(W_BZ2Compressor.flush),
 )
-
+W_BZ2Compressor.typedef.acceptable_as_base_class = False
 
 def descr_decompressor__new__(space, w_subtype):
     x = space.allocate_instance(W_BZ2Decompressor, w_subtype)
@@ -457,3 +457,4 @@
     eof = GetSetProperty(W_BZ2Decompressor.eof_w),
     decompress = interp2app(W_BZ2Decompressor.decompress),
 )
+W_BZ2Decompressor.typedef.acceptable_as_base_class = False
diff --git a/pypy/module/posix/app_posix.py b/pypy/module/posix/app_posix.py
--- a/pypy/module/posix/app_posix.py
+++ b/pypy/module/posix/app_posix.py
@@ -54,8 +54,6 @@
         st_flags = structseqfield(23, "user defined flags for file")
 
     def __init__(self, *args, **kw):
-        super(stat_result, self).__init__(*args, **kw)
-
         # If we have been initialized from a tuple,
         # st_?time might be set to None. Initialize it
         # from the int slots.
diff --git a/pypy/module/thread/os_local.py b/pypy/module/thread/os_local.py
--- a/pypy/module/thread/os_local.py
+++ b/pypy/module/thread/os_local.py
@@ -50,10 +50,9 @@
         self.dicts[ec] = w_dict
         # call __init__
         try:
-            w_self = space.wrap(self)
-            w_type = space.type(w_self)
+            w_type = space.type(self)
             w_init = space.getattr(w_type, space.wrap("__init__"))
-            space.call_obj_args(w_init, w_self, self.initargs)
+            space.call_obj_args(w_init, self, self.initargs)
         except:
             # failed, forget w_dict and propagate the exception
             del self.dicts[ec]
diff --git a/pypy/module/zipimport/interp_zipimport.py b/pypy/module/zipimport/interp_zipimport.py
--- a/pypy/module/zipimport/interp_zipimport.py
+++ b/pypy/module/zipimport/interp_zipimport.py
@@ -364,6 +364,28 @@
         space = self.space
         return space.wrap_fsdecoded(self.filename)
 
+    def _find_loader(self, space, fullname):
+        filename = self.make_filename(fullname)
+        for _, _, ext in ENUMERATE_EXTS:
+            if self.have_modulefile(space, filename + ext):
+                return True, None
+        # See if this is a directory (part of a namespace pkg)
+        dirpath = self.prefix + fullname
+        if self.have_modulefile(space, dirpath + ZIPSEP):
+            return True, self.filename + os.path.sep + self.corr_zname(dirpath)
+        return False, None
+
+    @unwrap_spec(fullname='str0')
+    def find_loader(self, space, fullname, w_path=None):
+        found, ns_portion = self._find_loader(space, fullname)
+        if not found:
+            result = [space.w_None, space.newlist([])]
+        elif not ns_portion:
+            result = [self, space.newlist([])]
+        else:
+            result = [space.w_None, space.newlist([space.wrap(ns_portion)])]
+        return space.newtuple(result)
+
 def descr_new_zipimporter(space, w_type, w_name):
     name = space.fsencode_w(w_name)
     ok = False
@@ -422,6 +444,7 @@
     get_filename = interp2app(W_ZipImporter.get_filename),
     is_package  = interp2app(W_ZipImporter.is_package),
     load_module = interp2app(W_ZipImporter.load_module),
+    find_loader = interp2app(W_ZipImporter.find_loader),
     archive     = GetSetProperty(W_ZipImporter.getarchive),
     prefix      = GetSetProperty(W_ZipImporter.getprefix),
 )
diff --git a/pypy/module/zipimport/test/test_zipimport.py b/pypy/module/zipimport/test/test_zipimport.py
--- a/pypy/module/zipimport/test/test_zipimport.py
+++ b/pypy/module/zipimport/test/test_zipimport.py
@@ -440,6 +440,12 @@
         self.writefile('x1test/__init__.py', 'raise ValueError')
         raises(ValueError, __import__, 'x1test', None, None, [])
 
+    def test_namespace_pkg(self):
+        self.writefile('foo/', '')
+        self.writefile('foo/one.py', "attr = 'portion1 foo one'\n")
+        foo = __import__('foo.one', None, None, [])
+        assert foo.one.attr == 'portion1 foo one'
+
 
 if os.sep != '/':
     class AppTestNativePathSep(AppTestZipimport):
diff --git a/pypy/objspace/std/noneobject.py b/pypy/objspace/std/noneobject.py
--- a/pypy/objspace/std/noneobject.py
+++ b/pypy/objspace/std/noneobject.py
@@ -4,7 +4,7 @@
 
 
 class W_NoneObject(W_Root):
-    def unwrap(w_self, space):
+    def unwrap(self, space):
         return None
 
     @staticmethod
diff --git a/pypy/objspace/std/objectobject.py b/pypy/objspace/std/objectobject.py
--- a/pypy/objspace/std/objectobject.py
+++ b/pypy/objspace/std/objectobject.py
@@ -84,23 +84,23 @@
     'object()' call."""
 
 
+def _excess_args(__args__):
+    return bool(__args__.arguments_w) or bool(__args__.keywords)
+
 def descr__new__(space, w_type, __args__):
-    from pypy.objspace.std.objectobject import W_ObjectObject
     from pypy.objspace.std.typeobject import _precheck_for_new
+    w_type = _precheck_for_new(space, w_type)
+
     # don't allow arguments if the default object.__init__() is about
     # to be called
-    w_type = _precheck_for_new(space, w_type)
-    w_parentinit, _ = w_type.lookup_where('__init__')
-    if w_parentinit is space.w_object:
-        try:
-            __args__.fixedunpack(0)
-        except ValueError:
+    if _excess_args(__args__):
+        w_parent_init, _ = space.lookup_in_type_where(w_type, '__init__')
+        if w_parent_init is space.w_object:
             raise oefmt(space.w_TypeError,
-                        "default __new__ takes no parameters")
+                        "object() takes no parameters")
     if w_type.is_abstract():
         _abstract_method_error(space, w_type)
-    w_obj = space.allocate_instance(W_ObjectObject, w_type)
-    return w_obj
+    return space.allocate_instance(W_ObjectObject, w_type)
 
 
 def descr___subclasshook__(space, __args__):
@@ -109,12 +109,10 @@
 
 def descr__init__(space, w_obj, __args__):
     # don't allow arguments unless __new__ is overridden
-    w_type = space.type(w_obj)
-    w_parent_new, _ = space.lookup_in_type_where(w_type, '__new__')
-    if w_parent_new is space.w_object:
-        try:
-            __args__.fixedunpack(0)
-        except ValueError:
+    if _excess_args(__args__):
+        w_type = space.type(w_obj)
+        w_parent_new, _ = space.lookup_in_type_where(w_type, '__new__')
+        if w_parent_new is space.w_object:
             raise oefmt(space.w_TypeError,
                         "object.__init__() takes no parameters")
 
diff --git a/pypy/objspace/std/sliceobject.py b/pypy/objspace/std/sliceobject.py
--- a/pypy/objspace/std/sliceobject.py
+++ b/pypy/objspace/std/sliceobject.py
@@ -12,13 +12,13 @@
 class W_SliceObject(W_Root):
     _immutable_fields_ = ['w_start', 'w_stop', 'w_step']
 
-    def __init__(w_self, w_start, w_stop, w_step):
+    def __init__(self, w_start, w_stop, w_step):
         assert w_start is not None
         assert w_stop is not None
         assert w_step is not None
-        w_self.w_start = w_start
-        w_self.w_stop = w_stop
-        w_self.w_step = w_step
+        self.w_start = w_start
+        self.w_stop = w_stop
+        self.w_step = w_step
 
     def unwrap(w_slice, space):
         return slice(space.unwrap(w_slice.w_start), space.unwrap(w_slice.w_stop), space.unwrap(w_slice.w_step))
diff --git a/pypy/objspace/std/strbufobject.py b/pypy/objspace/std/strbufobject.py
--- a/pypy/objspace/std/strbufobject.py
+++ b/pypy/objspace/std/strbufobject.py
@@ -26,10 +26,10 @@
         else:
             return self.w_str._value
 
-    def __repr__(w_self):
+    def __repr__(self):
         """ representation for debugging purposes """
         return "%s(%r[:%d])" % (
-            w_self.__class__.__name__, w_self.builder, w_self.length)
+            self.__class__.__name__, self.builder, self.length)
 
     def unwrap(self, space):
         return self.force()
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -154,220 +154,220 @@
     w_new_function = None
 
     @dont_look_inside
-    def __init__(w_self, space, name, bases_w, dict_w,
+    def __init__(self, space, name, bases_w, dict_w,
                  overridetypedef=None, force_new_layout=False):
-        w_self.space = space
-        w_self.name = name
-        w_self.qualname = None
-        w_self.bases_w = bases_w
-        w_self.dict_w = dict_w
-        w_self.hasdict = False
-        w_self.hasuserdel = False
-        w_self.weakrefable = False
-        w_self.w_doc = space.w_None
-        w_self.weak_subclasses = []
-        w_self.flag_heaptype = False
-        w_self.flag_cpytype = False
-        w_self.flag_abstract = False
-        w_self.flag_sequence_bug_compat = False
-        w_self.flag_map_or_seq = '?'   # '?' means "don't know, check otherwise"
+        self.space = space
+        self.name = name
+        self.qualname = None
+        self.bases_w = bases_w
+        self.dict_w = dict_w
+        self.hasdict = False
+        self.hasuserdel = False
+        self.weakrefable = False
+        self.w_doc = space.w_None
+        self.weak_subclasses = []
+        self.flag_heaptype = False
+        self.flag_cpytype = False
+        self.flag_abstract = False
+        self.flag_sequence_bug_compat = False
+        self.flag_map_or_seq = '?'   # '?' means "don't know, check otherwise"
 
         if overridetypedef is not None:
             assert not force_new_layout
-            layout = setup_builtin_type(w_self, overridetypedef)
+            layout = setup_builtin_type(self, overridetypedef)
         else:
-            layout = setup_user_defined_type(w_self, force_new_layout)
-        w_self.layout = layout
+            layout = setup_user_defined_type(self, force_new_layout)
+        self.layout = layout
 
-        if not is_mro_purely_of_types(w_self.mro_w):
+        if not is_mro_purely_of_types(self.mro_w):
             pass
         else:
             # the _version_tag should change, whenever the content of
             # dict_w of any of the types in the mro changes, or if the mro
             # itself changes
-            w_self._version_tag = VersionTag()
+            self._version_tag = VersionTag()
         from pypy.objspace.std.mapdict import DictTerminator, NoDictTerminator
         # if the typedef has a dict, then the rpython-class does all the dict
         # management, which means from the point of view of mapdict there is no
         # dict.
-        typedef = w_self.layout.typedef
-        if (w_self.hasdict and not typedef.hasdict):
-            w_self.terminator = DictTerminator(space, w_self)
+        typedef = self.layout.typedef
+        if (self.hasdict and not typedef.hasdict):
+            self.terminator = DictTerminator(space, self)
         else:
-            w_self.terminator = NoDictTerminator(space, w_self)
+            self.terminator = NoDictTerminator(space, self)
 
     def __repr__(self):
         "NOT_RPYTHON"
         return '<W_TypeObject %r at 0x%x>' % (self.name, id(self))
 
-    def mutated(w_self, key):
+    def mutated(self, key):
         """
         The type is being mutated. key is either the string containing the
         specific attribute which is being deleted/set or None to indicate a
         generic mutation.
         """
-        space = w_self.space
-        assert w_self.is_heaptype() or w_self.is_cpytype()
+        space = self.space
+        assert self.is_heaptype() or self.is_cpytype()
 
-        w_self.uses_object_getattribute = False
+        self.uses_object_getattribute = False
         # ^^^ conservative default, fixed during real usage
 
         if (key is None or key == '__eq__' or key == '__hash__'):
-            w_self.compares_by_identity_status = UNKNOWN
+            self.compares_by_identity_status = UNKNOWN
 
         if space.config.objspace.std.newshortcut:
-            w_self.w_new_function = None
+            self.w_new_function = None
 
-        if w_self._version_tag is not None:
-            w_self._version_tag = VersionTag()
+        if self._version_tag is not None:
+            self._version_tag = VersionTag()
 
-        subclasses_w = w_self.get_subclasses()
+        subclasses_w = self.get_subclasses()
         for w_subclass in subclasses_w:
             assert isinstance(w_subclass, W_TypeObject)
             w_subclass.mutated(key)
 
-    def version_tag(w_self):
-        if not we_are_jitted() or w_self.is_heaptype():
-            return w_self._version_tag
+    def version_tag(self):
+        if not we_are_jitted() or self.is_heaptype():
+            return self._version_tag
         # prebuilt objects cannot get their version_tag changed
-        return w_self._pure_version_tag()
+        return self._pure_version_tag()
 
     @elidable_promote()
-    def _pure_version_tag(w_self):
-        return w_self._version_tag
+    def _pure_version_tag(self):
+        return self._version_tag
 
-    def getattribute_if_not_from_object(w_self):
+    def getattribute_if_not_from_object(self):
         """ this method returns the applevel __getattribute__ if that is not
         the one from object, in which case it returns None """
         from pypy.objspace.descroperation import object_getattribute
         if not we_are_jitted():
-            if not w_self.uses_object_getattribute:
+            if not self.uses_object_getattribute:
                 # slow path: look for a custom __getattribute__ on the class
-                w_descr = w_self.lookup('__getattribute__')
+                w_descr = self.lookup('__getattribute__')
                 # if it was not actually overriden in the class, we remember this
                 # fact for the next time.
-                if w_descr is object_getattribute(w_self.space):
-                    w_self.uses_object_getattribute = True
+                if w_descr is object_getattribute(self.space):
+                    self.uses_object_getattribute = True
                 else:
                     return w_descr
             return None
         # in the JIT case, just use a lookup, because it is folded away
         # correctly using the version_tag
-        w_descr = w_self.lookup('__getattribute__')
-        if w_descr is not object_getattribute(w_self.space):
+        w_descr = self.lookup('__getattribute__')
+        if w_descr is not object_getattribute(self.space):
             return w_descr
 
-    def has_object_getattribute(w_self):
-        return w_self.getattribute_if_not_from_object() is None
+    def has_object_getattribute(self):
+        return self.getattribute_if_not_from_object() is None
 
-    def compares_by_identity(w_self):
+    def compares_by_identity(self):
         from pypy.objspace.descroperation import object_hash, type_eq
         #
-        if w_self.compares_by_identity_status != UNKNOWN:
+        if self.compares_by_identity_status != UNKNOWN:
             # fast path
-            return w_self.compares_by_identity_status == COMPARES_BY_IDENTITY
+            return self.compares_by_identity_status == COMPARES_BY_IDENTITY
         #
-        default_hash = object_hash(w_self.space)
-        my_eq = w_self.lookup('__eq__')
-        overrides_eq = (my_eq and my_eq is not type_eq(w_self.space))
+        default_hash = object_hash(self.space)
+        my_eq = self.lookup('__eq__')
+        overrides_eq = (my_eq and my_eq is not type_eq(self.space))
         overrides_eq_cmp_or_hash = (overrides_eq or
-                                    w_self.lookup('__hash__') is not default_hash)
+                                    self.lookup('__hash__') is not default_hash)
         if overrides_eq_cmp_or_hash:
-            w_self.compares_by_identity_status = OVERRIDES_EQ_CMP_OR_HASH
+            self.compares_by_identity_status = OVERRIDES_EQ_CMP_OR_HASH
         else:
-            w_self.compares_by_identity_status = COMPARES_BY_IDENTITY
-        return w_self.compares_by_identity_status == COMPARES_BY_IDENTITY
+            self.compares_by_identity_status = COMPARES_BY_IDENTITY
+        return self.compares_by_identity_status == COMPARES_BY_IDENTITY
 
-    def ready(w_self):
-        for w_base in w_self.bases_w:
+    def ready(self):
+        for w_base in self.bases_w:
             if not isinstance(w_base, W_TypeObject):
                 continue
-            w_base.add_subclass(w_self)
+            w_base.add_subclass(self)
 
     # compute a tuple that fully describes the instance layout
-    def get_full_instance_layout(w_self):
-        layout = w_self.layout
-        return (layout, w_self.hasdict, w_self.weakrefable)
+    def get_full_instance_layout(self):
+        layout = self.layout
+        return (layout, self.hasdict, self.weakrefable)
 
-    def compute_default_mro(w_self):
-        return compute_C3_mro(w_self.space, w_self)
+    def compute_default_mro(self):
+        return compute_C3_mro(self.space, self)
 
-    def getdictvalue(w_self, space, attr):
-        version_tag = w_self.version_tag()
+    def getdictvalue(self, space, attr):
+        version_tag = self.version_tag()
         if version_tag is not None:
             return unwrap_cell(
                 space,
-                w_self._pure_getdictvalue_no_unwrapping(
+                self._pure_getdictvalue_no_unwrapping(
                     space, version_tag, attr))
-        w_value = w_self._getdictvalue_no_unwrapping(space, attr)
+        w_value = self._getdictvalue_no_unwrapping(space, attr)
         return unwrap_cell(space, w_value)
 
-    def _getdictvalue_no_unwrapping(w_self, space, attr):
-        w_value = w_self.dict_w.get(attr, None)
-        if w_self.lazyloaders and w_value is None:
-            if attr in w_self.lazyloaders:
+    def _getdictvalue_no_unwrapping(self, space, attr):
+        w_value = self.dict_w.get(attr, None)
+        if self.lazyloaders and w_value is None:
+            if attr in self.lazyloaders:
                 # very clever next line: it forces the attr string
                 # to be interned.
                 space.new_interned_str(attr)
-                loader = w_self.lazyloaders[attr]
-                del w_self.lazyloaders[attr]
+                loader = self.lazyloaders[attr]
+                del self.lazyloaders[attr]
                 w_value = loader()
                 if w_value is not None:   # None means no such attribute
-                    w_self.dict_w[attr] = w_value
+                    self.dict_w[attr] = w_value
                     return w_value
         return w_value
 
     @elidable
-    def _pure_getdictvalue_no_unwrapping(w_self, space, version_tag, attr):
-        return w_self._getdictvalue_no_unwrapping(space, attr)
+    def _pure_getdictvalue_no_unwrapping(self, space, version_tag, attr):
+        return self._getdictvalue_no_unwrapping(space, attr)
 
-    def setdictvalue(w_self, space, name, w_value):
-        if not w_self.is_heaptype():
+    def setdictvalue(self, space, name, w_value):
+        if not self.is_heaptype():
             raise oefmt(space.w_TypeError,
-                        "can't set attributes on type object '%N'", w_self)
-        if name == "__del__" and name not in w_self.dict_w:
+                        "can't set attributes on type object '%N'", self)
+        if name == "__del__" and name not in self.dict_w:
             msg = ("a __del__ method added to an existing type will not be "
                    "called")
             space.warn(space.wrap(msg), space.w_RuntimeWarning)
-        version_tag = w_self.version_tag()
+        version_tag = self.version_tag()
         if version_tag is not None:
-            w_curr = w_self._pure_getdictvalue_no_unwrapping(
+            w_curr = self._pure_getdictvalue_no_unwrapping(
                     space, version_tag, name)
             w_value = write_cell(space, w_curr, w_value)
             if w_value is None:
                 return True
-        w_self.mutated(name)
-        w_self.dict_w[name] = w_value
+        self.mutated(name)
+        self.dict_w[name] = w_value
         return True
 
-    def deldictvalue(w_self, space, key):
-        if w_self.lazyloaders:
-            w_self._cleanup_()    # force un-lazification
-        if not w_self.is_heaptype():
+    def deldictvalue(self, space, key):
+        if self.lazyloaders:
+            self._cleanup_()    # force un-lazification
+        if not self.is_heaptype():
             raise oefmt(space.w_TypeError,
-                        "can't delete attributes on type object '%N'", w_self)
+                        "can't delete attributes on type object '%N'", self)
         try:
-            del w_self.dict_w[key]
+            del self.dict_w[key]
         except KeyError:
             return False
         else:
-            w_self.mutated(key)
+            self.mutated(key)
             return True
 
-    def lookup(w_self, name):
+    def lookup(self, name):
         # note that this doesn't call __get__ on the result at all
-        space = w_self.space
-        return w_self.lookup_where_with_method_cache(name)[1]
+        space = self.space
+        return self.lookup_where_with_method_cache(name)[1]
 
-    def lookup_where(w_self, name):
-        space = w_self.space
-        return w_self.lookup_where_with_method_cache(name)
+    def lookup_where(self, name):
+        space = self.space
+        return self.lookup_where_with_method_cache(name)
 
     @unroll_safe
-    def lookup_starting_at(w_self, w_starttype, name):
-        space = w_self.space
+    def lookup_starting_at(self, w_starttype, name):
+        space = self.space
         look = False
-        for w_class in w_self.mro_w:
+        for w_class in self.mro_w:
             if w_class is w_starttype:
                 look = True
             elif look:
@@ -377,54 +377,54 @@
         return None
 
     @unroll_safe
-    def _lookup(w_self, key):
+    def _lookup(self, key):
         # nowadays, only called from ../../tool/ann_override.py
-        space = w_self.space
-        for w_class in w_self.mro_w:
+        space = self.space
+        for w_class in self.mro_w:
             w_value = w_class.getdictvalue(space, key)
             if w_value is not None:
                 return w_value
         return None
 
     @unroll_safe
-    def _lookup_where(w_self, key):
+    def _lookup_where(self, key):
         # like _lookup() but also returns the parent class in which the
         # attribute was found
-        space = w_self.space
-        for w_class in w_self.mro_w:
+        space = self.space
+        for w_class in self.mro_w:
             w_value = w_class.getdictvalue(space, key)
             if w_value is not None:
                 return w_class, w_value
         return None, None
 
-    def _lookup_where_all_typeobjects(w_self, key):
-        # like _lookup_where(), but when we know that w_self.mro_w only
+    def _lookup_where_all_typeobjects(self, key):
+        # like _lookup_where(), but when we know that self.mro_w only
         # contains W_TypeObjects.  (It differs from _lookup_where() mostly
         # from a JIT point of view: it cannot invoke arbitrary Python code.)
-        space = w_self.space
-        for w_class in w_self.mro_w:
+        space = self.space
+        for w_class in self.mro_w:
             assert isinstance(w_class, W_TypeObject)
             w_value = w_class._getdictvalue_no_unwrapping(space, key)
             if w_value is not None:
                 return w_class, w_value
         return None, None
 
-    def lookup_where_with_method_cache(w_self, name):
-        space = w_self.space
-        promote(w_self)
-        version_tag = promote(w_self.version_tag())
+    def lookup_where_with_method_cache(self, name):
+        space = self.space
+        promote(self)
+        version_tag = promote(self.version_tag())
         if version_tag is None:
-            tup = w_self._lookup_where(name)
+            tup = self._lookup_where(name)
             return tup
-        tup_w = w_self._pure_lookup_where_with_method_cache(name, version_tag)
+        tup_w = self._pure_lookup_where_with_method_cache(name, version_tag)
         w_class, w_value = tup_w
         if isinstance(w_value, MutableCell):
             return w_class, w_value.unwrap_cell(space)
         return tup_w   # don't make a new tuple, reuse the old one
 
     @elidable
-    def _pure_lookup_where_with_method_cache(w_self, name, version_tag):
-        space = w_self.space
+    def _pure_lookup_where_with_method_cache(self, name, version_tag):
+        space = self.space
         cache = space.fromcache(MethodCache)
         SHIFT2 = r_uint.BITS - space.config.objspace.std.methodcachesizeexp
         SHIFT1 = SHIFT2 - 5
@@ -449,70 +449,70 @@
                 tup = cache.lookup_where[method_hash]
                 if space.config.objspace.std.withmethodcachecounter:
                     cache.hits[name] = cache.hits.get(name, 0) + 1
-#                print "hit", w_self, name
+#                print "hit", self, name
                 return tup
-        tup = w_self._lookup_where_all_typeobjects(name)
+        tup = self._lookup_where_all_typeobjects(name)
         cache.versions[method_hash] = version_tag
         cache.names[method_hash] = name
         cache.lookup_where[method_hash] = tup
         if space.config.objspace.std.withmethodcachecounter:
             cache.misses[name] = cache.misses.get(name, 0) + 1
-#        print "miss", w_self, name
+#        print "miss", self, name
         return tup
 
-    def check_user_subclass(w_self, w_subtype):
-        space = w_self.space
+    def check_user_subclass(self, w_subtype):
+        space = self.space
         if not isinstance(w_subtype, W_TypeObject):
             raise oefmt(space.w_TypeError,
                         "X is not a type object ('%T')", w_subtype)
-        if not w_subtype.issubtype(w_self):
+        if not w_subtype.issubtype(self):
             raise oefmt(space.w_TypeError,
                         "%N.__new__(%N): %N is not a subtype of %N",
-                        w_self, w_subtype, w_subtype, w_self)
-        if w_self.layout.typedef is not w_subtype.layout.typedef:
+                        self, w_subtype, w_subtype, self)
+        if self.layout.typedef is not w_subtype.layout.typedef:
             raise oefmt(space.w_TypeError,
                         "%N.__new__(%N) is not safe, use %N.__new__()",
-                        w_self, w_subtype, w_subtype)
+                        self, w_subtype, w_subtype)
         return w_subtype
 
-    def _cleanup_(w_self):
+    def _cleanup_(self):
         "NOT_RPYTHON.  Forces the lazy attributes to be computed."
-        if 'lazyloaders' in w_self.__dict__:
-            for attr in w_self.lazyloaders.keys():
-                w_self.getdictvalue(w_self.space, attr)
-            del w_self.lazyloaders
+        if 'lazyloaders' in self.__dict__:
+            for attr in self.lazyloaders.keys():
+                self.getdictvalue(self.space, attr)
+            del self.lazyloaders
 
-    def getdict(w_self, space): # returning a dict-proxy!
+    def getdict(self, space): # returning a dict-proxy!
         from pypy.objspace.std.dictproxyobject import DictProxyStrategy
         from pypy.objspace.std.dictproxyobject import W_DictProxyObject
-        if w_self.lazyloaders:
-            w_self._cleanup_()    # force un-lazification
+        if self.lazyloaders:
+            self._cleanup_()    # force un-lazification
         strategy = space.fromcache(DictProxyStrategy)
-        storage = strategy.erase(w_self)
+        storage = strategy.erase(self)
         return W_DictProxyObject(space, strategy, storage)
 
-    def is_heaptype(w_self):
-        return w_self.flag_heaptype
+    def is_heaptype(self):
+        return self.flag_heaptype
 
-    def is_cpytype(w_self):
-        return w_self.flag_cpytype
+    def is_cpytype(self):
+        return self.flag_cpytype
 
-    def is_abstract(w_self):
-        return w_self.flag_abstract
+    def is_abstract(self):
+        return self.flag_abstract
 
-    def set_abstract(w_self, abstract):
-        w_self.flag_abstract = bool(abstract)
+    def set_abstract(self, abstract):
+        self.flag_abstract = bool(abstract)
 
-    def issubtype(w_self, w_type):
-        promote(w_self)
+    def issubtype(self, w_type):
+        promote(self)
         promote(w_type)
         if we_are_jitted():
-            version_tag1 = w_self.version_tag()
+            version_tag1 = self.version_tag()
             version_tag2 = w_type.version_tag()
             if version_tag1 is not None and version_tag2 is not None:
-                res = _pure_issubtype(w_self, w_type, version_tag1, version_tag2)
+                res = _pure_issubtype(self, w_type, version_tag1, version_tag2)
                 return res
-        return _issubtype(w_self, w_type)
+        return _issubtype(self, w_type)
 
     def get_module(self):
         space = self.space
@@ -540,8 +540,8 @@
     def getqualname(self, space):
         return self.qualname or self.getname(space)
 
-    def add_subclass(w_self, w_subclass):
-        space = w_self.space
+    def add_subclass(self, w_subclass):
+        space = self.space
         if not space.config.translation.rweakref:
             # We don't have weakrefs!  In this case, every class stores
             # subclasses in a non-weak list.  ALL CLASSES LEAK!  To make
@@ -554,26 +554,26 @@
 
         assert isinstance(w_subclass, W_TypeObject)
         newref = weakref.ref(w_subclass)
-        for i in range(len(w_self.weak_subclasses)):
-            ref = w_self.weak_subclasses[i]
+        for i in range(len(self.weak_subclasses)):
+            ref = self.weak_subclasses[i]
             if ref() is None:
-                w_self.weak_subclasses[i] = newref
+                self.weak_subclasses[i] = newref
                 return
         else:
-            w_self.weak_subclasses.append(newref)
+            self.weak_subclasses.append(newref)
 
-    def remove_subclass(w_self, w_subclass):
-        space = w_self.space
-        for i in range(len(w_self.weak_subclasses)):
-            ref = w_self.weak_subclasses[i]
+    def remove_subclass(self, w_subclass):
+        space = self.space
+        for i in range(len(self.weak_subclasses)):
+            ref = self.weak_subclasses[i]
             if ref() is w_subclass:
-                del w_self.weak_subclasses[i]
+                del self.weak_subclasses[i]
                 return
 
-    def get_subclasses(w_self):
-        space = w_self.space
+    def get_subclasses(self):
+        space = self.space
         subclasses_w = []
-        for ref in w_self.weak_subclasses:
+        for ref in self.weak_subclasses:
             w_ob = ref()
             if w_ob is not None:
                 subclasses_w.append(w_ob)
diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -26,23 +26,23 @@
     import_from_mixin(StringMethods)
     _immutable_fields_ = ['_value', '_utf8?']
 
-    def __init__(w_self, unistr):
+    def __init__(self, unistr):
         assert isinstance(unistr, unicode)
-        w_self._value = unistr
-        w_self._utf8 = None
+        self._value = unistr
+        self._utf8 = None
 
-    def __repr__(w_self):
+    def __repr__(self):
         """representation for debugging purposes"""
-        return "%s(%r)" % (w_self.__class__.__name__, w_self._value)
+        return "%s(%r)" % (self.__class__.__name__, self._value)
 
-    def unwrap(w_self, space):
+    def unwrap(self, space):
         # for testing
-        return w_self._value
+        return self._value
 
-    def create_if_subclassed(w_self):
-        if type(w_self) is W_UnicodeObject:
-            return w_self
-        return W_UnicodeObject(w_self._value)
+    def create_if_subclassed(self):
+        if type(self) is W_UnicodeObject:
+            return self
+        return W_UnicodeObject(self._value)
 
     def is_w(self, space, w_other):
         if not isinstance(w_other, W_UnicodeObject):
@@ -75,8 +75,8 @@
         self._utf8 = identifier
         return identifier
 
-    def listview_unicode(w_self):
-        return _create_list_from_unicode(w_self._value)
+    def listview_unicode(self):
+        return _create_list_from_unicode(self._value)
 
     def ord(self, space):
         if len(self._value) != 1:


More information about the pypy-commit mailing list