Author: Carl Friedrich Bolz <[email protected]>
Branch: space-newtext
Changeset: r88512:036370c1dfd7
Date: 2016-11-21 11:46 +0100
http://bitbucket.org/pypy/pypy/changeset/036370c1dfd7/
Log: make interp_attrproperty take a required wrapfn argument (the py3.5
branch already started to invent workarounds for this)
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -808,6 +808,11 @@
raise
return None
+ def wrap_none(self, w_obj):
+ if w_obj is None:
+ return self.w_None
+ return w_obj
+
@signature(types.any(), types.bool(), returns=types.instance(W_Root))
def newbool(self, b):
if b:
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -324,11 +324,11 @@
def descr_get_objclass(space, property):
return property.objclass_getter(space)
-def interp_attrproperty(name, cls, doc=None):
+def interp_attrproperty(name, cls, doc=None, wrapfn=None):
"NOT_RPYTHON: initialization-time only"
- # YYY needs some refactoring to get rid of the wrap
+ assert wrapfn is not None
def fget(space, obj):
- return space.wrap(getattr(obj, name))
+ return getattr(space, wrapfn)(getattr(obj, name))
return GetSetProperty(fget, cls=cls, doc=doc)
def interp_attrproperty_w(name, cls, doc=None):
@@ -347,9 +347,9 @@
__get__ = interp2app(GetSetProperty.descr_property_get),
__set__ = interp2app(GetSetProperty.descr_property_set),
__delete__ = interp2app(GetSetProperty.descr_property_del),
- __name__ = interp_attrproperty('name', cls=GetSetProperty),
+ __name__ = interp_attrproperty('name', cls=GetSetProperty,
wrapfn="newtext_or_none"),
__objclass__ = GetSetProperty(GetSetProperty.descr_get_objclass),
- __doc__ = interp_attrproperty('doc', cls=GetSetProperty),
+ __doc__ = interp_attrproperty('doc', cls=GetSetProperty,
wrapfn="newtext_or_none"),
)
assert not GetSetProperty.typedef.acceptable_as_base_class # no __new__
@@ -402,7 +402,7 @@
__get__ = interp2app(Member.descr_member_get),
__set__ = interp2app(Member.descr_member_set),
__delete__ = interp2app(Member.descr_member_del),
- __name__ = interp_attrproperty('name', cls=Member),
+ __name__ = interp_attrproperty('name', cls=Member,
wrapfn="newtext_or_none"),
__objclass__ = interp_attrproperty_w('w_cls', cls=Member),
)
assert not Member.typedef.acceptable_as_base_class # no __new__
@@ -528,7 +528,7 @@
Code.typedef = TypeDef('internal-code',
- co_name = interp_attrproperty('co_name', cls=Code),
+ co_name = interp_attrproperty('co_name', cls=Code,
wrapfn="newtext_or_none"),
co_varnames = GetSetProperty(fget_co_varnames, cls=Code),
co_argcount = GetSetProperty(fget_co_argcount, cls=Code),
co_flags = GetSetProperty(fget_co_flags, cls=Code),
@@ -538,7 +538,7 @@
BuiltinCode.typedef = TypeDef('builtin-code',
__reduce__ = interp2app(BuiltinCode.descr__reduce__),
- co_name = interp_attrproperty('co_name', cls=BuiltinCode),
+ co_name = interp_attrproperty('co_name', cls=BuiltinCode,
wrapfn="newtext_or_none"),
co_varnames = GetSetProperty(fget_co_varnames, cls=BuiltinCode),
co_argcount = GetSetProperty(fget_co_argcount, cls=BuiltinCode),
co_flags = GetSetProperty(fget_co_flags, cls=BuiltinCode),
@@ -554,20 +554,20 @@
__hash__ = interp2app(PyCode.descr_code__hash__),
__reduce__ = interp2app(PyCode.descr__reduce__),
__repr__ = interp2app(PyCode.repr),
- co_argcount = interp_attrproperty('co_argcount', cls=PyCode),
- co_nlocals = interp_attrproperty('co_nlocals', cls=PyCode),
- co_stacksize = interp_attrproperty('co_stacksize', cls=PyCode),
- co_flags = interp_attrproperty('co_flags', cls=PyCode),
- co_code = interp_attrproperty('co_code', cls=PyCode),
+ co_argcount = interp_attrproperty('co_argcount', cls=PyCode,
wrapfn="newint"),
+ co_nlocals = interp_attrproperty('co_nlocals', cls=PyCode,
wrapfn="newint"),
+ co_stacksize = interp_attrproperty('co_stacksize', cls=PyCode,
wrapfn="newint"),
+ co_flags = interp_attrproperty('co_flags', cls=PyCode, wrapfn="newint"),
+ co_code = interp_attrproperty('co_code', cls=PyCode, wrapfn="newbytes"),
co_consts = GetSetProperty(PyCode.fget_co_consts),
co_names = GetSetProperty(PyCode.fget_co_names),
co_varnames = GetSetProperty(PyCode.fget_co_varnames),
co_freevars = GetSetProperty(PyCode.fget_co_freevars),
co_cellvars = GetSetProperty(PyCode.fget_co_cellvars),
- co_filename = interp_attrproperty('co_filename', cls=PyCode),
- co_name = interp_attrproperty('co_name', cls=PyCode),
- co_firstlineno = interp_attrproperty('co_firstlineno', cls=PyCode),
- co_lnotab = interp_attrproperty('co_lnotab', cls=PyCode),
+ co_filename = interp_attrproperty('co_filename', cls=PyCode,
wrapfn="newtext"),
+ co_name = interp_attrproperty('co_name', cls=PyCode, wrapfn="newtext"),
+ co_firstlineno = interp_attrproperty('co_firstlineno', cls=PyCode,
wrapfn="newint"),
+ co_lnotab = interp_attrproperty('co_lnotab', cls=PyCode,
wrapfn="newbytes"),
__weakref__ = make_weakref_descr(PyCode),
)
PyCode.typedef.acceptable_as_base_class = False
@@ -732,10 +732,10 @@
PyTraceback.typedef = TypeDef("traceback",
__reduce__ = interp2app(PyTraceback.descr__reduce__),
__setstate__ = interp2app(PyTraceback.descr__setstate__),
- tb_frame = interp_attrproperty('frame', cls=PyTraceback),
- tb_lasti = interp_attrproperty('lasti', cls=PyTraceback),
+ tb_frame = interp_attrproperty_w('frame', cls=PyTraceback),
+ tb_lasti = interp_attrproperty('lasti', cls=PyTraceback, wrapfn="newint"),
tb_lineno = GetSetProperty(PyTraceback.descr_tb_lineno),
- tb_next = interp_attrproperty('next', cls=PyTraceback),
+ tb_next = interp_attrproperty_w('next', cls=PyTraceback),
)
assert not PyTraceback.typedef.acceptable_as_base_class # no __new__
@@ -753,7 +753,7 @@
descrmismatch='close'),
__iter__ = interp2app(GeneratorIterator.descr__iter__,
descrmismatch='__iter__'),
- gi_running = interp_attrproperty('running', cls=GeneratorIterator),
+ gi_running = interp_attrproperty('running', cls=GeneratorIterator,
wrapfn="newbool"),
gi_frame = GetSetProperty(GeneratorIterator.descr_gi_frame),
gi_code = GetSetProperty(GeneratorIterator.descr_gi_code),
__name__ = GetSetProperty(GeneratorIterator.descr__name__),
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
@@ -4,7 +4,7 @@
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError, oefmt
-from pypy.interpreter.typedef import TypeDef, interp_attrproperty
+from pypy.interpreter.typedef import TypeDef, interp_attrproperty,
interp_attrproperty_w
from rpython.rlib import jit
from rpython.rlib.rarithmetic import r_uint, r_ulonglong, r_longlong, intmask
@@ -342,10 +342,10 @@
W_CField.typedef = TypeDef(
'_cffi_backend.CField',
- type = interp_attrproperty('ctype', W_CField),
- offset = interp_attrproperty('offset', W_CField),
- bitshift = interp_attrproperty('bitshift', W_CField),
- bitsize = interp_attrproperty('bitsize', W_CField),
- flags = interp_attrproperty('flags', W_CField),
+ type = interp_attrproperty_w('ctype', W_CField),
+ offset = interp_attrproperty('offset', W_CField, wrapfn="newint"),
+ bitshift = interp_attrproperty('bitshift', W_CField, wrapfn="newint"),
+ bitsize = interp_attrproperty('bitsize', W_CField, wrapfn="newint"),
+ flags = interp_attrproperty('flags', W_CField, wrapfn="newint"),
)
W_CField.typedef.acceptable_as_base_class = False
diff --git a/pypy/module/_cffi_backend/wrapper.py
b/pypy/module/_cffi_backend/wrapper.py
--- a/pypy/module/_cffi_backend/wrapper.py
+++ b/pypy/module/_cffi_backend/wrapper.py
@@ -138,8 +138,8 @@
'FFIFunctionWrapper',
__repr__ = interp2app(W_FunctionWrapper.descr_repr),
__call__ = interp2app(W_FunctionWrapper.descr_call),
- __name__ = interp_attrproperty('fnname', cls=W_FunctionWrapper),
- __module__ = interp_attrproperty('modulename', cls=W_FunctionWrapper),
+ __name__ = interp_attrproperty('fnname', cls=W_FunctionWrapper,
wrapfn="newtext"),
+ __module__ = interp_attrproperty('modulename', cls=W_FunctionWrapper,
wrapfn="newtext"),
__doc__ = GetSetProperty(W_FunctionWrapper.descr_get_doc),
__get__ = interp2app(W_FunctionWrapper.descr_get),
)
diff --git a/pypy/module/_csv/interp_csv.py b/pypy/module/_csv/interp_csv.py
--- a/pypy/module/_csv/interp_csv.py
+++ b/pypy/module/_csv/interp_csv.py
@@ -163,14 +163,20 @@
'_csv.Dialect',
__new__ = interp2app(W_Dialect___new__),
- delimiter = interp_attrproperty('delimiter', W_Dialect),
- doublequote = interp_attrproperty('doublequote', W_Dialect),
+ delimiter = interp_attrproperty('delimiter', W_Dialect,
+ wrapfn='newtext'),
+ doublequote = interp_attrproperty('doublequote', W_Dialect,
+ wrapfn='newbool'),
escapechar = GetSetProperty(_get_escapechar, cls=W_Dialect),
- lineterminator = interp_attrproperty('lineterminator', W_Dialect),
+ lineterminator = interp_attrproperty('lineterminator', W_Dialect,
+ wrapfn='newtext'),
quotechar = GetSetProperty(_get_quotechar, cls=W_Dialect),
- quoting = interp_attrproperty('quoting', W_Dialect),
- skipinitialspace = interp_attrproperty('skipinitialspace', W_Dialect),
- strict = interp_attrproperty('strict', W_Dialect),
+ quoting = interp_attrproperty('quoting', W_Dialect,
+ wrapfn='newint'),
+ skipinitialspace = interp_attrproperty('skipinitialspace', W_Dialect,
+ wrapfn='newbool'),
+ strict = interp_attrproperty('strict', W_Dialect,
+ wrapfn='newbool'),
__doc__ = """CSV dialect
diff --git a/pypy/module/_csv/interp_reader.py
b/pypy/module/_csv/interp_reader.py
--- a/pypy/module/_csv/interp_reader.py
+++ b/pypy/module/_csv/interp_reader.py
@@ -247,7 +247,8 @@
W_Reader.typedef = TypeDef(
'_csv.reader',
dialect = interp_attrproperty_w('dialect', W_Reader),
- line_num = interp_attrproperty('line_num', W_Reader),
+ line_num = interp_attrproperty('line_num', W_Reader,
+ wrapfn="newint"),
__iter__ = interp2app(W_Reader.iter_w),
next = interp2app(W_Reader.next_w),
__doc__ = """CSV reader
diff --git a/pypy/module/_file/interp_file.py b/pypy/module/_file/interp_file.py
--- a/pypy/module/_file/interp_file.py
+++ b/pypy/module/_file/interp_file.py
@@ -613,9 +613,12 @@
name = interp_attrproperty_w('w_name', cls=W_File, doc="file name"),
mode = interp_attrproperty('mode', cls=W_File,
doc = "file mode ('r', 'U', 'w', 'a', "
- "possibly with 'b' or '+' added)"),
- encoding = interp_attrproperty('encoding', cls=W_File),
- errors = interp_attrproperty('errors', cls=W_File),
+ "possibly with 'b' or '+' added)",
+ wrapfn="newtext"),
+ encoding = interp_attrproperty('encoding', cls=W_File,
+ wrapfn="wrap_none"),
+ errors = interp_attrproperty('errors', cls=W_File,
+ wrapfn="wrap_none"),
closed = GetSetProperty(descr_file_closed, cls=W_File,
doc="True if the file is closed"),
newlines = GetSetProperty(descr_file_newlines, cls=W_File,
diff --git a/pypy/module/_io/interp_fileio.py b/pypy/module/_io/interp_fileio.py
--- a/pypy/module/_io/interp_fileio.py
+++ b/pypy/module/_io/interp_fileio.py
@@ -449,7 +449,8 @@
fileno = interp2app(W_FileIO.fileno_w),
isatty = interp2app(W_FileIO.isatty_w),
name = interp_member_w('w_name', cls=W_FileIO),
- closefd = interp_attrproperty('closefd', cls=W_FileIO),
+ closefd = interp_attrproperty('closefd', cls=W_FileIO,
+ wrapfn="newbool"),
mode = GetSetProperty(W_FileIO.descr_get_mode),
)
diff --git a/pypy/module/_io/interp_io.py b/pypy/module/_io/interp_io.py
--- a/pypy/module/_io/interp_io.py
+++ b/pypy/module/_io/interp_io.py
@@ -34,7 +34,8 @@
"I/O stream"),
__new__ = generic_new_descr(W_BlockingIOError),
__init__ = interp2app(W_BlockingIOError.descr_init),
- characters_written = interp_attrproperty('written', W_BlockingIOError),
+ characters_written = interp_attrproperty('written', W_BlockingIOError,
+ wrapfn="newint"),
)
DEFAULT_BUFFER_SIZE = 8 * 1024
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
@@ -1045,7 +1045,8 @@
truncate = interp2app(W_TextIOWrapper.truncate_w),
close = interp2app(W_TextIOWrapper.close_w),
- line_buffering = interp_attrproperty("line_buffering", W_TextIOWrapper),
+ line_buffering = interp_attrproperty("line_buffering", W_TextIOWrapper,
+ wrapfn="newint"),
readable = interp2app(W_TextIOWrapper.readable_w),
writable = interp2app(W_TextIOWrapper.writable_w),
seekable = interp2app(W_TextIOWrapper.seekable_w),
diff --git a/pypy/module/_lsprof/interp_lsprof.py
b/pypy/module/_lsprof/interp_lsprof.py
--- a/pypy/module/_lsprof/interp_lsprof.py
+++ b/pypy/module/_lsprof/interp_lsprof.py
@@ -64,10 +64,14 @@
W_StatsEntry.typedef = TypeDef(
'StatsEntry',
code = GetSetProperty(W_StatsEntry.get_code),
- callcount = interp_attrproperty('callcount', W_StatsEntry),
- reccallcount = interp_attrproperty('reccallcount', W_StatsEntry),
- inlinetime = interp_attrproperty('it', W_StatsEntry),
- totaltime = interp_attrproperty('tt', W_StatsEntry),
+ callcount = interp_attrproperty('callcount', W_StatsEntry,
+ wrapfn="newint"),
+ reccallcount = interp_attrproperty('reccallcount', W_StatsEntry,
+ wrapfn="newint"),
+ inlinetime = interp_attrproperty('it', W_StatsEntry,
+ wrapfn="newfloat"),
+ totaltime = interp_attrproperty('tt', W_StatsEntry,
+ wrapfn="newfloat"),
calls = GetSetProperty(W_StatsEntry.get_calls),
__repr__ = interp2app(W_StatsEntry.repr),
)
@@ -91,10 +95,14 @@
W_StatsSubEntry.typedef = TypeDef(
'SubStatsEntry',
code = GetSetProperty(W_StatsSubEntry.get_code),
- callcount = interp_attrproperty('callcount', W_StatsSubEntry),
- reccallcount = interp_attrproperty('reccallcount', W_StatsSubEntry),
- inlinetime = interp_attrproperty('it', W_StatsSubEntry),
- totaltime = interp_attrproperty('tt', W_StatsSubEntry),
+ callcount = interp_attrproperty('callcount', W_StatsSubEntry,
+ wrapfn="newint"),
+ reccallcount = interp_attrproperty('reccallcount', W_StatsSubEntry,
+ wrapfn="newint"),
+ inlinetime = interp_attrproperty('it', W_StatsSubEntry,
+ wrapfn="newfloat"),
+ totaltime = interp_attrproperty('tt', W_StatsSubEntry,
+ wrapfn="newfloat"),
__repr__ = interp2app(W_StatsSubEntry.repr),
)
diff --git a/pypy/module/_rawffi/alt/interp_ffitype.py
b/pypy/module/_rawffi/alt/interp_ffitype.py
--- a/pypy/module/_rawffi/alt/interp_ffitype.py
+++ b/pypy/module/_rawffi/alt/interp_ffitype.py
@@ -105,7 +105,8 @@
W_FFIType.typedef = TypeDef(
'FFIType',
- name = interp_attrproperty('name', W_FFIType),
+ name = interp_attrproperty('name', W_FFIType,
+ wrapfn="newtext_or_none"),
__repr__ = interp2app(W_FFIType.repr),
deref_pointer = interp2app(W_FFIType.descr_deref_pointer),
sizeof = interp2app(W_FFIType.descr_sizeof),
diff --git a/pypy/module/_rawffi/alt/interp_struct.py
b/pypy/module/_rawffi/alt/interp_struct.py
--- a/pypy/module/_rawffi/alt/interp_struct.py
+++ b/pypy/module/_rawffi/alt/interp_struct.py
@@ -5,7 +5,7 @@
from rpython.rlib.rgc import must_be_light_finalizer
from rpython.rlib.rarithmetic import r_uint, r_ulonglong, intmask
from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.typedef import TypeDef, interp_attrproperty
+from pypy.interpreter.typedef import TypeDef, interp_attrproperty,
interp_attrproperty_w
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.error import oefmt
from pypy.module._rawffi.alt.interp_ffitype import W_FFIType
@@ -29,9 +29,11 @@
W_Field.typedef = TypeDef(
'Field',
__new__ = interp2app(descr_new_field),
- name = interp_attrproperty('name', W_Field),
- ffitype = interp_attrproperty('w_ffitype', W_Field),
- offset = interp_attrproperty('offset', W_Field),
+ name = interp_attrproperty('name', W_Field,
+ wrapfn="newtext_or_none"),
+ ffitype = interp_attrproperty_w('w_ffitype', W_Field),
+ offset = interp_attrproperty('offset', W_Field,
+ wrapfn="newint"),
)
@@ -141,7 +143,7 @@
W__StructDescr.typedef = TypeDef(
'_StructDescr',
__new__ = interp2app(descr_new_structdescr),
- ffitype = interp_attrproperty('w_ffitype', W__StructDescr),
+ ffitype = interp_attrproperty_w('w_ffitype', W__StructDescr),
define_fields = interp2app(W__StructDescr.define_fields),
allocate = interp2app(W__StructDescr.allocate),
fromaddress = interp2app(W__StructDescr.fromaddress),
diff --git a/pypy/module/_rawffi/array.py b/pypy/module/_rawffi/array.py
--- a/pypy/module/_rawffi/array.py
+++ b/pypy/module/_rawffi/array.py
@@ -4,7 +4,7 @@
"""
from pypy.interpreter.gateway import interp2app, unwrap_spec
-from pypy.interpreter.typedef import TypeDef, GetSetProperty,
interp_attrproperty
+from pypy.interpreter.typedef import TypeDef, GetSetProperty,
interp_attrproperty_w
from rpython.rtyper.lltypesystem import lltype, rffi
from pypy.interpreter.error import OperationError, oefmt
from pypy.module._rawffi.interp_rawffi import segfault_exception
@@ -199,7 +199,7 @@
__getitem__ = interp2app(W_ArrayInstance.descr_getitem),
__len__ = interp2app(W_ArrayInstance.getlength),
buffer = GetSetProperty(W_ArrayInstance.getbuffer),
- shape = interp_attrproperty('shape', W_ArrayInstance),
+ shape = interp_attrproperty_w('shape', W_ArrayInstance),
free = interp2app(W_ArrayInstance.free),
byptr = interp2app(W_ArrayInstance.byptr),
itemaddress = interp2app(W_ArrayInstance.descr_itemaddress),
@@ -223,7 +223,7 @@
__getitem__ = interp2app(W_ArrayInstance.descr_getitem),
__len__ = interp2app(W_ArrayInstance.getlength),
buffer = GetSetProperty(W_ArrayInstance.getbuffer),
- shape = interp_attrproperty('shape', W_ArrayInstance),
+ shape = interp_attrproperty_w('shape', W_ArrayInstance),
byptr = interp2app(W_ArrayInstance.byptr),
itemaddress = interp2app(W_ArrayInstance.descr_itemaddress),
)
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
@@ -242,7 +242,8 @@
__new__ = interp2app(descr_new_cdll),
ptr = interp2app(W_CDLL.ptr),
getaddressindll = interp2app(W_CDLL.getaddressindll),
- name = interp_attrproperty('name', W_CDLL),
+ name = interp_attrproperty('name', W_CDLL,
+ wrapfn="newtext_or_none"),
__doc__ = """ C Dynamically loaded library
use CDLL(libname) to create a handle to a C library (the argument is processed
the same way as dlopen processes it). On such a library you can call:
diff --git a/pypy/module/_rawffi/structure.py b/pypy/module/_rawffi/structure.py
--- a/pypy/module/_rawffi/structure.py
+++ b/pypy/module/_rawffi/structure.py
@@ -3,7 +3,7 @@
"""
from pypy.interpreter.gateway import interp2app, unwrap_spec
-from pypy.interpreter.typedef import interp_attrproperty
+from pypy.interpreter.typedef import interp_attrproperty, interp_attrproperty_w
from pypy.interpreter.typedef import TypeDef, GetSetProperty
from pypy.interpreter.error import OperationError, oefmt
from pypy.module._rawffi.interp_rawffi import segfault_exception, _MS_WINDOWS
@@ -270,8 +270,10 @@
__call__ = interp2app(W_Structure.descr_call),
__repr__ = interp2app(W_Structure.descr_repr),
fromaddress = interp2app(W_Structure.fromaddress),
- size = interp_attrproperty('size', W_Structure),
- alignment = interp_attrproperty('alignment', W_Structure),
+ size = interp_attrproperty('size', W_Structure,
+ wrapfn="newint"),
+ alignment = interp_attrproperty('alignment', W_Structure,
+ wrapfn="newint"),
fieldoffset = interp2app(W_Structure.descr_fieldoffset),
fieldsize = interp2app(W_Structure.descr_fieldsize),
size_alignment = interp2app(W_Structure.descr_size_alignment),
@@ -382,7 +384,7 @@
__setattr__ = interp2app(W_StructureInstance.setattr),
buffer = GetSetProperty(W_StructureInstance.getbuffer),
free = interp2app(W_StructureInstance.free),
- shape = interp_attrproperty('shape', W_StructureInstance),
+ shape = interp_attrproperty_w('shape', W_StructureInstance),
byptr = interp2app(W_StructureInstance.byptr),
fieldaddress= interp2app(W_StructureInstance.descr_fieldaddress),
)
@@ -403,7 +405,7 @@
__getattr__ = interp2app(W_StructureInstance.getattr),
__setattr__ = interp2app(W_StructureInstance.setattr),
buffer = GetSetProperty(W_StructureInstance.getbuffer),
- shape = interp_attrproperty('shape', W_StructureInstance),
+ shape = interp_attrproperty_w('shape', W_StructureInstance),
byptr = interp2app(W_StructureInstance.byptr),
fieldaddress= interp2app(W_StructureInstance.descr_fieldaddress),
)
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
@@ -406,9 +406,11 @@
split = interp2app(W_SRE_Pattern.split_w),
sub = interp2app(W_SRE_Pattern.sub_w),
subn = interp2app(W_SRE_Pattern.subn_w),
- flags = interp_attrproperty('flags', W_SRE_Pattern),
+ flags = interp_attrproperty('flags', W_SRE_Pattern,
+ wrapfn="newint"),
groupindex = interp_attrproperty_w('w_groupindex', W_SRE_Pattern),
- groups = interp_attrproperty('num_groups', W_SRE_Pattern),
+ groups = interp_attrproperty('num_groups', W_SRE_Pattern,
+ wrapfn="newint"),
pattern = interp_attrproperty_w('w_pattern', W_SRE_Pattern),
)
W_SRE_Pattern.typedef.acceptable_as_base_class = False
@@ -587,7 +589,7 @@
span = interp2app(W_SRE_Match.span_w),
expand = interp2app(W_SRE_Match.expand_w),
#
- re = interp_attrproperty('srepat', W_SRE_Match),
+ re = interp_attrproperty_w('srepat', W_SRE_Match),
string = GetSetProperty(W_SRE_Match.fget_string),
pos = GetSetProperty(W_SRE_Match.fget_pos),
endpos = GetSetProperty(W_SRE_Match.fget_endpos),
@@ -649,6 +651,6 @@
next = interp2app(W_SRE_Scanner.next_w),
match = interp2app(W_SRE_Scanner.match_w),
search = interp2app(W_SRE_Scanner.search_w),
- pattern = interp_attrproperty('srepat', W_SRE_Scanner),
+ pattern = interp_attrproperty_w('srepat', W_SRE_Scanner),
)
W_SRE_Scanner.typedef.acceptable_as_base_class = False
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
@@ -699,7 +699,8 @@
W_BZ2Decompressor.typedef = TypeDef("BZ2Decompressor",
__doc__ = W_BZ2Decompressor.__doc__,
__new__ = interp2app(descr_decompressor__new__),
- unused_data = interp_attrproperty("unused_data", W_BZ2Decompressor),
+ unused_data = interp_attrproperty("unused_data", W_BZ2Decompressor,
+ wrapfn="newbytes"),
decompress = interp2app(W_BZ2Decompressor.decompress),
)
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
@@ -249,7 +249,8 @@
__call__ = interp2app(cfunction_descr_call),
__doc__ = GetSetProperty(W_PyCFunctionObject.get_doc),
__module__ = interp_attrproperty_w('w_module', cls=W_PyCFunctionObject),
- __name__ = interp_attrproperty('name', cls=W_PyCFunctionObject),
+ __name__ = interp_attrproperty('name', cls=W_PyCFunctionObject,
+ wrapfn="newtext_or_none"),
)
W_PyCFunctionObject.typedef.acceptable_as_base_class = False
@@ -257,7 +258,8 @@
'method',
__get__ = interp2app(cmethod_descr_get),
__call__ = interp2app(cmethod_descr_call),
- __name__ = interp_attrproperty('name', cls=W_PyCMethodObject),
+ __name__ = interp_attrproperty('name', cls=W_PyCMethodObject,
+ wrapfn="newtext_or_none"),
__objclass__ = interp_attrproperty_w('w_objclass', cls=W_PyCMethodObject),
__repr__ = interp2app(W_PyCMethodObject.descr_method_repr),
)
@@ -267,7 +269,8 @@
'classmethod',
__get__ = interp2app(cclassmethod_descr_get),
__call__ = interp2app(cmethod_descr_call),
- __name__ = interp_attrproperty('name', cls=W_PyCClassMethodObject),
+ __name__ = interp_attrproperty('name', cls=W_PyCClassMethodObject,
+ wrapfn="newtext_or_none"),
__objclass__ = interp_attrproperty_w('w_objclass',
cls=W_PyCClassMethodObject),
__repr__ = interp2app(W_PyCClassMethodObject.descr_method_repr),
@@ -279,8 +282,10 @@
'wrapper_descriptor',
__call__ = interp2app(cwrapper_descr_call),
__get__ = interp2app(cmethod_descr_get),
- __name__ = interp_attrproperty('method_name', cls=W_PyCWrapperObject),
- __doc__ = interp_attrproperty('doc', cls=W_PyCWrapperObject),
+ __name__ = interp_attrproperty('method_name', cls=W_PyCWrapperObject,
+ wrapfn="newtext_or_none"),
+ __doc__ = interp_attrproperty('doc', cls=W_PyCWrapperObject,
+ wrapfn="newtext_or_none"),
__objclass__ = interp_attrproperty_w('w_objclass', cls=W_PyCWrapperObject),
__repr__ = interp2app(W_PyCWrapperObject.descr_method_repr),
# XXX missing: __getattribute__
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -9,7 +9,7 @@
from pypy.interpreter.baseobjspace import W_Root, DescrMismatch
from pypy.interpreter.error import oefmt
from pypy.interpreter.typedef import (GetSetProperty, TypeDef,
- interp_attrproperty, interp_attrproperty, interp2app)
+ interp_attrproperty, interp2app)
from pypy.module.__builtin__.abstractinst import abstract_issubclass_w
from pypy.module.cpyext import structmemberdefs
from pypy.module.cpyext.api import (
@@ -97,9 +97,11 @@
__get__ = interp2app(GetSetProperty.descr_property_get),
__set__ = interp2app(GetSetProperty.descr_property_set),
__delete__ = interp2app(GetSetProperty.descr_property_del),
- __name__ = interp_attrproperty('name', cls=GetSetProperty),
+ __name__ = interp_attrproperty('name', cls=GetSetProperty,
+ wrapfn="newtext_or_none"),
__objclass__ = GetSetProperty(GetSetProperty.descr_get_objclass),
- __doc__ = interp_attrproperty('doc', cls=GetSetProperty),
+ __doc__ = interp_attrproperty('doc', cls=GetSetProperty,
+ wrapfn="newtext_or_none"),
)
assert not W_MemberDescr.typedef.acceptable_as_base_class # no __new__
diff --git a/pypy/module/micronumpy/descriptor.py
b/pypy/module/micronumpy/descriptor.py
--- a/pypy/module/micronumpy/descriptor.py
+++ b/pypy/module/micronumpy/descriptor.py
@@ -1128,12 +1128,12 @@
__new__ = interp2app(descr__new__),
type = interp_attrproperty_w("w_box_type", cls=W_Dtype),
- kind = interp_attrproperty("kind", cls=W_Dtype),
- char = interp_attrproperty("char", cls=W_Dtype),
- num = interp_attrproperty("num", cls=W_Dtype),
- byteorder = interp_attrproperty("byteorder", cls=W_Dtype),
- itemsize = interp_attrproperty("elsize", cls=W_Dtype),
- alignment = interp_attrproperty("alignment", cls=W_Dtype),
+ kind = interp_attrproperty("kind", cls=W_Dtype, wrapfn="newtext"),
+ char = interp_attrproperty("char", cls=W_Dtype, wrapfn="newtext"),
+ num = interp_attrproperty("num", cls=W_Dtype, wrapfn="newint"),
+ byteorder = interp_attrproperty("byteorder", cls=W_Dtype,
wrapfn="newtext"),
+ itemsize = interp_attrproperty("elsize", cls=W_Dtype, wrapfn="newint"),
+ alignment = interp_attrproperty("alignment", cls=W_Dtype, wrapfn="newint"),
name = GetSetProperty(W_Dtype.descr_get_name),
str = GetSetProperty(W_Dtype.descr_get_str),
diff --git a/pypy/module/micronumpy/ufuncs.py b/pypy/module/micronumpy/ufuncs.py
--- a/pypy/module/micronumpy/ufuncs.py
+++ b/pypy/module/micronumpy/ufuncs.py
@@ -1199,8 +1199,10 @@
identity = GetSetProperty(W_Ufunc.descr_get_identity),
accumulate = interp2app(W_Ufunc.descr_accumulate),
- nin = interp_attrproperty("nin", cls=W_Ufunc),
- nout = interp_attrproperty("nout", cls=W_Ufunc),
+ nin = interp_attrproperty("nin", cls=W_Ufunc,
+ wrapfn="newint"),
+ nout = interp_attrproperty("nout", cls=W_Ufunc,
+ wrapfn="newint"),
nargs = interp_attrproperty("nargs", cls=W_Ufunc),
signature = interp_attrproperty("signature", cls=W_Ufunc),
diff --git a/pypy/module/pypyjit/interp_resop.py
b/pypy/module/pypyjit/interp_resop.py
--- a/pypy/module/pypyjit/interp_resop.py
+++ b/pypy/module/pypyjit/interp_resop.py
@@ -199,7 +199,7 @@
__new__ = interp2app(descr_new_resop),
__repr__ = interp2app(WrappedOp.descr_repr),
name = GetSetProperty(WrappedOp.descr_name),
- offset = interp_attrproperty("offset", cls=WrappedOp),
+ offset = interp_attrproperty("offset", cls=WrappedOp, wrapfn="newint"),
)
WrappedOp.typedef.acceptable_as_base_class = False
@@ -209,8 +209,8 @@
__new__ = interp2app(descr_new_guardop),
__repr__ = interp2app(GuardOp.descr_repr),
name = GetSetProperty(GuardOp.descr_name),
- offset = interp_attrproperty("offset", cls=GuardOp),
- hash = interp_attrproperty("hash", cls=GuardOp),
+ offset = interp_attrproperty("offset", cls=GuardOp, wrapfn="newint"),
+ hash = interp_attrproperty("hash", cls=GuardOp, wrapfn="newint"),
)
GuardOp.typedef.acceptable_as_base_class = False
@@ -226,9 +226,9 @@
bytecode_no = GetSetProperty(DebugMergePoint.get_bytecode_no,
doc="offset in the bytecode"),
call_depth = interp_attrproperty("call_depth", cls=DebugMergePoint,
- doc="Depth of calls within this loop"),
+ doc="Depth of calls within this loop",
wrapfn="newint"),
call_id = interp_attrproperty("call_id", cls=DebugMergePoint,
- doc="Number of applevel function traced in this loop"),
+ doc="Number of applevel function traced in this loop",
wrapfn="newint"),
jitdriver_name = GetSetProperty(DebugMergePoint.get_jitdriver_name,
doc="Name of the jitdriver 'pypyjit' in the case "
"of the main interpreter loop"),
@@ -311,7 +311,8 @@
__doc__ = W_JitLoopInfo.__doc__,
__new__ = interp2app(descr_new_jit_loop_info),
jitdriver_name = interp_attrproperty('jd_name', cls=W_JitLoopInfo,
- doc="Name of the JitDriver, pypyjit for the main one"),
+ doc="Name of the JitDriver, pypyjit for the main one",
+ wrapfn="newtext"),
greenkey = interp_attrproperty_w('w_green_key', cls=W_JitLoopInfo,
doc="Representation of place where the loop was compiled. "
"In the case of the main interpreter loop, it's a triplet "
@@ -319,15 +320,19 @@
operations = interp_attrproperty_w('w_ops', cls=W_JitLoopInfo, doc=
"List of operations in this loop."),
loop_no = interp_attrproperty('loop_no', cls=W_JitLoopInfo, doc=
- "Loop cardinal number"),
+ "Loop cardinal number",
+ wrapfn="newint"),
bridge_no = GetSetProperty(W_JitLoopInfo.descr_get_bridge_no,
doc="bridge number (if a bridge)"),
type = interp_attrproperty('type', cls=W_JitLoopInfo,
- doc="Loop type"),
+ doc="Loop type",
+ wrapfn="newtext"),
asmaddr = interp_attrproperty('asmaddr', cls=W_JitLoopInfo,
- doc="Address of machine code"),
+ doc="Address of machine code",
+ wrapfn="newint"),
asmlen = interp_attrproperty('asmlen', cls=W_JitLoopInfo,
- doc="Length of machine code"),
+ doc="Length of machine code",
+ wrapfn="newint"),
__repr__ = interp2app(W_JitLoopInfo.descr_repr),
)
W_JitLoopInfo.typedef.acceptable_as_base_class = False
diff --git a/pypy/module/struct/interp_struct.py
b/pypy/module/struct/interp_struct.py
--- a/pypy/module/struct/interp_struct.py
+++ b/pypy/module/struct/interp_struct.py
@@ -134,8 +134,8 @@
W_Struct.typedef = TypeDef("Struct",
__new__=interp2app(W_Struct.descr__new__.im_func),
- format=interp_attrproperty("format", cls=W_Struct),
- size=interp_attrproperty("size", cls=W_Struct),
+ format=interp_attrproperty("format", cls=W_Struct, wrapfn="newbytes"),
+ size=interp_attrproperty("size", cls=W_Struct, wrapfn="newint"),
pack=interp2app(W_Struct.descr_pack),
unpack=interp2app(W_Struct.descr_unpack),
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
@@ -322,7 +322,8 @@
UCD.typedef = TypeDef("unicodedata.UCD",
__doc__ = "",
- unidata_version = interp_attrproperty('version', UCD),
+ unidata_version = interp_attrproperty('version', UCD,
+ wrapfn="newtext"),
**methods)
ucd_3_2_0 = UCD(unicodedb_3_2_0)
diff --git a/pypy/module/zlib/interp_zlib.py b/pypy/module/zlib/interp_zlib.py
--- a/pypy/module/zlib/interp_zlib.py
+++ b/pypy/module/zlib/interp_zlib.py
@@ -347,8 +347,8 @@
__new__ = interp2app(Decompress___new__),
decompress = interp2app(Decompress.decompress),
flush = interp2app(Decompress.flush),
- unused_data = interp_attrproperty('unused_data', Decompress),
- unconsumed_tail = interp_attrproperty('unconsumed_tail', Decompress),
+ unused_data = interp_attrproperty('unused_data', Decompress,
wrapfn="newbytes"),
+ unconsumed_tail = interp_attrproperty('unconsumed_tail', Decompress,
wrapfn="newbytes"),
__doc__ = """decompressobj([wbits]) -- Return a decompressor object.
Optional arg wbits is the window buffer size.
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit