[Bug] UTF8 character issues in strftime functions in datetime module
Thank you for making this project, pypy is fantastic!
I found this small bug when using strftime
with a format string containing Icelandic-specific characters.
The strftime
functions in the datetime
module cause a SystemError
when the format string argument contains multiple non-ASCII characters.
Example:
>>>> import datetime
>>>> datetime.datetime.now().strftime("%Dðððððððððððððððððððððððð")
RPython traceback:
File "pypy_interpreter.c", line 48201, in BuiltinCode2_fastcall_2
File "implement_5.c", line 25646, in fastfunc_strftime_2
File "pypy_module_time.c", line 309, in strftime
File "pypy_module__codecs.c", line 828, in str_decode_locale_surrogateescape
File "pypy_module__codecs.c", line 5076, in rawwcharp2utf8en
File "rpython_rlib.c", line 10322, in unichr_as_utf8
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/.../pypy_3.7/lib-python/3/datetime.py", line 916, in strftime
return _wrap_strftime(self, format, self.timetuple())
File "/.../pypy_3.7/lib-python/3/datetime.py", line 263, in _wrap_strftime
return _time.strftime(newformat, timetuple)
SystemError: unexpected internal exception (please report a bug): <OutOfRange object at 0x7f9519c281d0>; internal traceback was dumped to stderr
Same thing happens for other characters like e.g. 'Ж' or '꿀', and for strftime functions on time
or date
objects.
(However I couldn't reproduce the error with the character 'ß', in case that information helps somehow.)
Pypy version used:
Python 3.7.13 (7e0ae751533460d5f89f3ac48ce366d8642d1db5, Mar 29 2022, 06:03:31)
[PyPy 7.3.9 with GCC 10.2.1 20210130 (Red Hat 10.2.1-11)]