-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
Open
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Issue
isreadable is documented as returning True if the object's repr is readable by the interpreter — implying eval(pformat(obj)) == obj. For float and complex non-finite values, isreadable returns True, but the roundtrip fails — eval raises NameError since inf and nan aren't valid Python expressions.
Reproducer
import pprint
print(pprint.isreadable(float('inf'))) # True — but eval('inf') raises NameError
print(pprint.isreadable(float('nan'))) # True
print(pprint.isreadable(complex(float('inf'), 0))) # TrueCPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error