On Mon, Mar 4, 2013 at 11:06 AM, Amaury Forgeot d'Arc <amaur...@gmail.com> wrote: > > > 2013/3/4 Serhiy Storchaka <storch...@gmail.com> >> >> On 01.03.13 17:24, Stefan Bucur wrote: >>> >>> Before digging deeper into the issue, I wanted to ask here if there are >>> any implicit assumptions about string identity and interning throughout >>> the interpreter implementation. For instance, are two single-char >>> strings having the same content supposed to be identical objects? >> >> >> I think this is not a bug if the code relies on the fact that an empty >> string is a singleton. This obviously is an immutable object and there is no >> public method to create different empty string. > > > Really? > >>>> x = u'\xe9'.encode('ascii', 'ignore') >>>> x == '', x is '' > (True, False)
Code that relies on this is incorrect (the language doesn't guarantee interning) but nevertheless given the intention of the implementation, that behavior of encode() is also a bug. -- --Guido van Rossum (python.org/~guido) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com