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

asyncio.sleep(float('nan')) does not raise ValueError #105331

Closed
Labels
@jakkdl

Description

@jakkdl

Bug report

time.sleep(float('nan')) raisesValueError, butasyncio.sleep(float('nan')) is valid and sleeps for 0. This seems bad, andasyncio.sleep should probably also raiseValueError.

importasyncioimporttimetry:time.sleep(float('nan'))exceptValueError:print("time.sleep raised ValueError")asyncdeffoo()->None:awaitasyncio.sleep(float('nan'))print("asyncio.sleep does not raise any error")asyncio.run(foo())
$ python foo.pytime.sleep raised ValueErrorasyncio.sleep does not raise any error

time.sleep andasyncio.sleep do differ in behaviour when it comes to negative numbers and changing that behaviour was considered a breaking change without strong reason:#83879
nan feels like it shouldvery rare to be passed intentionally, but the potential gain might also be small enough that this isn't worth fixing.

Related:python-trio/trio#2493

Your environment

  • CPython versions tested on: 3.8 to 3.11
  • Operating system and architecture:Linux 6.3.4-arch1-1

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp