Skip to content

{:d} format should support bool value. #4939

@xiaxinmeng

Description

@xiaxinmeng

{:d} format is supported to pass a boolean value. See the following test case. CPython can execute it and return expected result, while RustPython report a TypeError.

for i in range(12):
    print('{:d}, '.format(chr(i) in "ss"), end='')
    if i % 16 == 1:
        print()

Behaviors on CPython:

0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 

Behaviors on RustPython

Traceback (most recent call last):
  File "/home/xxm/Desktop/RustPython/test.py", line 169, in <module>
    print('{:d}, '.format(chr(i) in "ss"), end='')
TypeError: unsupported format string passed to bool.__format__

Ubuntu 18.04
RustPython 0.2.0 0284059
CPython 3.8.0, 3.9.0, 3.11.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions