Erik Bray <[email protected]> added the comment:
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.
----------
nosy: +erik.bray
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35066>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com