Issue 9043: 2to3 doesn't handle byte comparison well (original) (raw)
Issue9043
Created on 2010-06-21 14:46 by vdupras, last changed 2022-04-11 14:57 by admin. This issue is now closed.
Messages (3) | ||
---|---|---|
msg108272 - (view) | Author: Virgil Dupras (vdupras) ![]() |
Date: 2010-06-21 14:46 |
If we run 2to3 on the following code: s = b' ' print s[0] == s we end up with this: s = b' ' print(s[0] == s) However, the first code, under python2 prints True while the converted code, under python3 prints False. Shouldn't 2to3 convert this code to: s = b' ' print s[0:1] == s instead? | ||
msg108273 - (view) | Author: Benjamin Peterson (benjamin.peterson) * ![]() |
Date: 2010-06-21 14:59 |
2to3 can't guess which slices are from bytes. | ||
msg108633 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2010-06-25 21:19 |
Replacing string indexes with length-1 slices in the 2.x codebase, whether or not one one is running 2to3, seems to be a 'known' technique for Python3 portability and unicode-bytes inter-operability. (It was discussed this week on py-dev list .) But I do not see it mentioned in PyWiki, such as on http://wiki.python.org/moin/PortingPythonToPy3k |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:57:02 | admin | set | github: 53289 |
2010-06-25 21:19:57 | terry.reedy | set | nosy: + terry.reedymessages: + |
2010-06-21 16:12:10 | eric.araujo | set | stage: resolved |
2010-06-21 14:59:11 | benjamin.peterson | set | status: open -> closednosy: + benjamin.petersonmessages: + resolution: wont fix |
2010-06-21 14:46:13 | vdupras | create |