Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The ValueError for converting an all-whitespace string to a float misleadingly displays it as the empty string #95605

Closed
Labels
3.10only security fixes3.11only security fixes3.12only security fixestype-bugAn unexpected behavior, bug, or error
@Zeturic

Description

@Zeturic

Bug report

Actual behavior:

>>>float('\n')Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:couldnotconvertstringtofloat:''

Expected behavior:

>>>float('\n')Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:couldnotconvertstringtofloat:'\n'

As long as the string isn't completely whitespace, it does display properly. For example:

>>>float('\nn')Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:couldnotconvertstringtofloat:'\nn'

In addition to newlines, the same thing can be observed with tabs and carriage returns, or any combination of the three. I didn't test any additional whitespace characters, though they would likely behave the same way.

Your environment

  • CPython versions tested on: 3.10.5
  • Operating system and architecture: Windows 10 (64-bit)

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10only security fixes3.11only security fixes3.12only security fixestype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp