Skip to content

Explicitly mention bytes and other buffers in the documentation for float() #77748

Description

@mjpieters
mannequin
BPO 33567
Nosy @rhettinger, @mjpieters, @joelthelion

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 = None
created_at = <Date 2018-05-18.10:41:41.124>
labels = ['3.11', 'type-feature', '3.9', '3.10', 'docs']
title = 'Explicitly mention bytes and other buffers in the documentation for float()'
updated_at = <Date 2021-12-19.04:18:07.710>
user = 'https://github.com/mjpieters'

bugs.python.org fields:

activity = <Date 2021-12-19.04:18:07.710>
actor = 'rhettinger'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2018-05-18.10:41:41.124>
creator = 'mjpieters'
dependencies = []
files = []
hgrepos = []
issue_num = 33567
keywords = []
message_count = 1.0
messages = ['317022']
nosy_count = 4.0
nosy_names = ['rhettinger', 'mjpieters', 'docs@python', 'joelthelion']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue33567'
versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

Linked PRs

Activity

  1. mjpieters commented on May 18, 2018

    mjpietersmannequin
    MannequinAuthor

    float(bytesobject) treats the contents of the bytesobject as a sequence of ASCII characters, and converts those to a float value as if you used float(bytesobject.decode('ASCII')). The same support is extended to other objects implementing the buffer protocol.

    The documentation, however, doesn't mention this:

    Return a floating point number constructed from a number or string x.

    Everywhere else in the functions documentation, "string" refers to an object of type str. Please make it explicit that bytes is also acceptedable, like it does for the int() documentation.

  2. transferred this issue fromon Apr 10, 2022
  3. added and removed
    3.11only security fixes
    on Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirtype-featureA feature request or enhancement

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions