brownplt / lambda-py

Other
58 stars 10 forks source link

string identity fails for equal strings #57

Closed amtriathlon closed 11 years ago

amtriathlon commented 11 years ago

For example:

s = "abc" assert s is "abc"

works in Python and fails in lambda-py, that's the reason these control tests https://github.com/brownplt/lambda-py/commit/95dad02d1cc4255dbfda3f8e7008cfc794062084 are failing, I moved them to tests/bugs.

amtriathlon commented 11 years ago

It is not a bug, identity is not the same as equality for str even in CPython 3.2.3:

Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> a = 'pub'
>> b = ''.join(['p', 'u', 'b'])
>>> a == b
True
>>> a is b
False
>>> 

Example from http://stackoverflow.com/questions/1504717/python-vs-is-comparing-strings-is-fails-sometimes-why

jpolitz commented 11 years ago

Sorry I meant that it was a broken feature to use to test. My message was just vague.

On Wed, Mar 27, 2013 at 4:03 PM, Alejandro Martinez < notifications@github.com> wrote:

It is not a bug, identity is not the same as equality for str even in CPython 3.2.3:

Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information.

a = 'pub' b = ''.join(['p', 'u', 'b']) a == b True a is b False

Example from http://stackoverflow.com/questions/1504717/python-vs-is-comparing-strings-is-fails-sometimes-why

— Reply to this email directly or view it on GitHubhttps://github.com/brownplt/lambda-py/issues/57#issuecomment-15549653 .