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.

classification
Title: datetime's strftime limits strings to 127 chars
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith
Priority: normal Keywords:

Created on 2006-09-12 10:56 by eric.smith, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (1)
msg29802 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2006-09-12 10:56
[I'm putting this in category Python Library, because I
assume Extensions Modules is for problems in the
Extensions Module plumbing.]


datetime.date and datetime.time's strftime() methods
call wrap_strftime(), which limits the length of the
format string to 127 chars before calling time.strftime().

This can be seen in the examples below.  Note that in
the third example, time.strftime() does not have a
problem with a 128 character format string.


>>> import datetime
>>> datetime.date.today().strftime('x'*128)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
MemoryError


>>> import datetime
>>> datetime.date.today().strftime('x'*256)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: Objects/stringobject.c:4077: bad argument
to internal function


>>> import time
>>> time.strftime('x'*128)
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'


Reproduced on 2.5c1 Linux, 2.4.3 Linux, and 2.3.3 Windows.
History
Date User Action Args
2022-04-11 14:56:20adminsetgithub: 43964
2006-09-12 10:56:44eric.smithcreate