Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datetime's strftime limits strings to 127 chars #43962

Closed
ericvsmith opened this issue Sep 12, 2006 · 3 comments
Closed

datetime's strftime limits strings to 127 chars #43962

ericvsmith opened this issue Sep 12, 2006 · 3 comments
Labels
stdlib Python modules in the Lib dir

Comments

@ericvsmith
Copy link
Member

BPO 1556784
Nosy @birkenfeld, @ericvsmith

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2006-09-30.11:18:03.000>
created_at = <Date 2006-09-12.02:43:32.000>
labels = ['library']
title = "datetime's strftime limits strings to 127 chars"
updated_at = <Date 2006-09-30.11:18:03.000>
user = 'https://github.com/ericvsmith'

bugs.python.org fields:

activity = <Date 2006-09-30.11:18:03.000>
actor = 'georg.brandl'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2006-09-12.02:43:32.000>
creator = 'eric.smith'
dependencies = []
files = []
hgrepos = []
issue_num = 1556784
keywords = []
message_count = 3.0
messages = ['29797', '29798', '29799']
nosy_count = 2.0
nosy_names = ['georg.brandl', 'eric.smith']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1556784'
versions = ['Python 2.5']

@ericvsmith
Copy link
Member Author

[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.

@ericvsmith ericvsmith added the stdlib Python modules in the Lib dir label Sep 12, 2006
@ericvsmith ericvsmith added the stdlib Python modules in the Lib dir label Sep 12, 2006
@ericvsmith
Copy link
Member Author

Logged In: YES
user_id=411198

See patch http://python.org/sf/1557390

@birkenfeld
Copy link
Member

Logged In: YES
user_id=849994

Thanks for the report, fixed in rev. 52072, 52073 (2.4),
52074 (2.5).

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

2 participants