Author: Ronan Lamy <[email protected]>
Branch:
Changeset: r93401:0ad21cfe4469
Date: 2017-12-12 22:14 +0000
http://bitbucket.org/pypy/pypy/changeset/0ad21cfe4469/
Log: Small cleanup
diff --git a/pypy/module/_codecs/interp_codecs.py
b/pypy/module/_codecs/interp_codecs.py
--- a/pypy/module/_codecs/interp_codecs.py
+++ b/pypy/module/_codecs/interp_codecs.py
@@ -369,12 +369,16 @@
# ____________________________________________________________
# delegation to runicode/unicodehelper
+def _find_implementation(impl_name):
+ try:
+ func = getattr(unicodehelper, impl_name)
+ except AttributeError:
+ func = getattr(runicode, impl_name)
+ return func
+
def make_encoder_wrapper(name):
rname = "unicode_encode_%s" % (name.replace("_encode", ""), )
- try:
- func = getattr(unicodehelper, rname)
- except AttributeError:
- func = getattr(runicode, rname)
+ func = _find_implementation(rname)
@unwrap_spec(uni=unicode, errors='text_or_none')
def wrap_encoder(space, uni, errors="strict"):
if errors is None:
@@ -387,10 +391,7 @@
def make_decoder_wrapper(name):
rname = "str_decode_%s" % (name.replace("_decode", ""), )
- try:
- func = getattr(unicodehelper, rname)
- except AttributeError:
- func = getattr(runicode, rname)
+ func = _find_implementation(rname)
@unwrap_spec(string='bufferstr', errors='text_or_none',
w_final=WrappedDefault(False))
def wrap_decoder(space, string, errors="strict", w_final=None):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit