Author: Antonio Cuni <[email protected]>
Branch: rpython-unicode-formatting
Changeset: r56139:0532b325c29c
Date: 2012-07-18 14:40 +0200
http://bitbucket.org/pypy/pypy/changeset/0532b325c29c/
Log: add proper support to (unicode %s unicode) formatting to ootype
diff --git a/pypy/rpython/ootypesystem/rstr.py
b/pypy/rpython/ootypesystem/rstr.py
--- a/pypy/rpython/ootypesystem/rstr.py
+++ b/pypy/rpython/ootypesystem/rstr.py
@@ -80,6 +80,12 @@
sb.ll_append_char(cast_primitive(Char, c))
return sb.ll_build()
+ def ll_unicode(self, s):
+ if s:
+ return s
+ else:
+ return self.convert_const(u'None')
+
def ll_encode_latin1(self, value):
sb = ootype.new(ootype.StringBuilder)
length = value.ll_strlen()
@@ -340,7 +346,12 @@
vitem, r_arg = argsiter.next()
if not hasattr(r_arg, 'll_str'):
raise TyperError("ll_str unsupported for: %r" % r_arg)
- if code == 's' or (code == 'r' and isinstance(r_arg,
InstanceRepr)):
+ if code == 's':
+ if is_unicode:
+ vchunk = hop.gendirectcall(r_arg.ll_unicode, vitem)
+ else:
+ vchunk = hop.gendirectcall(r_arg.ll_str, vitem)
+ elif code == 'r' and isinstance(r_arg, InstanceRepr):
vchunk = hop.gendirectcall(r_arg.ll_str, vitem)
elif code == 'd':
assert isinstance(r_arg, IntegerRepr)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit