Author: Maciej Fijalkowski <fij...@gmail.com> Branch: kill-someobject Changeset: r57989:c7b80d289313 Date: 2012-10-10 22:17 +0200 http://bitbucket.org/pypy/pypy/changeset/c7b80d289313/
Log: fix some more stuff diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py --- a/pypy/interpreter/function.py +++ b/pypy/interpreter/function.py @@ -205,11 +205,11 @@ code = space.interp_w(Code, w_code) if not space.is_true(space.isinstance(w_globals, space.w_dict)): raise OperationError(space.w_TypeError, space.wrap("expected dict")) - if not space.is_w(w_name, space.w_None): + if not space.is_none(w_name): name = space.str_w(w_name) else: name = None - if not space.is_w(w_argdefs, space.w_None): + if not space.is_none(w_argdefs): defs_w = space.fixedview(w_argdefs) else: defs_w = [] @@ -217,7 +217,7 @@ from pypy.interpreter.pycode import PyCode if isinstance(code, PyCode): nfreevars = len(code.co_freevars) - if space.is_w(w_closure, space.w_None) and nfreevars == 0: + if space.is_none(w_closure) and nfreevars == 0: closure = None elif not space.is_w(space.type(w_closure), space.w_tuple): raise OperationError(space.w_TypeError, space.wrap("invalid closure")) @@ -428,8 +428,8 @@ """functionobject.__get__(obj[, type]) -> method""" # this is not defined as a method on Function because it's generally # useful logic: w_function can be any callable. It is used by Method too. - asking_for_bound = (space.is_w(w_cls, space.w_None) or - not space.is_w(w_obj, space.w_None) or + asking_for_bound = (space.is_none(w_cls) or + not space.is_none(w_obj) or space.is_w(w_cls, space.type(space.w_None))) if asking_for_bound: return space.wrap(Method(space, w_function, w_obj, w_cls)) @@ -445,12 +445,15 @@ self.space = space self.w_function = w_function self.w_instance = w_instance # or None + if w_class is None: + w_class = space.w_None self.w_class = w_class # possibly space.w_None - def descr_method__new__(space, w_subtype, w_function, w_instance, w_class=None): + def descr_method__new__(space, w_subtype, w_function, w_instance, + w_class=None): if space.is_w(w_instance, space.w_None): w_instance = None - if w_instance is None and space.is_w(w_class, space.w_None): + if w_instance is None and space.is_none(w_class): raise OperationError(space.w_TypeError, space.wrap("unbound methods must have class")) method = space.allocate_instance(Method, w_subtype) diff --git a/pypy/interpreter/generator.py b/pypy/interpreter/generator.py --- a/pypy/interpreter/generator.py +++ b/pypy/interpreter/generator.py @@ -91,6 +91,8 @@ def descr_throw(self, w_type, w_val=None, w_tb=None): """x.throw(typ[,val[,tb]]) -> raise exception in generator, return next yielded value or raise StopIteration.""" + if w_val is None: + w_val = self.space.w_None return self.throw(w_type, w_val, w_tb) @@ -99,7 +101,7 @@ space = self.space msg = "throw() third argument must be a traceback object" - if space.is_w(w_tb, space.w_None): + if space.is_none(w_tb): tb = None else: tb = check_traceback(space, w_tb, msg) diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py --- a/pypy/interpreter/typedef.py +++ b/pypy/interpreter/typedef.py @@ -3,7 +3,8 @@ """ import py -from pypy.interpreter.gateway import interp2app, BuiltinCode +from pypy.interpreter.gateway import interp2app, BuiltinCode, unwrap_spec,\ + W_Root from pypy.interpreter.argument import Arguments from pypy.interpreter.baseobjspace import Wrappable, DescrMismatch from pypy.interpreter.error import OperationError, operationerrfmt @@ -456,6 +457,7 @@ self.objclass_getter = objclass_getter self.use_closure = use_closure + @unwrap_spec(w_cls = (W_Root, 'space.w_None')) def descr_property_get(self, space, w_obj, w_cls=None): """property.__get__(obj[, type]) -> value Read the value of the property of the given obj.""" @@ -553,7 +555,7 @@ self.w_cls.name, space.type(w_obj).getname(space)) - def descr_member_get(self, space, w_obj, w_w_cls=None): + def descr_member_get(self, space, w_obj, w_cls=None): """member.__get__(obj[, type]) -> value Read the slot 'member' of the given 'obj'.""" if space.is_w(w_obj, space.w_None): diff --git a/pypy/module/__builtin__/operation.py b/pypy/module/__builtin__/operation.py --- a/pypy/module/__builtin__/operation.py +++ b/pypy/module/__builtin__/operation.py @@ -124,8 +124,8 @@ NDIGITS_MAX = int((rfloat.DBL_MANT_DIG - rfloat.DBL_MIN_EXP) * 0.30103) NDIGITS_MIN = -int((rfloat.DBL_MAX_EXP + 1) * 0.30103) -@unwrap_spec(number=float) -def round(space, number, w_ndigits=0): +@unwrap_spec(number=float, w_ndigits = (W_Root, 'space.wrap(0)')) +def round(space, number, w_ndigits): """round(number[, ndigits]) -> floating point number Round a number to a given precision in decimal digits (default 0 digits). @@ -234,6 +234,7 @@ function). Note that classes are callable.""" return space.callable(w_object) -def format(space, w_obj, w_format_spec=""): +@unwrap_spec(w_format_spec = (W_Root, 'space.wrap("")')) +def format(space, w_obj, w_format_spec): """Format a obj according to format_spec""" return space.format(w_obj, w_format_spec) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit