◐ Shell
reader mode source ↗
Skip to content

Fix #4157: handle error in case of unsupported format#4474

Closed
itsankitkp wants to merge 47 commits into
RustPython:mainfrom
itsankitkp:handle-panic-strftime
Closed

Fix #4157: handle error in case of unsupported format#4474
itsankitkp wants to merge 47 commits into
RustPython:mainfrom
itsankitkp:handle-panic-strftime

Conversation

@itsankitkp

Copy link
Copy Markdown
Contributor

Chrono panics in case of unsupported formats, this patch handles such cases and returns supplied format as a result.

@itsankitkp itsankitkp changed the title handle error in case of unsupported format Jan 27, 2023
@itsankitkp itsankitkp requested a review from fanninpm January 27, 2023 19:47
@fanninpm

Copy link
Copy Markdown
Contributor

It's fine to have that "%4Y" case in the extra_tests/.

@itsankitkp

Copy link
Copy Markdown
Contributor Author

It's fine to have that "%4Y" case in the extra_tests/.

Okay, I tried that but there is an issue
If I write assert_equal(_time.strftime("%4Y"), "%4Y"),
it runs first arg against cpython (which returns "2023") and 2nd part against rustpython (which returns "%4Y")
What I require is to run both first and second argument against rustpython only. Am I looking at wrong direction here?

Assertion Failure: <class 'str'>(2023) == <class 'str'>(%4Y)

@DimitrisJim DimitrisJim linked an issue Jan 30, 2023 that may be closed by this pull request
@itsankitkp itsankitkp force-pushed the handle-panic-strftime branch from 0cf0b04 to d4c2fd3 Compare January 31, 2023 15:30
@itsankitkp itsankitkp requested a review from fanninpm January 31, 2023 15:31
@itsankitkp

Copy link
Copy Markdown
Contributor Author

It's fine to have that "%4Y" case in the extra_tests/.

Okay, I tried that but there is an issue If I write assert_equal(_time.strftime("%4Y"), "%4Y"), it runs first arg against cpython (which returns "2023") and 2nd part against rustpython (which returns "%4Y") What I require is to run both first and second argument against rustpython only. Am I looking at wrong direction here?

Assertion Failure: <class 'str'>(2023) == <class 'str'>(%4Y)

I have fixed this for now by using unsupported format which returns same result in both python and rustpython.

@youknowone

Copy link
Copy Markdown
Member

@itsankitkp it passes tests on ubuntu, but not on macos and windows. could you check it?

----------------------------- Captured stdout call -----------------------------
Assertion Failure: <class 'str'>(?) == <class 'str'>(%?)
----------------------------- Captured stderr call -----------------------------
Traceback (most recent call last):
  File "/Users/runner/work/RustPython/RustPython/extra_tests/snippets/stdlib_datetime.py", line 135, in <module>
    assert_equal(_time.strftime("%?"), "%?")
  File "/Users/runner/work/RustPython/RustPython/extra_tests/snippets/testutils.py", line 58, in assert_equal
    _assert_print(lambda: a == b, [_typed(a), '==', _typed(b)])
  File "/Users/runner/work/RustPython/RustPython/extra_tests/snippets/testutils.py", line 47, in _assert_print
    assert f()
AssertionError

@itsankitkp itsankitkp force-pushed the handle-panic-strftime branch from fd2f370 to 052e984 Compare February 18, 2023 08:30
39 hidden items Load more…
@itsankitkp itsankitkp force-pushed the handle-panic-strftime branch from be812d7 to d4a6d39 Compare February 19, 2023 05:37
@youknowone

Copy link
Copy Markdown
Member

rebase seems messed up. could you try:

git fetch upstream
git rebase upstream/main

when upstream is github.com/RustPython/RustPython

@itsankitkp

Copy link
Copy Markdown
Contributor Author

rebase seems messed up. could you try:

git fetch upstream
git rebase upstream/main

when upstream is github.com/RustPython/RustPython

This branch was messed up, I have created fresh PR with same changes with history fixed.
Can you please take a look #4530

@itsankitkp

Copy link
Copy Markdown
Contributor Author

Closing as I have opened other PR: #4530 with fixed git history

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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