Message323963
The C datetime implementation uses PyUnicode_AsUTF8AndSize() in wrap_strftime() and rejects strings containing surrogate code points (0xD800 - 0xDFFF) since they can't be encoded in UTF-8. On the other hand, the pure-Python datetime implementation doesn't have this restriction:
>>> import sys
>>> sys.modules['_datetime'] = None # block C implementation
>>> from datetime import time
>>> time().strftime('\ud800')
'\ud800'
>>> del sys.modules['datetime']
>>> del sys.modules['_datetime']
>>> from datetime import time
>>> time().strftime('\ud800')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'utf-8' codec can't encode character '\ud800' in position 0: surrogates not allowed |
|
Date |
User |
Action |
Args |
2018-08-23 17:40:57 | izbyshev | set | recipients:
+ izbyshev, belopolsky, pitrou, taleinat, serhiy.storchaka |
2018-08-23 17:40:57 | izbyshev | set | messageid: <1535046057.5.0.56676864532.issue34481@psf.upfronthosting.co.za> |
2018-08-23 17:40:57 | izbyshev | link | issue34481 messages |
2018-08-23 17:40:57 | izbyshev | create | |
|