Author: Armin Rigo <[email protected]>
Branch: py3.5-newtext
Changeset: r90125:451198f306e0
Date: 2017-02-14 18:36 +0100
http://bitbucket.org/pypy/pypy/changeset/451198f306e0/
Log: hg merge 036370c1dfd7 (probably buggy)
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -805,6 +805,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
@@ -273,7 +273,7 @@
self.fdel = fdel
self.doc = doc
self.reqcls = cls
- self.qualname = None
+ self.w_qualname = None
self.objclass_getter = objclass_getter
self.use_closure = use_closure
self.name = name if name is not None else '<generic property>'
@@ -336,19 +336,19 @@
space.newtext(self.name)]))
def descr_get_qualname(self, space):
- if self.qualname is None:
- self.qualname = self._calculate_qualname(space)
- return self.qualname
+ if self.w_qualname is None:
+ self.w_qualname = self._calculate_qualname(space)
+ return self.w_qualname
def _calculate_qualname(self, space):
if self.reqcls is None:
- type_qualname = u'?'
+ type_qualname = '?'
else:
w_type = space.gettypeobject(self.reqcls.typedef)
- type_qualname = space.unicode_w(
- space.getattr(w_type, space.wrap('__qualname__')))
- qualname = u"%s.%s" % (type_qualname, self.name.decode('utf-8'))
- return space.wrap(qualname)
+ type_qualname = space.text_w(
+ space.getattr(w_type, space.newtext('__qualname__')))
+ qualname = "%s.%s" % (type_qualname, self.name)
+ return space.newtext(qualname)
def descr_get_objclass(space, property):
if property.w_objclass is not None:
@@ -360,23 +360,11 @@
"generic property has no __objclass__")
-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 GetSetProperty(fget, cls=cls, doc=doc)
-
-def interp_attrproperty_bytes(name, cls, doc=None):
- "NOT_RPYTHON: initialization-time only"
- def fget(space, obj):
- return space.newbytes(getattr(obj, name))
- return GetSetProperty(fget, cls=cls, doc=doc)
-
-def interp_attrproperty_fsdecode(name, cls, doc=None):
- "NOT_RPYTHON: initialization-time only"
- def fget(space, obj):
- return space.fsdecode(space.newbytes(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):
@@ -395,10 +383,10 @@
__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"),
__qualname__ = GetSetProperty(GetSetProperty.descr_get_qualname),
__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__
@@ -451,7 +439,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__
@@ -581,7 +569,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_kwonlyargcount = GetSetProperty(fget_zero, cls=Code),
@@ -592,7 +580,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_kwonlyargcount = GetSetProperty(fget_zero, cls=BuiltinCode),
@@ -609,21 +597,21 @@
__hash__ = interp2app(PyCode.descr_code__hash__),
__reduce__ = interp2app(PyCode.descr__reduce__),
__repr__ = interp2app(PyCode.repr),
- co_argcount = interp_attrproperty('co_argcount', cls=PyCode),
- co_kwonlyargcount = interp_attrproperty('co_kwonlyargcount', 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_bytes('co_code', cls=PyCode),
+ co_argcount = interp_attrproperty('co_argcount', cls=PyCode,
wrapfn="newint"),
+ co_kwonlyargcount = interp_attrproperty('co_kwonlyargcount', 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_fsdecode('co_filename', cls=PyCode),
- co_name = interp_attrproperty('co_name', cls=PyCode),
- co_firstlineno = interp_attrproperty('co_firstlineno', cls=PyCode),
- co_lnotab = interp_attrproperty_bytes('co_lnotab', cls=PyCode),
+ co_filename = interp_attrproperty('co_filename', cls=PyCode,
wrapfn="wrap_fsdecoded"),
+ 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
@@ -798,10 +786,10 @@
__reduce__ = interp2app(PyTraceback.descr__reduce__),
__setstate__ = interp2app(PyTraceback.descr__setstate__),
__dir__ = interp2app(PyTraceback.descr__dir__),
- 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__
@@ -819,7 +807,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_gicr_frame),
gi_code = interp_attrproperty_w('pycode', cls=GeneratorIterator),
gi_yieldfrom=interp_attrproperty_w('w_yielded_from',
cls=GeneratorIterator),
@@ -843,7 +831,7 @@
descrmismatch='close'),
__await__ = interp2app(Coroutine.descr__await__,
descrmismatch='__await__'),
- cr_running = interp_attrproperty('running', cls=Coroutine),
+ cr_running = interp_attrproperty('running', cls=Coroutine,
wrapfn="newbool"),
cr_frame = GetSetProperty(Coroutine.descr_gicr_frame),
cr_code = interp_attrproperty_w('pycode', cls=Coroutine),
cr_await = interp_attrproperty_w('w_yielded_from', cls=Coroutine),
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
@@ -343,10 +343,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/_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
@@ -531,7 +531,7 @@
_dealloc_warn = interp2app(W_FileIO._dealloc_warn_w),
name = interp_member_w('w_name', cls=W_FileIO),
closefd = interp_attrproperty(
- 'closefd', cls=W_FileIO,
+ 'closefd', cls=W_FileIO, wrapfn="newbool",
doc="True if the file descriptor will be closed"),
mode = GetSetProperty(W_FileIO.descr_get_mode,
doc="String giving the file mode"),
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
@@ -1080,7 +1080,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(
'_lsprof.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(
'_lsprof.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 OperationError, 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"),
)
@@ -145,7 +147,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
@@ -197,7 +197,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),
@@ -221,7 +221,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
@@ -252,7 +252,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
@@ -271,8 +271,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),
@@ -383,7 +385,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),
)
@@ -404,7 +406,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
@@ -494,9 +494,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 = GetSetProperty(W_SRE_Pattern.fget_groupindex),
- 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
@@ -687,7 +689,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),
@@ -749,6 +751,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
@@ -4,7 +4,7 @@
from rpython.rtyper.lltypesystem import lltype
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.typedef import TypeDef, interp_attrproperty_bytes
+from pypy.interpreter.typedef import TypeDef, interp_attrproperty
from pypy.interpreter.typedef import GetSetProperty
from pypy.interpreter.gateway import interp2app, unwrap_spec
from rpython.translator.tool.cbuild import ExternalCompilationInfo
@@ -543,7 +543,8 @@
__doc__ = W_BZ2Decompressor.__doc__,
__new__ = interp2app(descr_decompressor__new__),
__getstate__ = interp2app(W_BZ2Decompressor.descr_getstate),
- unused_data = interp_attrproperty_bytes("unused_data", W_BZ2Decompressor),
+ unused_data = interp_attrproperty("unused_data", W_BZ2Decompressor,
+ wrapfn="newbytes"),
eof = GetSetProperty(W_BZ2Decompressor.eof_w),
decompress = interp2app(W_BZ2Decompressor.decompress),
needs_input = GetSetProperty(W_BZ2Decompressor.needs_input_w),
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
@@ -229,7 +229,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
@@ -237,7 +238,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),
)
@@ -247,7 +249,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),
@@ -259,8 +262,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
@@ -6,8 +6,8 @@
from pypy.interpreter.baseobjspace import W_Root, DescrMismatch
from pypy.interpreter.error import oefmt
-from pypy.interpreter.typedef import (
- GetSetProperty, TypeDef, interp_attrproperty, interp2app)
+from pypy.interpreter.typedef import (GetSetProperty, TypeDef,
+ interp_attrproperty, interp2app)
from pypy.module.__builtin__.abstractinst import abstract_issubclass_w
from pypy.module.cpyext import structmemberdefs
from pypy.module.cpyext.api import (
@@ -102,9 +102,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
@@ -1127,12 +1127,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
@@ -6,8 +6,7 @@
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.error import OperationError, oefmt
-from pypy.interpreter.typedef import (
- TypeDef, interp_attrproperty, interp_attrproperty_bytes)
+from pypy.interpreter.typedef import TypeDef, interp_attrproperty
from pypy.module.struct.formatiterator import (
PackFormatIterator, UnpackFormatIterator
)
@@ -172,8 +171,8 @@
W_Struct.typedef = TypeDef("Struct",
__new__=interp2app(W_Struct.descr__new__.im_func),
- format=interp_attrproperty_bytes("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
@@ -331,7 +331,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
@@ -1,7 +1,7 @@
import sys
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.typedef import TypeDef, interp_attrproperty_bytes,
interp_attrproperty
+from pypy.interpreter.typedef import TypeDef, interp_attrproperty
from pypy.interpreter.error import OperationError, oefmt
from rpython.rlib.rarithmetic import intmask, r_uint, r_uint32
from rpython.rlib.objectmodel import keepalive_until_here
@@ -344,9 +344,9 @@
__new__ = interp2app(Decompress___new__),
decompress = interp2app(Decompress.decompress),
flush = interp2app(Decompress.flush),
- unused_data = interp_attrproperty_bytes('unused_data', Decompress),
- unconsumed_tail = interp_attrproperty_bytes('unconsumed_tail', Decompress),
- eof = interp_attrproperty('eof', Decompress),
+ unused_data = interp_attrproperty('unused_data', Decompress,
wrapfn="newbytes"),
+ unconsumed_tail = interp_attrproperty('unconsumed_tail', Decompress,
wrapfn="newbytes"),
+ eof = interp_attrproperty('eof', Decompress, wrapfn="newbool"),
__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