[pypy-commit] pypy default: switch multibytecodec to use the decorator unwrap_spec, which is prettier
alex_gaynor
noreply at buildbot.pypy.org
Fri May 20 20:46:33 CEST 2011
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r44334:2df6c44ca312
Date: 2011-05-20 13:55 -0500
http://bitbucket.org/pypy/pypy/changeset/2df6c44ca312/
Log: switch multibytecodec to use the decorator unwrap_spec, which is
prettier
diff --git a/pypy/module/_multibytecodec/interp_multibytecodec.py b/pypy/module/_multibytecodec/interp_multibytecodec.py
--- a/pypy/module/_multibytecodec/interp_multibytecodec.py
+++ b/pypy/module/_multibytecodec/interp_multibytecodec.py
@@ -1,5 +1,5 @@
from pypy.interpreter.baseobjspace import Wrappable
-from pypy.interpreter.gateway import ObjSpace, interp2app
+from pypy.interpreter.gateway import ObjSpace, interp2app, unwrap_spec
from pypy.interpreter.typedef import TypeDef
from pypy.interpreter.error import OperationError
from pypy.module._multibytecodec import c_codecs
@@ -11,6 +11,7 @@
self.name = name
self.codec = codec
+ @unwrap_spec(input=str, errors="str_or_None")
def decode(self, space, input, errors=None):
if errors is not None and errors != 'strict':
raise OperationError(space.w_NotImplementedError, # XXX
@@ -33,8 +34,8 @@
space.wrap("internal codec error"))
return space.newtuple([space.wrap(output),
space.wrap(len(input))])
- decode.unwrap_spec = ['self', ObjSpace, str, 'str_or_None']
+ @unwrap_spec(input=unicode, errors="str_or_None")
def encode(self, space, input, errors=None):
if errors is not None and errors != 'strict':
raise OperationError(space.w_NotImplementedError, # XXX
@@ -57,7 +58,6 @@
space.wrap("internal codec error"))
return space.newtuple([space.wrap(output),
space.wrap(len(input))])
- encode.unwrap_spec = ['self', ObjSpace, unicode, 'str_or_None']
MultibyteCodec.typedef = TypeDef(
@@ -69,6 +69,7 @@
MultibyteCodec.typedef.acceptable_as_base_class = False
+ at unwrap_spec(name=str)
def getcodec(space, name):
try:
codec = c_codecs.getcodec(name)
@@ -76,4 +77,3 @@
raise OperationError(space.w_LookupError,
space.wrap("no such codec is supported."))
return space.wrap(MultibyteCodec(name, codec))
-getcodec.unwrap_spec = [ObjSpace, str]
More information about the pypy-commit
mailing list