Michael Saah <mike.s...@gmail.com> added the comment:

>From a pure usability standpoint I'd prefer for datetime to match the time
behavior you're demonstrating, that is to not fail on a dangling %.

Of course I defer to the dev team on this, but I want to make clear where
I'm coming from.

On Thu, Oct 25, 2018 at 1:22 PM Karthikeyan Singaravelan <
rep...@bugs.python.org> wrote:

>
> Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:
>
> I am not sure time.strftime("%") should raise an error. There is an
> explicit test case and it's mentioned as platform dependent in the comment
> to raise a ValueError or succeed.  So I don't know if it should be changed
> despite the inconsistency and there is any reason behind this.
>
> The error regarding datetime module comes from SVN version and I couldn't
> get to know the original reason behind it and why the same was not carried
> over to time module.
>
> I agree with Eric that raising a DeprecationWarning for this and then
> removing it in later versions if we are going forward with this since we
> are making a platform dependent error as an expected error across platforms.
>
> In the below test case "%" doesn't raise ValueError on my Mac OS and
> Ubuntu machine.
>
>
> https://github.com/python/cpython/blob/9e95eb0d609cee23e6c9915c0bef243585b8c14b/Lib/test/test_time.py#L240
>
> def test_strftime_format_check(self):
>     # Test that strftime does not crash on invalid format strings
>     # that may trigger a buffer overread. When not triggered,
>     # strftime may succeed or raise ValueError depending on
>     # the platform.
>     for x in [ '', 'A', '%A', '%AA' ]:
>         for y in range(0x0, 0x10):
>             for z in [ '%', 'A%', 'AA%', '%A%', 'A%A%', '%#' ]:
>                 try:
>                     time.strftime(x * y + z)
>                 except ValueError:
>                     pass
>
>
> I am adding @belopolsky who might have thoughts on the change.
>
> Thanks for the report.
>
> ----------
> nosy: +belopolsky, xtreak
>
> _______________________________________
> Python tracker <rep...@bugs.python.org>
> <https://bugs.python.org/issue35066>
> _______________________________________
>

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35066>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

  • ... Michael Saah
    • ... Stéphane Wirtel
    • ... Eric V. Smith
      • ... Michael Saah
    • ... Karthikeyan Singaravelan
      • ... Michael Saah
    • ... Eric V. Smith
    • ... Eric V. Smith
    • ... శ్రీనివాస్ రెడ్డి తాటిపర్తి
    • ... Karthikeyan Singaravelan
      • ... Michael Saah
    • ... Terry J. Reedy
      • ... Michael Saah
    • ... Karthikeyan Singaravelan
      • ... Michael Saah
    • ... Paul Ganssle

Reply via email to