This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xtreak
Recipients belopolsky, eric.smith, matrixise, mjsaah, xtreak
Date 2018-10-25.17:22:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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.

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%', '%#' ]:
                    time.strftime(x * y + z)
                except ValueError:

I am adding @belopolsky who might have thoughts on the change.

Thanks for the report.
Date User Action Args
2018-10-25 17:22:41xtreaksetrecipients: + xtreak, belopolsky, eric.smith, matrixise, mjsaah
2018-10-25 17:22:41xtreaksetmessageid: <>
2018-10-25 17:22:41xtreaklinkissue35066 messages
2018-10-25 17:22:41xtreakcreate