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

range.count returns boolean #54683

Closed
SilentGhost mannequin opened this issue Nov 20, 2010 · 5 comments
Closed

range.count returns boolean #54683

SilentGhost mannequin opened this issue Nov 20, 2010 · 5 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@SilentGhost
Copy link
Mannequin

SilentGhost mannequin commented Nov 20, 2010

BPO 10474
Nosy @abalkin, @benjaminp, @durban

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-11-20.22:36:13.866>
created_at = <Date 2010-11-20.22:26:58.055>
labels = ['interpreter-core', 'type-bug']
title = 'range.count returns boolean'
updated_at = <Date 2010-11-20.22:45:47.737>
user = 'https://bugs.python.org/SilentGhost'

bugs.python.org fields:

activity = <Date 2010-11-20.22:45:47.737>
actor = 'belopolsky'
assignee = 'none'
closed = True
closed_date = <Date 2010-11-20.22:36:13.866>
closer = 'benjamin.peterson'
components = ['Interpreter Core']
creation = <Date 2010-11-20.22:26:58.055>
creator = 'SilentGhost'
dependencies = []
files = []
hgrepos = []
issue_num = 10474
keywords = []
message_count = 5.0
messages = ['121799', '121802', '121803', '121806', '121807']
nosy_count = 4.0
nosy_names = ['belopolsky', 'benjamin.peterson', 'SilentGhost', 'daniel.urban']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue10474'
versions = ['Python 3.2']

@SilentGhost
Copy link
Mannequin Author

SilentGhost mannequin commented Nov 20, 2010

>>> a = range(5)
>>> a.count(5)
False
>>> a.count(2)
True

I believe this is related to the bpo-9213 that introduced count and index method on the range object. According to the documentation accompanying that fix it should return an integer.

@SilentGhost SilentGhost mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Nov 20, 2010
@benjaminp
Copy link
Contributor

r86618

@SilentGhost
Copy link
Mannequin Author

SilentGhost mannequin commented Nov 20, 2010

Benjamin, the docs say that it's possible to have count more than 1, depending on comparison rules. If that's the case, I'm afraid your solution might need to be adjusted.

@benjaminp
Copy link
Contributor

2010/11/20 SilentGhost <report@bugs.python.org>:

SilentGhost <michael.mischurow+bpo@gmail.com> added the comment:

Benjamin, the docs say that it's possible to have count more than 1, depending on comparison rules. If that's the case, I'm afraid your solution might need to be adjusted.

Produce a case where that's true, and I'll fix it.

@abalkin
Copy link
Member

abalkin commented Nov 20, 2010

SilentGhost,

Benjamin's fix only affect the optimized path when the argument is int or bool. Exotic comparison rules are handled in the else clause.

@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
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants