1
"""Default implementation for some operation."""
3
from pypy.objspace.std.objspace import *
6
# The following default implementations are used before delegation is tried.
7
# 'id' is normally the address of the wrapper.
9
def id__ANY(space, w_obj):
11
return space.wrap(id(w_obj))
13
# __init__ should succeed if called internally as a multimethod
15
def init__ANY(space, w_obj, __args__):
18
def typed_unwrap_error_msg(space, expected, w_obj):
19
type_name = space.type(w_obj).getname(space, '?')
20
return space.wrap("expected %s, got %s object" % (expected, type_name))
22
def int_w__ANY(space,w_obj):
23
raise OperationError(space.w_TypeError,
24
typed_unwrap_error_msg(space, "integer", w_obj))
26
def str_w__ANY(space,w_obj):
27
raise OperationError(space.w_TypeError,
28
typed_unwrap_error_msg(space, "string", w_obj))
30
def float_w__ANY(space,w_obj):
31
raise OperationError(space.w_TypeError,
32
typed_unwrap_error_msg(space, "float", w_obj))
34
def uint_w__ANY(space,w_obj):
35
raise OperationError(space.w_TypeError,
36
typed_unwrap_error_msg(space, "integer", w_obj))