| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| # XXX this test case fails, this should have been handled in | ||
| # in in layers above fn strftime. | ||
| # self.assertRaises(ValueError, time.strftime, '%S\0', tt) | ||
|
|
||
| # check if unsupported arg in strftime returns arg itself | ||
| self.assertEqual(time.strftime("%4Y"), "%4Y") |
There was a problem hiding this comment.
Is this in CPython?
Sorry, something went wrong.
There was a problem hiding this comment.
No, CPython returns '2023'. But rust chrono doesn't support it yet
Sorry, something went wrong.
There was a problem hiding this comment.
We prefer to keep the tests in the Lib/test directory as close as possible to what's in CPython.
Sorry, something went wrong.
There was a problem hiding this comment.
Okay, should I keep it in extra_tests/snippets/stdlib_datetime.py ?
Sorry, something went wrong.
There was a problem hiding this comment.
If the "%S\0" case no longer panics, then you could change the decorator to this:
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_function():
# ...
Sorry, something went wrong.
There was a problem hiding this comment.
If the "%4Y" case no longer panics, then you could change the decorator to this:
# TODO: RUSTPYTHON @unittest.expectedFailure def test_function(): # ...
I have done this, test ran fine.
Sorry, something went wrong.
|
|
||
| let mut formatted_time = String::new(); | ||
|
|
||
| /* | ||
| * chrono doesn't support all formats and it | ||
| * raised an error if unsupported format is supplied. | ||
| * If error happens, we set result as input arg | ||
| */ | ||
| let result = write!(&mut formatted_time, "{}", instant.format(format.as_str())); | ||
| match result { | ||
| Ok(r) => r, | ||
| Err(_) => formatted_time = format.to_string(), | ||
| }; |
There was a problem hiding this comment.
Does this work?
| let mut formatted_time = String::new(); | |
| /* | |
| * chrono doesn't support all formats and it | |
| * raised an error if unsupported format is supplied. | |
| * If error happens, we set result as input arg | |
| */ | |
| let result = write!(&mut formatted_time, "{}", instant.format(format.as_str())); | |
| match result { | |
| Ok(r) => r, | |
| Err(_) => formatted_time = format.to_string(), | |
| }; | |
| let formatted_time = String::try_from(instant.format(format.as_str())).unwrap_or(|| format.to_string()); |
Sorry, something went wrong.
There was a problem hiding this comment.
I am getting following error
the trait std::convert::From<DelayedFormat<StrftimeItems<'_>>> is not implemented for std::string::String
Sorry, something went wrong.
There was a problem hiding this comment.
But I do see what you are trying to do here. I will give another pass at this.
Sorry, something went wrong.
There was a problem hiding this comment.
I have refactored code, it looks lot better now
Sorry, something went wrong.
|
It's fine to have that "%4Y" case in the extra_tests/. |
Sorry, something went wrong.
Okay, I tried that but there is an issue
|
Sorry, something went wrong.
I have fixed this for now by using unsupported format which returns same result in both python and rustpython. |
Sorry, something went wrong.
|
@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
|
Sorry, something went wrong.
Bumps [openssl-src](https://github.com/alexcrichton/openssl-src-rs) from 111.24.0+1.1.1s to 111.25.0+1.1.1t. - [Release notes](https://github.com/alexcrichton/openssl-src-rs/releases) - [Commits](https://github.com/alexcrichton/openssl-src-rs/commits) --- updated-dependencies: - dependency-name: openssl-src dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>
Chrono panics in case of unsupported formats, this patch handles such cases and returns supplied format as a result.
|
rebase seems messed up. could you try: git fetch upstream git rebase upstream/main when upstream is github.com/RustPython/RustPython |
Sorry, something went wrong.
This branch was messed up, I have created fresh PR with same changes with history fixed. |
Sorry, something went wrong.
|
Closing as I have opened other PR: #4530 with fixed git history |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Chrono panics in case of unsupported formats, this patch handles such cases and returns supplied format as a result.