[pypy-svn] r12303 - pypy/dist/pypy/objspace/std
arigo at codespeak.net
arigo at codespeak.net
Sun May 15 18:14:12 CEST 2005
Author: arigo
Date: Sun May 15 18:14:12 2005
New Revision: 12303
Modified:
pypy/dist/pypy/objspace/std/fake.py
pypy/dist/pypy/objspace/std/floattype.py
pypy/dist/pypy/objspace/std/inttype.py
pypy/dist/pypy/objspace/std/longtype.py
pypy/dist/pypy/objspace/std/stringtype.py
pypy/dist/pypy/objspace/std/tupletype.py
Log:
Use the same keyword arguments as CPython for constructing built-in types,
e.g. int(x=5).
Modified: pypy/dist/pypy/objspace/std/fake.py
==============================================================================
--- pypy/dist/pypy/objspace/std/fake.py (original)
+++ pypy/dist/pypy/objspace/std/fake.py Sun May 15 18:14:12 2005
@@ -78,10 +78,13 @@
kw['__module__'] = cpy_type.__module__
- def fake__new__(space, w_type, args_w):
+ def fake__new__(space, w_type, __args__):
+ args_w, kwds_w = __args__.unpack()
args = [space.unwrap(w_arg) for w_arg in args_w]
+ kwds = dict([(key, space.unwrap(w_value))
+ for (key, w_value) in kwds_w.items()])
try:
- r = cpy_type.__new__(cpy_type, *args)
+ r = cpy_type.__new__(cpy_type, *args, **kwds)
except:
wrap_exception(space)
raise
@@ -92,7 +95,7 @@
kw['__new__'] = gateway.interp2app(fake__new__,
unwrap_spec = [baseobjspace.ObjSpace,
baseobjspace.W_Root,
- 'args_w'])
+ gateway.Arguments])
if cpy_type.__base__ is not object:
assert cpy_type.__base__ is basestring
from pypy.objspace.std.basestringtype import basestring_typedef
Modified: pypy/dist/pypy/objspace/std/floattype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/floattype.py (original)
+++ pypy/dist/pypy/objspace/std/floattype.py Sun May 15 18:14:12 2005
@@ -1,8 +1,9 @@
from pypy.objspace.std.stdtypedef import *
from pypy.interpreter.error import OperationError
-def descr__new__(space, w_floattype, w_value=0.0):
+def descr__new__(space, w_floattype, w_x=0.0):
from pypy.objspace.std.floatobject import W_FloatObject
+ w_value = w_x # 'x' is the keyword argument name in CPython
if space.is_true(space.isinstance(w_value, space.w_str)):
try:
value = float(space.str_w(w_value))
Modified: pypy/dist/pypy/objspace/std/inttype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/inttype.py (original)
+++ pypy/dist/pypy/objspace/std/inttype.py Sun May 15 18:14:12 2005
@@ -11,9 +11,10 @@
raise OperationError(space.w_ValueError,
space.wrap(e.msg))
-def descr__new__(space, w_inttype, w_value=0, w_base=NoneNotWrapped):
+def descr__new__(space, w_inttype, w_x=0, w_base=NoneNotWrapped):
from pypy.objspace.std.intobject import W_IntObject
w_longval = None
+ w_value = w_x # 'x' is the keyword argument name in CPython
value = 0
if w_base is None:
# check for easy cases
Modified: pypy/dist/pypy/objspace/std/longtype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/longtype.py (original)
+++ pypy/dist/pypy/objspace/std/longtype.py Sun May 15 18:14:12 2005
@@ -5,8 +5,9 @@
from pypy.interpreter.gateway import NoneNotWrapped
from pypy.rpython.rarithmetic import r_uint
-def descr__new__(space, w_longtype, w_value=0, w_base=NoneNotWrapped):
+def descr__new__(space, w_longtype, w_x=0, w_base=NoneNotWrapped):
from pypy.objspace.std.longobject import W_LongObject, args_from_long
+ w_value = w_x # 'x' is the keyword argument name in CPython
if w_base is None:
# check for easy cases
if isinstance(w_value, W_LongObject):
Modified: pypy/dist/pypy/objspace/std/stringtype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/stringtype.py (original)
+++ pypy/dist/pypy/objspace/std/stringtype.py Sun May 15 18:14:12 2005
@@ -40,9 +40,9 @@
# ____________________________________________________________
-def descr__new__(space, w_stringtype, w_obj=''):
+def descr__new__(space, w_stringtype, w_object=''):
from pypy.objspace.std.stringobject import W_StringObject
- w_obj = space.str(w_obj)
+ w_obj = space.str(w_object)
if space.is_true(space.is_(w_stringtype, space.w_str)):
return w_obj # XXX might be reworked when space.str() typechecks
value = space.str_w(w_obj)
Modified: pypy/dist/pypy/objspace/std/tupletype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/tupletype.py (original)
+++ pypy/dist/pypy/objspace/std/tupletype.py Sun May 15 18:14:12 2005
@@ -1,15 +1,15 @@
from pypy.objspace.std.stdtypedef import *
from pypy.interpreter.gateway import NoneNotWrapped
-def descr__new__(space, w_tupletype, w_items=NoneNotWrapped):
+def descr__new__(space, w_tupletype, w_sequence=NoneNotWrapped):
from pypy.objspace.std.tupleobject import W_TupleObject
- if w_items is None:
+ if w_sequence is None:
tuple_w = []
elif (space.is_w(w_tupletype, space.w_tuple) and
- space.is_w(space.type(w_items), space.w_tuple)):
- return w_items
+ space.is_w(space.type(w_sequence), space.w_tuple)):
+ return w_sequence
else:
- tuple_w = space.unpackiterable(w_items)
+ tuple_w = space.unpackiterable(w_sequence)
w_obj = space.allocate_instance(W_TupleObject, w_tupletype)
W_TupleObject.__init__(w_obj, space, tuple_w)
return w_obj
More information about the Pypy-commit
mailing list