Message345367
FWIW (unsurprisingly) the new test added here is broken on Cygwin, whose libc's (newlib) behavior in this undefined case. So I get:
>>> from datetime import date
>>> t = date(2005, 1, 1)
>>> t.strftime("%Y") # ok
'2005'
>>> t.strftime("%%") # ok
'%'
>>> t.strftime("%") # undefined behavior
''
>>> t.strftime("%Y %") # undefined behavior; discards the whole format string
''
>>> t.strftime("%Y%Q") # undefined format; discards the whole format string
''
This behavior is user-hostile I think; it should raise a ValueError instead of just return an empty string. I would have suggested the same for the trailing '%' case, though I understand the goal of this issue was consistency.
Also worth noting that both before and after this patch:
>>> import time
>>> time.strftime('%')
''
So the question of consistency between the interfaces, which was the main point of this issue, was already resolved in this case, and the *inconsistency* observed was dependent on system-dependent behavior.
For now I might propose doing away with this test in its current form, and just test
assert t.strftime('%') == time.strftime('%')
or something like that.
I agree with Victor that trying to make the strftime experience consistent across system-dependent quirks is a worthy goal, but that goes deeper than just this trailing '%' case. |
|
Date |
User |
Action |
Args |
2019-06-12 14:35:13 | erik.bray | set | recipients:
+ erik.bray, terry.reedy, belopolsky, vstinner, eric.smith, xdegaye, matrixise, thatiparthy, p-ganssle, pablogsal, miss-islington, xtreak, mjsaah |
2019-06-12 14:35:13 | erik.bray | set | messageid: <1560350113.85.0.703026867764.issue35066@roundup.psfhosted.org> |
2019-06-12 14:35:13 | erik.bray | link | issue35066 messages |
2019-06-12 14:35:13 | erik.bray | create | |
|