MAINT/ENH: datetime: remove calls to PyUnicode_AsASCIIString, allow μs as an alias for us#17176
Conversation
ae77176 to
e359477
Compare
Rather than raising UnicodeEncodeError, this just raises ValueError. Passing weird byte strings results in UnicodeDecodeError instead. In future, we may just want to deprecate passing `bytes` objects.
This is motivated primarily as a proof that the datetime API is now unicode-safe, and generally seems harmless.
e359477 to
d3e4792
Compare
|
PyPy failure is |
| def test_datetime_dtype_creation(self): | ||
| for unit in ['Y', 'M', 'W', 'D', | ||
| 'h', 'm', 's', 'ms', 'us', | ||
| 'μs', # alias for us |
There was a problem hiding this comment.
This assumes the file encoding is utf-8, which is the default. It might help some editors to explicitly add a
# -*- coding: utf-8 -*- directive to the first line of the file.
There was a problem hiding this comment.
Well, all non-dead versions of python assume source files are utf-8 too, so arguably an up to date editor should be able to guess the correct encoding.
If you're worried, I can also use \N{Greek small letter mu} instead.
|
Looks good, thanks. This flips the default case from |
|
That PyPy failure is on windows 32-bit, which we do not test for with CPython. I don't think it is connected to gh-16744. Has it appeared often? |
|
Thanks @eric-wieser |
I'd be very surprised if it wasn't |
Motivated by #15317.
Happy to revert the last commit, added it primarily as a test-case