Skip to content

gh-77748: Document that float() accepts bytes-like objects - #155501

Open
Qanty228 wants to merge 18 commits into
python:mainfrom
Qanty228:float-doc-fix
Open

gh-77748: Document that float() accepts bytes-like objects#155501
Qanty228 wants to merge 18 commits into
python:mainfrom
Qanty228:float-doc-fix

Conversation

@Qanty228

@Qanty228 Qanty228 commented Aug 10, 2026

Copy link
Copy Markdown

fixes #77748
Update the float.__new__ docstring to state that float() accepts bytes-like objects.

@python-cla-bot

python-cla-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app

bedevere-app Bot commented Aug 10, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@skirpichev skirpichev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also modify the sphinx docs (https://docs.python.org/3.14/library/functions.html#float).

Comment thread Misc/NEWS.d/next/Documentation/2026-08-10-18-13-43.gh-issue-77748.aVLelN.rst Outdated
Comment thread Objects/floatobject.c
@skirpichev skirpichev added skip news needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Aug 11, 2026
@read-the-docs-community

read-the-docs-community Bot commented Aug 11, 2026

Copy link
Copy Markdown

@Qanty228
Qanty228 requested a review from skirpichev August 11, 2026 16:38
@skirpichev
skirpichev removed their request for review August 11, 2026 19:28
@Qanty228
Qanty228 requested a review from skirpichev August 11, 2026 20:34
Comment thread Doc/library/functions.rst Outdated
Comment thread Doc/library/functions.rst Outdated
Comment thread Doc/library/functions.rst Outdated
Comment on lines +813 to +815
If the argument is a bytes-like object, its contents are parsed as a decimal
string. Therefore, the bytes-like object must contain a valid representation
of a floating-point number, otherwise :exc:`ValueError` is raised.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a wrong place. Move it under the productionlist directive, after full description of the string output.

And rephrase somehow like this: "Bytes-like argument should contain only sequence of ASCII characters, conforming to the :token:~float:floatvalue rule."

Qanty228 and others added 2 commits August 22, 2026 02:24
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
@Qanty228
Qanty228 requested a review from skirpichev August 21, 2026 23:59
Comment thread Doc/library/functions.rst Outdated
Comment thread Doc/library/functions.rst Outdated
Qanty228 and others added 2 commits August 22, 2026 03:52
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants