Skip to content

Docs: Inconsistent signature in help() for str.count #138969

@0-op

Description

@0-op

Bug report

Bug description:

# The help() output for str.count lacks the '/' for positional-only arguments
help(str.count)
# Relevant output line:
# count(...) unbound builtins.str method
# S.count(sub[, start[, end]]) -> int

# In contrast, str.strip correctly shows the '/' marker
help(str.strip)
# Relevant output line:
# strip(self, chars=None, /) unbound builtins.str method

Description

There is an inconsistency in the signature displayed by the built-in help() function for str.count when compared to other similar methods like str.strip.

While str.count is functionally a positional-only argument method (it raises a TypeError if called with keyword arguments), its signature in help() does not include the / marker to indicate this. This is inconsistent with other methods that correctly display the positional-only marker.

This can be a minor point of confusion for users learning about Python's function signatures and introspection.

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions