[pypy-commit] pypy remove-list-smm: general progress removing Wrappable, stuff is a bit broken
alex_gaynor
noreply at buildbot.pypy.org
Wed Mar 20 23:56:53 CET 2013
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: remove-list-smm
Changeset: r62591:4f75442b1bcf
Date: 2013-03-20 15:39 -0700
http://bitbucket.org/pypy/pypy/changeset/4f75442b1bcf/
Log: general progress removing Wrappable, stuff is a bit broken
diff too long, truncating to 2000 out of 2161 lines
diff --git a/pypy/interpreter/astcompiler/ast.py b/pypy/interpreter/astcompiler/ast.py
--- a/pypy/interpreter/astcompiler/ast.py
+++ b/pypy/interpreter/astcompiler/ast.py
@@ -1,5 +1,5 @@
# Generated by tools/asdl_py.py
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter import typedef
from pypy.interpreter.gateway import interp2app
from pypy.interpreter.error import OperationError, operationerrfmt
@@ -16,7 +16,7 @@
return w_obj
-class AST(Wrappable):
+class AST(W_Root):
w_dict = None
@@ -82,7 +82,7 @@
pass
-class _FieldsWrapper(Wrappable):
+class _FieldsWrapper(W_Root):
"Hack around the fact we can't store tuples on a TypeDef."
def __init__(self, fields):
diff --git a/pypy/interpreter/astcompiler/tools/asdl_py.py b/pypy/interpreter/astcompiler/tools/asdl_py.py
--- a/pypy/interpreter/astcompiler/tools/asdl_py.py
+++ b/pypy/interpreter/astcompiler/tools/asdl_py.py
@@ -538,7 +538,7 @@
HEAD = """# Generated by tools/asdl_py.py
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter import typedef
from pypy.interpreter.gateway import interp2app
from pypy.interpreter.error import OperationError, operationerrfmt
@@ -555,7 +555,7 @@
return w_obj
-class AST(Wrappable):
+class AST(W_Root):
w_dict = None
@@ -621,7 +621,7 @@
pass
-class _FieldsWrapper(Wrappable):
+class _FieldsWrapper(W_Root):
"Hack around the fact we can\'t store tuples on a TypeDef."
def __init__(self, fields):
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -15,7 +15,7 @@
from rpython.rlib.rarithmetic import r_uint
-__all__ = ['ObjSpace', 'OperationError', 'Wrappable', 'W_Root']
+__all__ = ['ObjSpace', 'OperationError', 'W_Root']
UINT_MAX_32_BITS = r_uint(4294967295)
@@ -220,11 +220,6 @@
return self
-# ---------- backward compatibility: these classes are the same now ----------
-Wrappable = W_Root
-# ----------------------------------------------------------------------------
-
-
class W_InterpIterable(W_Root):
def __init__(self, space, w_iterable):
self.w_iter = space.iter(w_iterable)
@@ -726,7 +721,7 @@
def interp_w(self, RequiredClass, w_obj, can_be_None=False):
"""
Unwrap w_obj, checking that it is an instance of the required internal
- interpreter class (a subclass of Wrappable).
+ interpreter class.
"""
assert RequiredClass is not None
if can_be_None and self.is_none(w_obj):
diff --git a/pypy/interpreter/buffer.py b/pypy/interpreter/buffer.py
--- a/pypy/interpreter/buffer.py
+++ b/pypy/interpreter/buffer.py
@@ -15,7 +15,7 @@
# free the typecheck that __buffer__() really returned a wrapped Buffer.
import operator
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.typedef import TypeDef
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.error import OperationError
@@ -23,7 +23,7 @@
from rpython.rlib.rstring import StringBuilder
-class Buffer(Wrappable):
+class Buffer(W_Root):
"""Abstract base class for memory views."""
__slots__ = () # no extra slot here
@@ -144,6 +144,7 @@
for i in range(len(string)):
self.setitem(start + i, string[i])
+
@unwrap_spec(offset=int, size=int)
def descr_buffer__new__(space, w_subtype, w_object, offset=0, size=-1):
# w_subtype can only be exactly 'buffer' for now
@@ -208,7 +209,7 @@
__mul__ = interp2app(Buffer.descr_mul),
__rmul__ = interp2app(Buffer.descr_mul),
__repr__ = interp2app(Buffer.descr_repr),
- )
+)
Buffer.typedef.acceptable_as_base_class = False
# ____________________________________________________________
diff --git a/pypy/interpreter/eval.py b/pypy/interpreter/eval.py
--- a/pypy/interpreter/eval.py
+++ b/pypy/interpreter/eval.py
@@ -3,10 +3,10 @@
Code and Frame.
"""
from pypy.interpreter.error import OperationError
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
-class Code(Wrappable):
+class Code(W_Root):
"""A code is a compiled version of some source code.
Abstract base class."""
_immutable_ = True
@@ -52,19 +52,20 @@
def funcrun_obj(self, func, w_obj, args):
return self.funcrun(func, args.prepend(w_obj))
-class Frame(Wrappable):
+
+class Frame(W_Root):
"""A frame is an environment supporting the execution of a code object.
Abstract base class."""
def __init__(self, space, w_globals=None):
- self.space = space
- self.w_globals = w_globals # wrapped dict of globals
- self.w_locals = None # wrapped dict of locals
+ self.space = space
+ self.w_globals = w_globals # wrapped dict of globals
+ self.w_locals = None # wrapped dict of locals
def run(self):
"Abstract method to override. Runs the frame"
- raise TypeError, "abstract"
-
+ raise TypeError("abstract")
+
def getdictscope(self):
"Get the locals as a dictionary."
self.fast2locals()
@@ -86,16 +87,16 @@
def getfastscope(self):
"Abstract. Get the fast locals as a list."
- raise TypeError, "abstract"
+ raise TypeError("abstract")
def setfastscope(self, scope_w):
"""Abstract. Initialize the fast locals from a list of values,
where the order is according to self.getcode().signature()."""
- raise TypeError, "abstract"
+ raise TypeError("abstract")
def getfastscopelength(self):
"Abstract. Get the expected number of locals."
- raise TypeError, "abstract"
+ raise TypeError("abstract")
def fast2locals(self):
# Copy values from the fastlocals to self.w_locals
diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -8,21 +8,22 @@
from rpython.rlib.unroll import unrolling_iterable
from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.eval import Code
from pypy.interpreter.argument import Arguments
from rpython.rlib import jit
-from rpython.rlib.debug import make_sure_not_resized
+
funccallunrolling = unrolling_iterable(range(4))
+
@jit.elidable_promote()
def _get_immutable_code(func):
assert not func.can_change_code
return func.code
-class Function(Wrappable):
+class Function(W_Root):
"""A function is a code object captured with some environment:
an object space, a dictionary of globals, default arguments,
and an arbitrary 'closure' passed to the code object."""
@@ -41,7 +42,7 @@
self.w_doc = None # lazily read from code.getdocstring()
self.code = code # Code instance
self.w_func_globals = w_globals # the globals dictionary
- self.closure = closure # normally, list of Cell instances or None
+ self.closure = closure # normally, list of Cell instances or None
self.defs_w = defs_w
self.w_func_dict = None # filled out below if needed
self.w_module = None
@@ -240,7 +241,6 @@
def descr_function_repr(self):
return self.getrepr(self.space, 'function %s' % (self.name,))
-
# delicate
_all = {'': None}
@@ -267,8 +267,8 @@
def descr_function__reduce__(self, space):
from pypy.interpreter.gateway import BuiltinCode
from pypy.interpreter.mixedmodule import MixedModule
- w_mod = space.getbuiltinmodule('_pickle_support')
- mod = space.interp_w(MixedModule, w_mod)
+ w_mod = space.getbuiltinmodule('_pickle_support')
+ mod = space.interp_w(MixedModule, w_mod)
code = self.code
if isinstance(code, BuiltinCode):
new_inst = mod.get('builtin_function')
@@ -276,7 +276,7 @@
space.newtuple([space.wrap(code.identifier)])])
new_inst = mod.get('func_new')
- w = space.wrap
+ w = space.wrap
if self.closure is None:
w_closure = space.w_None
else:
@@ -309,7 +309,6 @@
return nt([new_inst, nt(tup_base), nt(tup_state)])
def descr_function__setstate__(self, space, w_args):
- from pypy.interpreter.pycode import PyCode
args_w = space.unpackiterable(w_args)
try:
(w_name, w_doc, w_code, w_func_globals, w_closure, w_defs,
@@ -354,7 +353,7 @@
self.defs_w = []
return
if not space.is_true(space.isinstance(w_defaults, space.w_tuple)):
- raise OperationError( space.w_TypeError, space.wrap("func_defaults must be set to a tuple object or None") )
+ raise OperationError(space.w_TypeError, space.wrap("func_defaults must be set to a tuple object or None"))
self.defs_w = space.fixedview(w_defaults)
def fdel_func_defaults(self, space):
@@ -381,7 +380,6 @@
"to a string object"))
raise
-
def fdel_func_doc(self, space):
self.w_doc = space.w_None
@@ -420,7 +418,7 @@
def fget_func_closure(self, space):
if self.closure is not None:
- w_res = space.newtuple( [ space.wrap(i) for i in self.closure ] )
+ w_res = space.newtuple([space.wrap(i) for i in self.closure])
else:
w_res = space.w_None
return w_res
@@ -439,7 +437,7 @@
return space.wrap(Method(space, w_function, None, w_cls))
-class Method(Wrappable):
+class Method(W_Root):
"""A method is a function bound to a specific instance or class."""
_immutable_fields_ = ['w_function', 'w_instance', 'w_class']
@@ -585,13 +583,14 @@
tup = [self.w_class, space.wrap(w_function.name)]
else:
tup = [w_instance, space.wrap(w_function.name)]
- elif space.is_w( self.w_class, space.w_None ):
+ elif space.is_w(self.w_class, space.w_None):
tup = [self.w_function, w_instance]
else:
tup = [self.w_function, w_instance, self.w_class]
return space.newtuple([new_inst, space.newtuple(tup)])
-class StaticMethod(Wrappable):
+
+class StaticMethod(W_Root):
"""The staticmethod objects."""
_immutable_fields_ = ['w_function']
@@ -607,7 +606,8 @@
instance.__init__(w_function)
return space.wrap(instance)
-class ClassMethod(Wrappable):
+
+class ClassMethod(W_Root):
"""The classmethod objects."""
_immutable_fields_ = ['w_function']
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -16,8 +16,8 @@
from pypy.interpreter.eval import Code
from pypy.interpreter.argument import Arguments
from pypy.interpreter.signature import Signature
-from pypy.interpreter.baseobjspace import (W_Root, ObjSpace, Wrappable,
- SpaceCache, DescrMismatch)
+from pypy.interpreter.baseobjspace import (W_Root, ObjSpace, SpaceCache,
+ DescrMismatch)
from pypy.interpreter.error import OperationError
from pypy.interpreter.function import ClassMethod, FunctionWithFixedCode
from rpython.rlib import rstackovf
@@ -53,7 +53,7 @@
class UnwrapSpecRecipe(object):
"NOT_RPYTHON"
- bases_order = [Wrappable, W_Root, ObjSpace, Arguments, object]
+ bases_order = [W_Root, ObjSpace, Arguments, object]
def dispatch(self, el, *args):
if isinstance(el, str):
@@ -111,7 +111,7 @@
self.orig_arg = iter(original_sig.argnames).next
def visit_self(self, cls, app_sig):
- self.visit__Wrappable(cls, app_sig)
+ self.visit__W_Root(cls, app_sig)
def checked_space_method(self, typname, app_sig):
argname = self.orig_arg()
@@ -147,14 +147,6 @@
def visit_truncatedint_w(self, el, app_sig):
self.checked_space_method(el, app_sig)
- def visit__Wrappable(self, el, app_sig):
- name = el.__name__
- argname = self.orig_arg()
- assert not argname.startswith('w_'), (
- "unwrapped %s argument %s of built-in function %r should "
- "not start with 'w_'" % (name, argname, self.func))
- app_sig.append(argname)
-
def visit__ObjSpace(self, el, app_sig):
self.orig_arg()
@@ -216,10 +208,6 @@
self.run_args.append("space.descr_self_interp_w(%s, %s)" %
(self.use(typ), self.scopenext()))
- def visit__Wrappable(self, typ):
- self.run_args.append("space.interp_w(%s, %s)" % (self.use(typ),
- self.scopenext()))
-
def visit__ObjSpace(self, el):
self.run_args.append('space')
@@ -353,10 +341,6 @@
self.unwrap.append("space.descr_self_interp_w(%s, %s)" %
(self.use(typ), self.nextarg()))
- def visit__Wrappable(self, typ):
- self.unwrap.append("space.interp_w(%s, %s)" % (self.use(typ),
- self.nextarg()))
-
def visit__ObjSpace(self, el):
if self.finger != 0:
raise FastFuncNotSupported
@@ -541,7 +525,6 @@
# It is a list of types or singleton objects:
# baseobjspace.ObjSpace is used to specify the space argument
# baseobjspace.W_Root is for wrapped arguments to keep wrapped
- # baseobjspace.Wrappable subclasses imply interp_w and a typecheck
# argument.Arguments is for a final rest arguments Arguments object
# 'args_w' for fixedview applied to rest arguments
# 'w_args' for rest arguments passed as wrapped tuple
@@ -560,7 +543,7 @@
assert unwrap_spec[0] == 'self', "self_type without 'self' spec element"
unwrap_spec = list(unwrap_spec)
if descrmismatch is not None:
- assert issubclass(self_type, Wrappable)
+ assert issubclass(self_type, W_Root)
unwrap_spec[0] = ('INTERNAL:self', self_type)
self.descrmismatch_op = descrmismatch
self.descr_reqcls = self_type
@@ -805,7 +788,7 @@
return w_result
-class interp2app(Wrappable):
+class interp2app(W_Root):
"""Build a gateway that calls 'f' at interp-level."""
# Takes optionally an unwrap_spec, see BuiltinCode
@@ -838,7 +821,7 @@
result = cls.instancecache[key]
assert result.__class__ is cls
return result
- self = Wrappable.__new__(cls)
+ self = W_Root.__new__(cls)
cls.instancecache[key] = self
self._code = BuiltinCode(f, unwrap_spec=unwrap_spec,
self_type=self_type,
diff --git a/pypy/interpreter/generator.py b/pypy/interpreter/generator.py
--- a/pypy/interpreter/generator.py
+++ b/pypy/interpreter/generator.py
@@ -1,10 +1,10 @@
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError
from pypy.interpreter.pyopcode import LoopBlock
from rpython.rlib import jit
-class GeneratorIterator(Wrappable):
+class GeneratorIterator(W_Root):
"An iterator created by a generator."
_immutable_fields_ = ['pycode']
@@ -94,7 +94,6 @@
w_val = self.space.w_None
return self.throw(w_type, w_val, w_tb)
-
def throw(self, w_type, w_val, w_tb):
from pypy.interpreter.pytraceback import check_traceback
space = self.space
@@ -164,6 +163,7 @@
jitdriver = jit.JitDriver(greens=['pycode'],
reds=['self', 'frame', 'results'],
name='unpack_into')
+
def unpack_into(self, results):
"""This is a hack for performance: runs the generator and collects
all produced items in a list."""
diff --git a/pypy/interpreter/module.py b/pypy/interpreter/module.py
--- a/pypy/interpreter/module.py
+++ b/pypy/interpreter/module.py
@@ -2,11 +2,12 @@
Module objects.
"""
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError
from rpython.rlib.objectmodel import we_are_translated
-class Module(Wrappable):
+
+class Module(W_Root):
"""A module."""
_immutable_fields_ = ["w_dict?"]
diff --git a/pypy/interpreter/nestedscope.py b/pypy/interpreter/nestedscope.py
--- a/pypy/interpreter/nestedscope.py
+++ b/pypy/interpreter/nestedscope.py
@@ -3,12 +3,12 @@
from pypy.interpreter import function, pycode, pyframe
from pypy.interpreter.astcompiler import consts
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError
from pypy.interpreter.mixedmodule import MixedModule
-class Cell(Wrappable):
+class Cell(W_Root):
"A simple container for a wrapped value."
def __init__(self, w_value=None):
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -6,7 +6,7 @@
import sys
from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter import gateway, function, eval, pyframe, pytraceback
from pypy.interpreter.pycode import PyCode, BytecodeCorruption
from rpython.tool.sourcetools import func_with_new_name
@@ -1141,11 +1141,15 @@
class ExitFrame(Exception):
pass
+
class Return(ExitFrame):
"""Raised when exiting a frame via a 'return' statement."""
+
+
class Yield(ExitFrame):
"""Raised when exiting a frame via a 'yield' statement."""
+
class RaiseWithExplicitTraceback(Exception):
"""Raised at interp-level by a 0- or 3-arguments 'raise' statement."""
def __init__(self, operr):
@@ -1154,7 +1158,7 @@
### Frame Blocks ###
-class SuspendedUnroller(Wrappable):
+class SuspendedUnroller(W_Root):
"""Abstract base class for interpreter-level objects that
instruct the interpreter to change the control flow and the
block stack.
diff --git a/pypy/interpreter/pytraceback.py b/pypy/interpreter/pytraceback.py
--- a/pypy/interpreter/pytraceback.py
+++ b/pypy/interpreter/pytraceback.py
@@ -4,7 +4,7 @@
from rpython.tool.error import offset2lineno
-class PyTraceback(baseobjspace.Wrappable):
+class PyTraceback(baseobjspace.W_Root):
"""Traceback object
Public app-level fields:
@@ -38,7 +38,7 @@
w(self.frame),
w(self.lasti),
w(self.next),
- ]
+ ]
nt = space.newtuple
return nt([new_inst, nt(tup_base), nt(tup_state)])
diff --git a/pypy/interpreter/special.py b/pypy/interpreter/special.py
--- a/pypy/interpreter/special.py
+++ b/pypy/interpreter/special.py
@@ -1,15 +1,17 @@
+from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.baseobjspace import Wrappable
-class Ellipsis(Wrappable):
+class Ellipsis(W_Root):
def __init__(self, space):
- self.space = space
+ self.space = space
+
def descr__repr__(self):
return self.space.wrap('Ellipsis')
-class NotImplemented(Wrappable):
+
+class NotImplemented(W_Root):
def __init__(self, space):
- self.space = space
+ self.space = space
+
def descr__repr__(self):
return self.space.wrap('NotImplemented')
-
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -1,7 +1,7 @@
import py
from pypy.interpreter.argument import Arguments
-from pypy.interpreter.baseobjspace import Wrappable, DescrMismatch
+from pypy.interpreter.baseobjspace import W_Root, DescrMismatch
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter.gateway import (interp2app, BuiltinCode, unwrap_spec,
WrappedDefault)
@@ -381,7 +381,7 @@
"""
else:
cls_name = cls.__name__
- assert issubclass(cls, Wrappable)
+ assert issubclass(cls, W_Root)
source = """
def descr_typecheck_%(name)s(closure, space, w_obj, %(extra)s):
obj = space.descr_self_interp_w(%(cls_name)s, w_obj)
@@ -439,7 +439,7 @@
res = miniglobals['objclass_getter'], cls
return res
-class GetSetProperty(Wrappable):
+class GetSetProperty(W_Root):
_immutable_fields_ = ["fget", "fset", "fdel"]
@specialize.arg(7)
@@ -542,7 +542,7 @@
GetSetProperty.typedef.acceptable_as_base_class = False
-class Member(Wrappable):
+class Member(W_Root):
"""For slots."""
_immutable_ = True
@@ -677,7 +677,7 @@
weakref_descr.name = '__weakref__'
def make_weakref_descr(cls):
- """Make instances of the Wrappable subclass 'cls' weakrefable.
+ """Make instances of the W_Root subclass 'cls' weakrefable.
This returns the '__weakref__' desctriptor to use for the TypeDef.
Note that if the class also defines a custom '__del__', the
__del__ should call self.clear_all_weakrefs() before it clears
@@ -686,10 +686,13 @@
# force the interface into the given cls
def getweakref(self):
return self._lifeline_
+
def setweakref(self, space, weakreflifeline):
self._lifeline_ = weakreflifeline
+
def delweakref(self):
self._lifeline_ = None
+
cls._lifeline_ = None
cls.getweakref = getweakref
cls.setweakref = setweakref
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,4 +1,4 @@
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError
from pypy.interpreter.function import StaticMethod, ClassMethod
from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
@@ -6,7 +6,8 @@
generic_new_descr)
from pypy.objspace.descroperation import object_getattribute
-class W_Super(Wrappable):
+
+class W_Super(W_Root):
def __init__(self, space, w_starttype, w_objtype, w_self):
self.w_starttype = w_starttype
self.w_objtype = w_objtype
@@ -91,7 +92,8 @@
super(C, self).meth(arg)"""
)
-class W_Property(Wrappable):
+
+class W_Property(W_Root):
_immutable_fields_ = ["w_fget", "w_fset", "w_fdel"]
def __init__(self, space):
@@ -192,4 +194,3 @@
# descriptor for the instances.
W_Property.typedef.rawdict['__doc__'] = interp_attrproperty_w('w_doc',
W_Property)
-
diff --git a/pypy/module/__builtin__/functional.py b/pypy/module/__builtin__/functional.py
--- a/pypy/module/__builtin__/functional.py
+++ b/pypy/module/__builtin__/functional.py
@@ -3,7 +3,7 @@
"""
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError
from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
from pypy.interpreter.typedef import TypeDef
@@ -226,8 +226,8 @@
"""
return min_max(space, __args__, "min")
-class W_Enumerate(Wrappable):
+class W_Enumerate(W_Root):
def __init__(self, w_iter, w_start):
self.w_iter = w_iter
self.w_index = w_start
@@ -283,8 +283,8 @@
return space.call_function(w_reversed)
return space.wrap(W_ReversedIterator(space, w_sequence))
-class W_ReversedIterator(Wrappable):
+class W_ReversedIterator(W_Root):
def __init__(self, space, w_sequence):
self.remaining = space.len_w(w_sequence) - 1
if space.lookup(w_sequence, "__getitem__") is None:
@@ -339,8 +339,7 @@
return space.wrap(iterator)
-
-class W_XRange(Wrappable):
+class W_XRange(W_Root):
def __init__(self, space, start, len, step, promote_step=False):
self.space = space
self.start = start
@@ -429,7 +428,8 @@
__reduce__ = interp2app(W_XRange.descr_reduce),
)
-class W_XRangeIterator(Wrappable):
+
+class W_XRangeIterator(W_Root):
def __init__(self, space, current, remaining, step):
self.space = space
self.current = current
@@ -441,7 +441,7 @@
def descr_next(self):
return self.next()
-
+
def next(self):
if self.remaining > 0:
item = self.current
diff --git a/pypy/module/__builtin__/interp_classobj.py b/pypy/module/__builtin__/interp_classobj.py
--- a/pypy/module/__builtin__/interp_classobj.py
+++ b/pypy/module/__builtin__/interp_classobj.py
@@ -2,7 +2,7 @@
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter.gateway import interp2app
from pypy.interpreter.typedef import TypeDef, make_weakref_descr
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.typedef import GetSetProperty, descr_get_dict, descr_set_dict
from rpython.rlib.objectmodel import compute_identity_hash
from rpython.rlib.debug import make_sure_not_resized
@@ -48,7 +48,8 @@
return W_ClassObject(space, w_name, bases_w, w_dict)
-class W_ClassObject(Wrappable):
+
+class W_ClassObject(W_Root):
def __init__(self, space, w_name, bases, w_dict):
self.name = space.str_w(w_name)
make_sure_not_resized(bases)
@@ -315,7 +316,8 @@
w_result.setdict(space, w_dict)
return w_result
-class W_InstanceObject(Wrappable):
+
+class W_InstanceObject(W_Root):
def __init__(self, space, w_class):
# note that user_setup is overridden by the typedef.py machinery
self.user_setup(space, space.gettypeobject(self.typedef))
diff --git a/pypy/module/__builtin__/interp_memoryview.py b/pypy/module/__builtin__/interp_memoryview.py
--- a/pypy/module/__builtin__/interp_memoryview.py
+++ b/pypy/module/__builtin__/interp_memoryview.py
@@ -1,7 +1,7 @@
"""
Implementation of the 'buffer' and 'memoryview' types.
"""
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter import buffer
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.typedef import TypeDef, GetSetProperty
@@ -11,7 +11,7 @@
W_Buffer = buffer.Buffer # actually implemented in pypy.interpreter.buffer
-class W_MemoryView(Wrappable):
+class W_MemoryView(W_Root):
"""Implement the built-in 'memoryview' type as a thin wrapper around
an interp-level buffer.
"""
@@ -110,16 +110,22 @@
def w_get_format(self, space):
return space.wrap("B")
+
def w_get_itemsize(self, space):
return space.wrap(1)
+
def w_get_ndim(self, space):
return space.wrap(1)
+
def w_is_readonly(self, space):
return space.wrap(not isinstance(self.buf, buffer.RWBuffer))
+
def w_get_shape(self, space):
return space.newtuple([space.wrap(self.getlength())])
+
def w_get_strides(self, space):
return space.newtuple([space.wrap(1)])
+
def w_get_suboffsets(self, space):
# I've never seen anyone filling this field
return space.w_None
diff --git a/pypy/module/__pypy__/interp_builders.py b/pypy/module/__pypy__/interp_builders.py
--- a/pypy/module/__pypy__/interp_builders.py
+++ b/pypy/module/__pypy__/interp_builders.py
@@ -1,4 +1,4 @@
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.typedef import TypeDef
@@ -7,7 +7,7 @@
def create_builder(name, strtype, builder_cls):
- class W_Builder(Wrappable):
+ class W_Builder(W_Root):
def __init__(self, space, size):
if size < 0:
self.builder = builder_cls()
diff --git a/pypy/module/__pypy__/interp_identitydict.py b/pypy/module/__pypy__/interp_identitydict.py
--- a/pypy/module/__pypy__/interp_identitydict.py
+++ b/pypy/module/__pypy__/interp_identitydict.py
@@ -1,9 +1,10 @@
from pypy.interpreter.error import OperationError
from pypy.interpreter.typedef import TypeDef
from pypy.interpreter.gateway import interp2app
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
-class W_IdentityDict(Wrappable):
+
+class W_IdentityDict(W_Root):
def __init__(self, space):
self.dict = {}
diff --git a/pypy/module/_cffi_backend/cdataobj.py b/pypy/module/_cffi_backend/cdataobj.py
--- a/pypy/module/_cffi_backend/cdataobj.py
+++ b/pypy/module/_cffi_backend/cdataobj.py
@@ -1,6 +1,6 @@
import operator
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter.gateway import interp2app
from pypy.interpreter.typedef import TypeDef, make_weakref_descr
@@ -13,7 +13,7 @@
from pypy.module._cffi_backend import misc
-class W_CData(Wrappable):
+class W_CData(W_Root):
_attrs_ = ['space', '_cdata', 'ctype', '_lifeline_']
_immutable_fields_ = ['_cdata', 'ctype']
_cdata = lltype.nullptr(rffi.CCHARP.TO)
diff --git a/pypy/module/_cffi_backend/ctypearray.py b/pypy/module/_cffi_backend/ctypearray.py
--- a/pypy/module/_cffi_backend/ctypearray.py
+++ b/pypy/module/_cffi_backend/ctypearray.py
@@ -2,7 +2,7 @@
Arrays.
"""
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter.gateway import interp2app
from pypy.interpreter.typedef import TypeDef
@@ -119,7 +119,7 @@
return W_CTypePtrOrArray._fget(self, attrchar)
-class W_CDataIter(Wrappable):
+class W_CDataIter(W_Root):
_immutable_fields_ = ['ctitem', 'cdata', '_stop'] # but not '_next'
def __init__(self, space, ctitem, cdata):
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
@@ -1,4 +1,4 @@
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter.gateway import interp2app
from pypy.interpreter.typedef import TypeDef, make_weakref_descr, GetSetProperty
@@ -9,8 +9,8 @@
from pypy.module._cffi_backend import cdataobj
-class W_CType(Wrappable):
- _attrs_ = ['space', 'size', 'name', 'name_position', '_lifeline_']
+class W_CType(W_Root):
+ _attrs_ = ['space', 'size', 'name', 'name_position', '_lifeline_']
_immutable_fields_ = ['size?', 'name', 'name_position']
# note that 'size' is not strictly immutable, because it can change
# from -1 to the real value in the W_CTypeStruct subclass.
diff --git a/pypy/module/_cffi_backend/ctypestruct.py b/pypy/module/_cffi_backend/ctypestruct.py
--- a/pypy/module/_cffi_backend/ctypestruct.py
+++ b/pypy/module/_cffi_backend/ctypestruct.py
@@ -3,7 +3,7 @@
"""
from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.typedef import TypeDef, interp_attrproperty
from rpython.rlib import jit
@@ -155,7 +155,7 @@
self.name, n)
-class W_CField(Wrappable):
+class W_CField(W_Root):
_immutable_ = True
BS_REGULAR = -1
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
@@ -1,6 +1,6 @@
import sys
from pypy.interpreter import gateway
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.typedef import TypeDef, make_weakref_descr
from pypy.interpreter.typedef import GetSetProperty
from pypy.interpreter.gateway import interp2app, unwrap_spec
@@ -51,7 +51,7 @@
# ------------------------------------------------------------
-class W_Deque(Wrappable):
+class W_Deque(W_Root):
def __init__(self, space):
self.space = space
self.maxlen = sys.maxint
@@ -504,7 +504,7 @@
# ------------------------------------------------------------
-class W_DequeIter(Wrappable):
+class W_DequeIter(W_Root):
def __init__(self, deque):
self.space = deque.space
self.deque = deque
@@ -547,7 +547,7 @@
# ------------------------------------------------------------
-class W_DequeRevIter(Wrappable):
+class W_DequeRevIter(W_Root):
def __init__(self, deque):
self.space = deque.space
self.deque = deque
diff --git a/pypy/module/_ffi/interp_ffitype.py b/pypy/module/_ffi/interp_ffitype.py
--- a/pypy/module/_ffi/interp_ffitype.py
+++ b/pypy/module/_ffi/interp_ffitype.py
@@ -1,13 +1,13 @@
from rpython.rlib import libffi, clibffi
from rpython.rlib.rarithmetic import intmask
from rpython.rlib import jit
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.typedef import TypeDef, interp_attrproperty
from pypy.interpreter.gateway import interp2app
from pypy.interpreter.error import OperationError
-class W_FFIType(Wrappable):
+class W_FFIType(W_Root):
_immutable_fields_ = ['name', 'w_structdescr', 'w_pointer_to']
def __init__(self, name, ffitype, w_structdescr=None, w_pointer_to=None):
@@ -157,6 +157,7 @@
pass
app_types.__dict__ = build_ffi_types()
+
def descr_new_pointer(space, w_cls, w_pointer_to):
try:
return descr_new_pointer.cache[w_pointer_to]
@@ -168,12 +169,13 @@
else:
w_pointer_to = space.interp_w(W_FFIType, w_pointer_to)
name = '(pointer to %s)' % w_pointer_to.name
- w_result = W_FFIType(name, libffi.types.pointer, w_pointer_to = w_pointer_to)
+ w_result = W_FFIType(name, libffi.types.pointer, w_pointer_to=w_pointer_to)
descr_new_pointer.cache[w_pointer_to] = w_result
return w_result
descr_new_pointer.cache = {}
-class W_types(Wrappable):
+
+class W_types(W_Root):
pass
W_types.typedef = TypeDef(
'types',
diff --git a/pypy/module/_ffi/interp_struct.py b/pypy/module/_ffi/interp_struct.py
--- a/pypy/module/_ffi/interp_struct.py
+++ b/pypy/module/_ffi/interp_struct.py
@@ -4,7 +4,7 @@
from rpython.rlib import jit
from rpython.rlib.rgc import must_be_light_finalizer
from rpython.rlib.rarithmetic import r_uint, r_ulonglong, r_singlefloat, intmask
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.typedef import TypeDef, interp_attrproperty
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.error import operationerrfmt
@@ -13,8 +13,7 @@
from pypy.module._ffi.type_converter import FromAppLevelConverter, ToAppLevelConverter
-class W_Field(Wrappable):
-
+class W_Field(W_Root):
def __init__(self, name, w_ffitype):
self.name = name
self.w_ffitype = w_ffitype
@@ -52,9 +51,9 @@
def __del__(self):
if self.ffistruct:
lltype.free(self.ffistruct, flavor='raw', track_allocation=True)
-
-class W__StructDescr(Wrappable):
+
+class W__StructDescr(W_Root):
def __init__(self, name):
self.w_ffitype = W_FFIType('struct %s' % name, clibffi.FFI_TYPE_NULL,
@@ -155,7 +154,7 @@
NULL = lltype.nullptr(rffi.VOIDP.TO)
-class W__StructInstance(Wrappable):
+class W__StructInstance(W_Root):
_immutable_fields_ = ['structdescr', 'rawmem']
@@ -207,7 +206,7 @@
self.rawmem = rawmem
self.offset = offset
- def get_longlong(self, w_ffitype):
+ def get_longlong(self, w_ffitype):
return libffi.struct_getfield_longlong(libffi.types.slonglong,
self.rawmem, self.offset)
diff --git a/pypy/module/_file/interp_stream.py b/pypy/module/_file/interp_stream.py
--- a/pypy/module/_file/interp_stream.py
+++ b/pypy/module/_file/interp_stream.py
@@ -1,15 +1,16 @@
import py
+
from rpython.rlib import streamio
from rpython.rlib.streamio import StreamErrors
from pypy.interpreter.error import OperationError
-from pypy.interpreter.baseobjspace import ObjSpace, Wrappable
+from pypy.interpreter.baseobjspace import ObjSpace, W_Root
from pypy.interpreter.typedef import TypeDef
from pypy.interpreter.gateway import interp2app
from pypy.interpreter.streamutil import wrap_streamerror, wrap_oserror_as_ioerror
-class W_AbstractStream(Wrappable):
+class W_AbstractStream(W_Root):
"""Base class for interp-level objects that expose streams to app-level"""
slock = None
slockowner = None
@@ -87,6 +88,7 @@
except StreamErrors, e:
raise wrap_streamerror(self.space, e)
+
# ____________________________________________________________
class W_Stream(W_AbstractStream):
diff --git a/pypy/module/_io/interp_iobase.py b/pypy/module/_io/interp_iobase.py
--- a/pypy/module/_io/interp_iobase.py
+++ b/pypy/module/_io/interp_iobase.py
@@ -1,4 +1,4 @@
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.typedef import (
TypeDef, GetSetProperty, generic_new_descr, descr_get_dict, descr_set_dict,
make_weakref_descr)
@@ -37,7 +37,8 @@
space.w_IOError,
space.wrap("file or stream is not seekable"))
-class W_IOBase(Wrappable):
+
+class W_IOBase(W_Root):
def __init__(self, space):
# XXX: IOBase thinks it has to maintain its own internal state in
# `__IOBase_closed` and call flush() by itself, but it is redundant
diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -3,7 +3,7 @@
TypeDef, GetSetProperty, interp_attrproperty_w, interp_attrproperty,
generic_new_descr)
from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError
from rpython.rlib.rarithmetic import intmask, r_ulonglong, r_uint
from rpython.rlib.rbigint import rbigint
@@ -22,7 +22,7 @@
_WINDOWS = sys.platform == 'win32'
-class W_IncrementalNewlineDecoder(Wrappable):
+class W_IncrementalNewlineDecoder(W_Root):
seennl = 0
pendingcr = False
w_decoder = None
diff --git a/pypy/module/_multiprocessing/interp_connection.py b/pypy/module/_multiprocessing/interp_connection.py
--- a/pypy/module/_multiprocessing/interp_connection.py
+++ b/pypy/module/_multiprocessing/interp_connection.py
@@ -1,5 +1,5 @@
from __future__ import with_statement
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.typedef import TypeDef, GetSetProperty
from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
from pypy.interpreter.error import (
@@ -25,7 +25,8 @@
def w_handle(space, handle):
return space.wrap(rffi.cast(rffi.INTPTR_T, handle))
-class W_BaseConnection(Wrappable):
+
+class W_BaseConnection(W_Root):
BUFFER_SIZE = 1024
def __init__(self, flags):
diff --git a/pypy/module/_multiprocessing/interp_semaphore.py b/pypy/module/_multiprocessing/interp_semaphore.py
--- a/pypy/module/_multiprocessing/interp_semaphore.py
+++ b/pypy/module/_multiprocessing/interp_semaphore.py
@@ -1,5 +1,5 @@
from __future__ import with_statement
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.typedef import TypeDef, GetSetProperty
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.error import wrap_oserror, OperationError
@@ -416,7 +416,7 @@
return semlock_getvalue(self, space) == 0
-class W_SemLock(Wrappable):
+class W_SemLock(W_Root):
def __init__(self, handle, kind, maxvalue):
self.handle = handle
self.kind = kind
diff --git a/pypy/module/_random/interp_random.py b/pypy/module/_random/interp_random.py
--- a/pypy/module/_random/interp_random.py
+++ b/pypy/module/_random/interp_random.py
@@ -1,11 +1,12 @@
+import time
+
from pypy.interpreter.error import OperationError
from pypy.interpreter.typedef import TypeDef
from pypy.interpreter.gateway import interp2app, unwrap_spec
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from rpython.rlib.rarithmetic import r_uint, intmask
from rpython.rlib import rbigint, rrandom, rstring
-import time
def descr_new__(space, w_subtype, __args__):
w_anything = __args__.firstarg()
@@ -14,7 +15,8 @@
W_Random.__init__(x, space, w_anything)
return space.wrap(x)
-class W_Random(Wrappable):
+
+class W_Random(W_Root):
def __init__(self, space, w_anything):
self._rnd = rrandom.Random()
self.seed(space, w_anything)
diff --git a/pypy/module/_rawffi/interp_rawffi.py b/pypy/module/_rawffi/interp_rawffi.py
--- a/pypy/module/_rawffi/interp_rawffi.py
+++ b/pypy/module/_rawffi/interp_rawffi.py
@@ -1,4 +1,4 @@
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError, wrap_oserror, operationerrfmt
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.typedef import TypeDef, GetSetProperty
@@ -138,7 +138,7 @@
space.wrap("not supported by libffi"))
-class W_CDLL(Wrappable):
+class W_CDLL(W_Root):
def __init__(self, space, name, cdll):
self.cdll = cdll
self.name = name
@@ -246,7 +246,7 @@
w_exception = space.getattr(w_mod, space.wrap("SegfaultException"))
return OperationError(w_exception, space.wrap(reason))
-class W_DataShape(Wrappable):
+class W_DataShape(W_Root):
_array_shapes = None
size = 0
alignment = 0
@@ -271,7 +271,7 @@
space.wrap(self.alignment)])
-class W_DataInstance(Wrappable):
+class W_DataInstance(W_Root):
def __init__(self, space, size, address=r_uint(0)):
if address:
self.ll_buffer = rffi.cast(rffi.VOIDP, address)
@@ -378,7 +378,8 @@
space.wrap("cannot directly read value"))
wrap_value._annspecialcase_ = 'specialize:arg(1)'
-class W_FuncPtr(Wrappable):
+
+class W_FuncPtr(W_Root):
def __init__(self, space, ptr, argshapes, resshape):
self.ptr = ptr
self.argshapes = argshapes
diff --git a/pypy/module/_sre/interp_sre.py b/pypy/module/_sre/interp_sre.py
--- a/pypy/module/_sre/interp_sre.py
+++ b/pypy/module/_sre/interp_sre.py
@@ -1,5 +1,5 @@
import sys
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.typedef import GetSetProperty, TypeDef
from pypy.interpreter.typedef import interp_attrproperty, interp_attrproperty_w
from pypy.interpreter.typedef import make_weakref_descr
@@ -89,7 +89,7 @@
#
# SRE_Pattern class
-class W_SRE_Pattern(Wrappable):
+class W_SRE_Pattern(W_Root):
_immutable_fields_ = ["code", "flags", "num_groups", "w_groupindex"]
def cannot_copy_w(self):
@@ -320,7 +320,7 @@
#
# SRE_Match class
-class W_SRE_Match(Wrappable):
+class W_SRE_Match(W_Root):
flatten_cache = None
def __init__(self, srepat, ctx):
@@ -493,14 +493,14 @@
regs = GetSetProperty(W_SRE_Match.fget_regs),
)
+
# ____________________________________________________________
#
# SRE_Scanner class
# This is mostly an internal class in CPython.
# Our version is also directly iterable, to make finditer() easier.
-class W_SRE_Scanner(Wrappable):
-
+class W_SRE_Scanner(W_Root):
def __init__(self, pattern, ctx):
self.space = pattern.space
self.srepat = pattern
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
@@ -1,5 +1,5 @@
import py
-from pypy.interpreter.baseobjspace import Wrappable, W_Root
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError
from pypy.interpreter.gateway import interp2app, ObjSpace
from pypy.interpreter.typedef import TypeDef
@@ -150,7 +150,7 @@
assert dead_ref() is None
-class W_WeakrefBase(Wrappable):
+class W_WeakrefBase(W_Root):
def __init__(w_self, space, w_obj, w_callable):
assert w_callable is not space.w_None # should be really None
w_self.space = space
@@ -183,6 +183,7 @@
state = "; to '%s'" % (typename,)
return self.getrepr(space, self.typedef.name, state)
+
class W_Weakref(W_WeakrefBase):
def __init__(w_self, space, w_obj, w_callable):
W_WeakrefBase.__init__(w_self, space, w_obj, w_callable)
@@ -217,8 +218,7 @@
ref2 = w_ref2
w_obj1 = ref1.dereference()
w_obj2 = ref2.dereference()
- if (w_obj1 is None or
- w_obj2 is None):
+ if w_obj1 is None or w_obj2 is None:
return space.is_(ref1, ref2)
return space.eq(w_obj1, w_obj2)
diff --git a/pypy/module/cpyext/methodobject.py b/pypy/module/cpyext/methodobject.py
--- a/pypy/module/cpyext/methodobject.py
+++ b/pypy/module/cpyext/methodobject.py
@@ -1,4 +1,4 @@
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.typedef import TypeDef, GetSetProperty
from pypy.interpreter.argument import Arguments
from pypy.interpreter.typedef import interp_attrproperty, interp_attrproperty_w
@@ -59,7 +59,8 @@
from pypy.module.cpyext.object import PyObject_dealloc
PyObject_dealloc(space, py_obj)
-class W_PyCFunctionObject(Wrappable):
+
+class W_PyCFunctionObject(W_Root):
def __init__(self, space, ml, w_self, w_module=None):
self.ml = ml
self.name = rffi.charp2str(self.ml.c_ml_name)
@@ -144,7 +145,7 @@
return self.getrepr(self.space, "built-in method '%s' of '%s' object" % (self.name, self.w_objclass.getname(self.space)))
-class W_PyCWrapperObject(Wrappable):
+class W_PyCWrapperObject(W_Root):
def __init__(self, space, pto, method_name, wrapper_func, wrapper_func_kwds,
doc, func):
self.space = space
diff --git a/pypy/module/exceptions/interp_exceptions.py b/pypy/module/exceptions/interp_exceptions.py
--- a/pypy/module/exceptions/interp_exceptions.py
+++ b/pypy/module/exceptions/interp_exceptions.py
@@ -72,21 +72,24 @@
+-- BytesWarning
"""
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.typedef import (TypeDef, GetSetProperty, descr_get_dict,
descr_set_dict, descr_del_dict)
from pypy.interpreter.gateway import interp2app
from pypy.interpreter.error import OperationError
from rpython.rlib import rwin32
+
def readwrite_attrproperty_w(name, cls):
def fget(space, obj):
return getattr(obj, name)
+
def fset(space, obj, w_val):
setattr(obj, name, w_val)
return GetSetProperty(fget, fset, cls=cls)
-class W_BaseException(Wrappable):
+
+class W_BaseException(W_Root):
"""Superclass representing the base of the exception hierarchy.
The __getitem__ method is provided for backwards-compatibility
@@ -153,8 +156,8 @@
return self.w_dict
def setdict(self, space, w_dict):
- if not space.is_true(space.isinstance( w_dict, space.w_dict )):
- raise OperationError( space.w_TypeError, space.wrap("setting exceptions's dictionary to a non-dict") )
+ if not space.is_true(space.isinstance(w_dict, space.w_dict)):
+ raise OperationError(space.w_TypeError, space.wrap("setting exceptions's dictionary to a non-dict"))
self.w_dict = w_dict
def descr_reduce(self, space):
diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -8,7 +8,7 @@
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.typedef import TypeDef, generic_new_descr
from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.eval import Code
from pypy.interpreter.pycode import PyCode
from rpython.rlib import streamio, jit
@@ -440,7 +440,7 @@
return w_loader
-class W_NullImporter(Wrappable):
+class W_NullImporter(W_Root):
def __init__(self, space):
pass
diff --git a/pypy/module/itertools/interp_itertools.py b/pypy/module/itertools/interp_itertools.py
--- a/pypy/module/itertools/interp_itertools.py
+++ b/pypy/module/itertools/interp_itertools.py
@@ -1,10 +1,10 @@
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError
from pypy.interpreter.typedef import TypeDef, make_weakref_descr
from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
-class W_Count(Wrappable):
+class W_Count(W_Root):
def __init__(self, space, w_firstval, w_step):
self.space = space
self.w_c = w_firstval
@@ -79,8 +79,7 @@
""")
-class W_Repeat(Wrappable):
-
+class W_Repeat(W_Root):
def __init__(self, space, w_obj, w_times):
self.space = space
self.w_obj = w_obj
@@ -145,8 +144,8 @@
yield object
""")
-class W_TakeWhile(Wrappable):
+class W_TakeWhile(W_Root):
def __init__(self, space, w_predicate, w_iterable):
self.space = space
self.w_predicate = w_predicate
@@ -193,8 +192,8 @@
break
""")
-class W_DropWhile(Wrappable):
+class W_DropWhile(W_Root):
def __init__(self, space, w_predicate, w_iterable):
self.space = space
self.w_predicate = w_predicate
@@ -246,8 +245,8 @@
yield x
""")
-class _IFilterBase(Wrappable):
+class _IFilterBase(W_Root):
def __init__(self, space, w_predicate, w_iterable):
self.space = space
if space.is_w(w_predicate, space.w_None):
@@ -328,7 +327,8 @@
yield x
""")
-class W_ISlice(Wrappable):
+
+class W_ISlice(W_Root):
def __init__(self, space, w_iterable, w_startstop, args_w):
self.iterable = space.iter(w_iterable)
self.space = space
@@ -430,7 +430,7 @@
""")
-class W_Chain(Wrappable):
+class W_Chain(W_Root):
def __init__(self, space, w_iterables):
self.space = space
self.w_iterables = w_iterables
@@ -495,7 +495,8 @@
yield element
""")
-class W_IMap(Wrappable):
+
+class W_IMap(W_Root):
_error_name = "imap"
_immutable_fields_ = ["w_fun", "iterators_w"]
@@ -685,8 +686,7 @@
""")
-class W_Cycle(Wrappable):
-
+class W_Cycle(W_Root):
def __init__(self, space, w_iterable):
self.space = space
self.saved_w = []
@@ -752,8 +752,8 @@
yield element
""")
-class W_StarMap(Wrappable):
+class W_StarMap(W_Root):
def __init__(self, space, w_fun, w_iterable):
self.space = space
self.w_fun = w_fun
@@ -841,7 +841,8 @@
class TeeChainedListNode(object):
w_obj = None
-class W_TeeIterable(Wrappable):
+
+class W_TeeIterable(W_Root):
def __init__(self, space, w_iterator, chained_list):
self.space = space
self.w_iterator = w_iterator
@@ -882,8 +883,7 @@
W_TeeIterable.typedef.acceptable_as_base_class = False
-class W_GroupBy(Wrappable):
-
+class W_GroupBy(W_Root):
def __init__(self, space, w_iterable, w_fun):
self.space = space
self.w_iterable = self.space.iter(w_iterable)
@@ -1001,7 +1001,8 @@
uniquekeys.append(k)
""")
-class W_GroupByIterator(Wrappable):
+
+class W_GroupByIterator(W_Root):
def __init__(self, space, index, groupby):
self.space = space
self.index = index
@@ -1031,7 +1032,7 @@
W_GroupByIterator.typedef.acceptable_as_base_class = False
-class W_Compress(Wrappable):
+class W_Compress(W_Root):
def __init__(self, space, w_data, w_selectors):
self.space = space
self.w_data = space.iter(w_data)
@@ -1073,7 +1074,7 @@
""")
-class W_Product(Wrappable):
+class W_Product(W_Root):
def __init__(self, space, args_w, w_repeat):
self.gears = [
space.fixedview(arg_w) for arg_w in args_w
@@ -1181,7 +1182,7 @@
""")
-class W_Combinations(Wrappable):
+class W_Combinations(W_Root):
def __init__(self, space, pool_w, indices, r):
self.pool_w = pool_w
self.indices = indices
@@ -1299,7 +1300,7 @@
)
-class W_Permutations(Wrappable):
+class W_Permutations(W_Root):
def __init__(self, space, pool_w, r):
self.pool_w = pool_w
self.r = r
diff --git a/pypy/module/select/interp_kqueue.py b/pypy/module/select/interp_kqueue.py
--- a/pypy/module/select/interp_kqueue.py
+++ b/pypy/module/select/interp_kqueue.py
@@ -1,4 +1,4 @@
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError, operationerrfmt, exception_from_errno
from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
from pypy.interpreter.typedef import TypeDef, generic_new_descr, GetSetProperty
@@ -103,7 +103,7 @@
)
-class W_Kqueue(Wrappable):
+class W_Kqueue(W_Root):
def __init__(self, space, kqfd):
self.kqfd = kqfd
@@ -232,7 +232,7 @@
W_Kqueue.typedef.acceptable_as_base_class = False
-class W_Kevent(Wrappable):
+class W_Kevent(W_Root):
def __init__(self, space):
self.event = lltype.nullptr(kevent)
diff --git a/pypy/module/unicodedata/interp_ucd.py b/pypy/module/unicodedata/interp_ucd.py
--- a/pypy/module/unicodedata/interp_ucd.py
+++ b/pypy/module/unicodedata/interp_ucd.py
@@ -1,8 +1,9 @@
"""
Implementation of the interpreter-level functions in the module unicodedata.
"""
-from pypy.interpreter.gateway import interp2app, unwrap_spec
-from pypy.interpreter.baseobjspace import Wrappable
+
+from pypy.interpreter.gateway import interp2app, unwrap_spec
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError
from pypy.interpreter.typedef import TypeDef, interp_attrproperty
from rpython.rlib.rarithmetic import r_longlong
@@ -72,7 +73,7 @@
'need a single Unicode character as parameter'))
-class UCD(Wrappable):
+class UCD(W_Root):
def __init__(self, unicodedb):
self._lookup = unicodedb.lookup
self._name = unicodedb.name
@@ -119,7 +120,6 @@
raise OperationError(space.w_ValueError, space.wrap('no such name'))
return space.wrap(name)
-
def decimal(self, space, w_unichr, w_default=None):
code = unichr_to_code_w(space, w_unichr)
try:
@@ -205,10 +205,10 @@
ch = space.int_w(space.ord(space.getitem(w_unistr, space.wrap(i))))
# Do Hangul decomposition
if SBase <= ch < SBase + SCount:
- SIndex = ch - SBase;
- L = LBase + SIndex / NCount;
- V = VBase + (SIndex % NCount) / TCount;
- T = TBase + SIndex % TCount;
+ SIndex = ch - SBase
+ L = LBase + SIndex / NCount
+ V = VBase + (SIndex % NCount) / TCount
+ T = TBase + SIndex % TCount
if T == TBase:
if j + 2 > resultlen:
result.extend([0] * (j + 2 - resultlen + 10))
@@ -300,7 +300,6 @@
current = next
continue
-
result[next_insert] = next
next_insert += 1
if next_combining > prev_combining:
diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -1,6 +1,6 @@
from rpython.annotator.model import SomeInstance, s_None
from pypy.interpreter import argument, gateway
-from pypy.interpreter.baseobjspace import W_Root, ObjSpace, Wrappable, SpaceCache
+from pypy.interpreter.baseobjspace import W_Root, ObjSpace, SpaceCache
from pypy.interpreter.typedef import TypeDef, GetSetProperty
from pypy.objspace.std.stdtypedef import StdTypeDef
from pypy.objspace.std.sliceobject import W_SliceObject
@@ -14,7 +14,7 @@
from rpython.translator.translator import TranslationContext
-class W_MyObject(Wrappable):
+class W_MyObject(W_Root):
typedef = None
def getdict(self, space):
@@ -47,10 +47,10 @@
def int_w(self, space):
return NonConstant(-42)
-
+
def uint_w(self, space):
return r_uint(NonConstant(42))
-
+
def bigint_w(self, space):
from rpython.rlib.rbigint import rbigint
return rbigint.fromint(NonConstant(42))
@@ -354,9 +354,11 @@
pass
FakeObjSpace.default_compiler = FakeCompiler()
-class FakeModule(Wrappable):
+
+class FakeModule(W_Root):
def __init__(self):
self.w_dict = w_some_obj()
+
def get(self, name):
name + "xx" # check that it's a string
return w_some_obj()
diff --git a/pypy/objspace/fake/test/test_checkmodule.py b/pypy/objspace/fake/test/test_checkmodule.py
--- a/pypy/objspace/fake/test/test_checkmodule.py
+++ b/pypy/objspace/fake/test/test_checkmodule.py
@@ -1,10 +1,11 @@
+from rpython.rlib.objectmodel import specialize
+from rpython.rtyper.test.test_llinterp import interpret
from pypy.objspace.fake.objspace import FakeObjSpace, is_root
-from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.typedef import TypeDef, GetSetProperty
-from pypy.interpreter.gateway import interp2app, W_Root, ObjSpace
-from rpython.rlib.objectmodel import specialize
-from rpython.rtyper.test.test_llinterp import interpret
+from pypy.interpreter.gateway import interp2app, ObjSpace
+
def make_checker():
check = []
@@ -65,7 +66,7 @@
def test_gettypefor_untranslated():
see, check = make_checker()
- class W_Foo(Wrappable):
+ class W_Foo(W_Root):
def do_it(self, space, w_x):
is_root(w_x)
see()
@@ -96,7 +97,7 @@
def test_see_objects():
see, check = make_checker()
- class W_Foo(Wrappable):
+ class W_Foo(W_Root):
def __init__(self, x):
self.x = x
def do_it(self):
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -1666,9 +1666,6 @@
list(sequence) -> new list initialized from sequence's items""",
__new__ = interp2app(descr_new),
__hash__ = None,
- # XXX this cannot work, within the methods the annotation of 'self' is W_Root
- # the reason why it works in modules is that there all classes inherit from Wrappable
- # see gateway.UnwrapSpec_EmitRun.visit__Wrappable vs visit__W_Root
sort = interp2app(W_ListObject.descr_sort),
index = interp2app(W_ListObject.descr_index),
append = interp2app(W_ListObject.append),
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -1,15 +1,15 @@
import __builtin__
import types
from pypy.interpreter import special
-from pypy.interpreter.baseobjspace import ObjSpace, Wrappable
+from pypy.interpreter.baseobjspace import ObjSpace, W_Root
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter.typedef import get_unique_interplevel_subclass
from pypy.objspace.std import (builtinshortcut, stdtypedef, frame, model,
- transparent, callmethod, proxyobject)
+ transparent, callmethod)
from pypy.objspace.descroperation import DescrOperation, raiseattrerror
-from rpython.rlib.objectmodel import instantiate, r_dict, specialize, is_annotation_constant
+from rpython.rlib.objectmodel import instantiate, specialize, is_annotation_constant
from rpython.rlib.debug import make_sure_not_resized
-from rpython.rlib.rarithmetic import base_int, widen, maxint, is_valid_int
+from rpython.rlib.rarithmetic import base_int, widen, is_valid_int
from rpython.rlib.objectmodel import we_are_translated
from rpython.rlib import jit
@@ -162,7 +162,7 @@
return wrapunicode(self, x)
if isinstance(x, float):
return W_FloatObject(x)
- if isinstance(x, Wrappable):
+ if isinstance(x, W_Root):
w_result = x.__spacebind__(self)
#print 'wrapping', x, '->', w_result
return w_result
diff --git a/pypy/objspace/std/proxyobject.py b/pypy/objspace/std/proxyobject.py
--- a/pypy/objspace/std/proxyobject.py
+++ b/pypy/objspace/std/proxyobject.py
@@ -2,39 +2,36 @@
""" transparent list implementation
"""
-from pypy.objspace.std.model import registerimplementation, W_Object
-from pypy.objspace.std.proxy_helpers import register_type
+from pypy.objspace.std.model import W_Object
from pypy.interpreter.error import OperationError
-from pypy.interpreter import baseobjspace, argument
+from pypy.interpreter import baseobjspace
#class W_Transparent(W_Object):
# def __init__(self, w_controller):
# self.controller = w_controller
-#class W_TransparentWrappable(Wrappable):
def transparent_class(name, BaseCls):
-
class W_Transparent(BaseCls):
ignore_for_isinstance_cache = True
def __init__(self, space, w_type, w_controller):
self.w_type = w_type
self.w_controller = w_controller
-
+
def descr_call_mismatch(self, space, name, reqcls, args):
args_w = args.arguments_w[:]
args_w[0] = space.wrap(name)
args = args.replace_arguments(args_w)
return space.call_args(self.w_controller, args)
-
+
def getclass(self, space):
return self.w_type
-
+
def setclass(self, space, w_subtype):
raise OperationError(space.w_TypeError,
space.wrap("You cannot override __class__ for transparent proxies"))
-
+
def getdictvalue(self, space, attr):
try:
return space.call_function(self.w_controller, space.wrap('__getattribute__'),
@@ -43,7 +40,7 @@
if not e.match(space, space.w_AttributeError):
raise
return None
-
+
def setdictvalue(self, space, attr, w_value):
try:
space.call_function(self.w_controller, space.wrap('__setattr__'),
@@ -53,7 +50,7 @@
if not e.match(space, space.w_AttributeError):
raise
return False
-
+
def deldictvalue(self, space, attr):
try:
space.call_function(self.w_controller, space.wrap('__delattr__'),
@@ -63,18 +60,18 @@
if not e.match(space, space.w_AttributeError):
raise
return False
-
+
def getdict(self, space):
return self.getdictvalue(space, '__dict__')
-
+
def setdict(self, space, w_dict):
if not self.setdictvalue(space, '__dict__', w_dict):
baseobjspace.W_Root.setdict(self, space, w_dict)
-
+
W_Transparent.__name__ = name
return W_Transparent
-W_Transparent = transparent_class('W_Transparent', baseobjspace.Wrappable)
+W_Transparent = transparent_class('W_Transparent', baseobjspace.W_Root)
W_TransparentObject = transparent_class('W_TransparentObject', W_Object)
from pypy.objspace.std.objecttype import object_typedef
diff --git a/pypy/objspace/std/test/test_proxy_internals.py b/pypy/objspace/std/test/test_proxy_internals.py
--- a/pypy/objspace/std/test/test_proxy_internals.py
+++ b/pypy/objspace/std/test/test_proxy_internals.py
@@ -14,7 +14,7 @@
class Controller(object):
def __init__(self, obj):
self.obj = obj
-
+
def perform(self, name, *args, **kwargs):
return getattr(self.obj, name)(*args, **kwargs)
def get_proxy(f):
@@ -28,9 +28,9 @@
if cls.runappdirect:
py.test.skip("interp only test")
from pypy.interpreter.typedef import TypeDef, interp2app
- from pypy.interpreter.baseobjspace import Wrappable
+ from pypy.interpreter.baseobjspace import W_Root
- class W_Stuff(Wrappable):
+ class W_Stuff(W_Root):
pass
def descr_new(space, w_subtype):
@@ -52,7 +52,7 @@
except:
import sys
e = sys.exc_info()
-
+
tb = self.get_proxy(e[2])
assert tb.tb_frame is e[2].tb_frame
@@ -75,7 +75,7 @@
except:
import sys
e = sys.exc_info()
-
+
tb = self.get_proxy(e[2])
raises(ZeroDivisionError, "raise e[0], e[1], tb")
raises(ZeroDivisionError, "raise e[0], self.get_proxy(e[1]), tb")
@@ -93,11 +93,11 @@
import types
import sys
import traceback
-
+
def get_proxy(f):
from __pypy__ import tproxy as proxy
return proxy(type(f), Controller(f).perform)
-
+
class FakeTb(object):
def __init__(self, tb):
self.tb_lasti = tb.tb_lasti
@@ -107,37 +107,37 @@
else:
self.tb_next = None
self.tb_frame = get_proxy(tb.tb_frame)
-
+
class Controller(object):
def __init__(self, tb):
if isinstance(tb, types.TracebackType):
self.obj = FakeTb(tb)
else:
self.obj = tb
-
+
def perform(self, name, *args, **kwargs):
return getattr(self.obj, name)(*args, **kwargs)
-
+
def f():
1/0
-
+
def g():
f()
-
+
try:
g()
except:
e = sys.exc_info()
-
+
last_tb = e[2]
tb = get_proxy(e[2])
try:
raise e[0], e[1], tb
except:
e = sys.exc_info()
-
+
assert traceback.format_tb(last_tb) == traceback.format_tb(e[2])
-
+
def test_proxy_get(self):
from __pypy__ import tproxy, get_tproxy_controller
l = [1,2,3]
diff --git a/pypy/objspace/std/test/test_proxy_usercreated.py b/pypy/objspace/std/test/test_proxy_usercreated.py
--- a/pypy/objspace/std/test/test_proxy_usercreated.py
+++ b/pypy/objspace/std/test/test_proxy_usercreated.py
@@ -1,13 +1,14 @@
More information about the pypy-commit
mailing list