A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-September/048749.html below:

[Python-Dev] unicode inconsistency?

[Python-Dev] unicode inconsistency? [Python-Dev] unicode inconsistency?Tim Peters tim.peters at gmail.com
Thu Sep 9 21:11:51 CEST 2004
[Neil Schemenauer]
> ...
> I suspect the fix will be pretty straight forward (call tp_str and
> if the result is 'unicode' the produce a 'unicode' string).  Again,
> is there some reason why we don't want this behavior?

Yes:  '%s' is documented as "String (converts any python object using
str())".  It's str(A()) that raises the exception you're seeing, not
interpolation.  To worm around that, you'll effectively have to
duplicate PyObject_Str's implementation (which is more than just
calling tp_str -- that may not exist -- you'll end up at least
duplicating PyObject_Repr's implementation too) inside
PyString_Format(), and end up with a mess that's harder to explain
too.

The *real* problem (IMO) is that we don't have a format code that
means "stick the unicode representation here", i.e. there's no format
code that triggers PyObject_Unicode() directly.  unicode.__mod__
treats '%s' that way, but that isn't documented.
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4