Skip to content

time.strftime(arg) fails when arg is not valid format string #4157

Description

@jopemachine

Expected Result

In cpython, when arg is not a valid format string, strftime returns arg itself.

>>> import time
>>> time.strftime("%Y")
'2022'
>>> time.strftime("%4Y")
'4Y'

Actual Result

In RustPython, strftime raise panic when arg is not a valid format string

>>>>> import time
>>>>> time.strftime("%Y")
'2022'
>>>>> time.strftime("%4Y")
thread 'main' panicked at 'a Display implementation returned an error unexpectedly: Error', /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/alloc/src/string.rs:2490:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomersz-ca-2022Tag to track contrubution-academy 2022

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions