Commit 9f82e3e3 authored by Stefan Behnel's avatar Stefan Behnel

"ustring!s" (i.e. str(ustring)) is actually not safe to optimise away for...

"ustring!s" (i.e. str(ustring)) is actually not safe to optimise away for f-string formatting in Py2 as it can fail to encode the Unicode string to a byte string. And it's unlikely to appear in practice.
parent c4c202bb
......@@ -3045,8 +3045,8 @@ class FormattedValueNode(ExprNode):
self.format_spec = self.format_spec.analyse_types(env).coerce_to_pyobject(env)
if self.c_format_spec is None:
self.value = self.value.coerce_to_pyobject(env)
if not self.format_spec and self.value.type is unicode_type and not self.value.may_be_none():
if self.conversion_char in (None, 's'):
if not self.format_spec and not self.conversion_char:
if self.value.type is unicode_type and not self.value.may_be_none():
# value is definitely a unicode string and we don't format it any special
return self.value
return self
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment