[Python-checkins] CVS: python/dist/src/Lib/test test_format.py,1.10,1.11

Tim Peters tim_one@users.sourceforge.net
Thu, 12 Apr 2001 11:38:50 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv15600/python/dist/src/Lib/test

Modified Files:
	test_format.py 
Log Message:
Bug 415514 reported that e.g.
    "%#x" % 0
blew up, at heart because C sprintf supplies a base marker if and only if
the value is not 0.  I then fixed that, by tolerating C's inconsistency
when it does %#x, and taking away that *Python* produced 0x0 when
formatting 0L (the "long" flavor of 0) under %#x itself.  But after talking
with Guido, we agreed it would be better to supply 0x for the short int
case too, despite that it's inconsistent with C, because C is inconsistent
with itself and with Python's hex(0) (plus, while "%#x" % 0 didn't work
before, "%#x" % 0L *did*, and returned "0x0").  Similarly for %#X conversion.


Index: test_format.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_format.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** test_format.py	2001/04/12 00:35:50	1.10
--- test_format.py	2001/04/12 18:38:48	1.11
***************
*** 177,184 ****
  testboth("%d", 0, "0")
  testboth("%d", 0L, "0")
! testboth("%#x", 0, "0")
! testboth("%#x", 0L, "0")
! testboth("%#X", 0, "0")
! testboth("%#X", 0L, "0")
  
  testboth("%x", 0x42, "42")
--- 177,184 ----
  testboth("%d", 0, "0")
  testboth("%d", 0L, "0")
! testboth("%#x", 0, "0x0")
! testboth("%#x", 0L, "0x0")
! testboth("%#X", 0, "0X0")
! testboth("%#X", 0L, "0X0")
  
  testboth("%x", 0x42, "42")