Pull requests

#69 Declined
Repository
kostialopuhin/pypy-my-messed-up-fork pypy-my-messed-up-fork
Branch
default
Repository
pypy/pypy pypy
Branch
default

Fix Issue 1180 - implement bool formatting

Author
  1. Konstantin Lopuhin
Reviewers
Description

Not sure if I should have added tests in lib-python

Comments (3)

  1. Amaury Forgeot d'Arc

    Could you add some tests with a format_spec? For example, assert "{:f}".format(True) == '1.000000' assert "{:05d}".format(False) == '00000' (these are values returned by CPython. To check, run tests with the -A option -- and be sure to use Python2.7)

    Actually, in CPython there is no specific code for booleans. But an empty format_spec always delegate to str().

  2. Armin Rigo

    Ah, so "{0}".format(x) returns "foo" if x is an instance of class foo(int): def str(self): return "foo". It even works already on pypy... Not sure I understand why it does, but bools don't print as their str()?