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

Comparisons difference: bytes with bytes, str with str #60942

Closed
ivb mannequin opened this issue Dec 20, 2012 · 2 comments
Closed

Comparisons difference: bytes with bytes, str with str #60942

ivb mannequin opened this issue Dec 20, 2012 · 2 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@ivb
Copy link
Mannequin

ivb mannequin commented Dec 20, 2012

BPO 16738
Nosy @tiran

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 2012-12-20.13:55:34.934>
created_at = <Date 2012-12-20.13:49:38.237>
labels = ['type-bug', 'invalid']
title = 'Comparisons difference: bytes with bytes, str with str'
updated_at = <Date 2012-12-20.13:55:34.887>
user = 'https://bugs.python.org/ivb'

bugs.python.org fields:

activity = <Date 2012-12-20.13:55:34.887>
actor = 'christian.heimes'
assignee = 'none'
closed = True
closed_date = <Date 2012-12-20.13:55:34.934>
closer = 'christian.heimes'
components = []
creation = <Date 2012-12-20.13:49:38.237>
creator = 'ivb'
dependencies = []
files = []
hgrepos = []
issue_num = 16738
keywords = []
message_count = 2.0
messages = ['177817', '177819']
nosy_count = 2.0
nosy_names = ['christian.heimes', 'ivb']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue16738'
versions = ['Python 3.3']

@ivb
Copy link
Mannequin Author

ivb mannequin commented Dec 20, 2012

Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> b = b't'
>>> b[0] in [b]
False
>>> u = 't'
>>> u[0] in [u]
True

@ivb ivb mannequin added the type-bug An unexpected behavior, bug, or error label Dec 20, 2012
@tiran
Copy link
Member

tiran commented Dec 20, 2012

That's the correct behaviour. Iteration and item access of bytes don't return bytes but a small number, e.g. b[0] returns 116 and not b't'.

>>> b = b't'
>>> b[0]  in [b]
False
>>> b[0]
116
>>> ord(b)
116

But:
>>> b in [b]
True

@tiran tiran closed this as completed Dec 20, 2012
@tiran tiran added the invalid label Dec 20, 2012
@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
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant