This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author izbyshev
Recipients belopolsky, izbyshev, pitrou, serhiy.storchaka, taleinat
Date 2018-08-23.17:40:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1535046057.5.0.56676864532.issue34481@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2018-08-23 17:40:57izbyshevsetrecipients: + izbyshev, belopolsky, pitrou, taleinat, serhiy.storchaka
2018-08-23 17:40:57izbyshevsetmessageid: <1535046057.5.0.56676864532.issue34481@psf.upfronthosting.co.za>
2018-08-23 17:40:57izbyshevlinkissue34481 messages
2018-08-23 17:40:57izbyshevcreate