Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2to3 doesn't handle byte comparison well #53289

Closed
vdupras mannequin opened this issue Jun 21, 2010 · 3 comments
Closed

2to3 doesn't handle byte comparison well #53289

vdupras mannequin opened this issue Jun 21, 2010 · 3 comments
Labels
topic-2to3 type-bug An unexpected behavior, bug, or error

Comments

@vdupras
Copy link
Mannequin

vdupras mannequin commented Jun 21, 2010

BPO 9043
Nosy @terryjreedy, @benjaminp

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2010-06-21.14:59:11.300>
created_at = <Date 2010-06-21.14:46:13.908>
labels = ['type-bug', 'expert-2to3']
title = "2to3 doesn't handle byte comparison well"
updated_at = <Date 2010-06-25.21:19:57.080>
user = 'https://bugs.python.org/vdupras'

bugs.python.org fields:

activity = <Date 2010-06-25.21:19:57.080>
actor = 'terry.reedy'
assignee = 'none'
closed = True
closed_date = <Date 2010-06-21.14:59:11.300>
closer = 'benjamin.peterson'
components = ['2to3 (2.x to 3.x conversion tool)']
creation = <Date 2010-06-21.14:46:13.908>
creator = 'vdupras'
dependencies = []
files = []
hgrepos = []
issue_num = 9043
keywords = []
message_count = 3.0
messages = ['108272', '108273', '108633']
nosy_count = 3.0
nosy_names = ['terry.reedy', 'benjamin.peterson', 'vdupras']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue9043'
versions = ['Python 2.7']

@vdupras
Copy link
Mannequin Author

vdupras mannequin commented Jun 21, 2010

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?

@vdupras vdupras mannequin added topic-2to3 type-bug An unexpected behavior, bug, or error labels Jun 21, 2010
@benjaminp
Copy link
Contributor

2to3 can't guess which slices are from bytes.

@terryjreedy
Copy link
Member

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

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-2to3 type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants