[issue7413] datetime.datetime.isoformat truncation problem

2009-11-30 Thread Jean-Paul Calderone

New submission from Jean-Paul Calderone :

Passing NUL as the separator to isoformat drops the time part of the
result entirely:

>>> import datetime
>>> datetime.datetime.today().isoformat()
'2009-11-30T20:57:37.918750'
>>> datetime.datetime.today().isoformat('x')
'2009-11-30x20:57:39.902573'
>>> datetime.datetime.today().isoformat('\0')
'2009-11-30'
>>>

--
messages: 95845
nosy: exarkun
severity: normal
status: open
title: datetime.datetime.isoformat truncation problem

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7413] datetime.datetime.isoformat truncation problem

2009-12-01 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc  added the comment:

Here is a test + fix.

--
assignee:  -> amaury.forgeotdarc
keywords: +patch
nosy: +amaury.forgeotdarc
Added file: http://bugs.python.org/file15424/isoformat.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7413] datetime.datetime.isoformat truncation problem

2009-12-01 Thread Eric Smith

Eric Smith  added the comment:

The patch looks okay to me, and works on 2.7. Although it's slightly out
of date with respect to line numbers, it still applies cleanly.

My trivial suggestions are that I'd replace:
x += PyOS_snprintf(buffer + 8, bufflen - 8, ".%06d", us);
with
x += PyOS_snprintf(buffer + x, bufflen - x, ".%06d", us);
in the extremely unlikely event that the time format string ever
changes. I'd probably also throw in an assert(bufflen >= x).

But these 2 points are nits.

--
assignee: amaury.forgeotdarc -> 
components: +Extension Modules
nosy: +eric.smith
priority:  -> normal
stage:  -> patch review
type:  -> behavior
versions: +Python 2.6, Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7413] datetime.datetime.isoformat truncation problem

2009-12-01 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc  added the comment:

Here is a new patch against a fresh trunk, and with the suggested changes: 
they indeed make the code more consistent with other parts.

--
keywords: +needs review
Added file: http://bugs.python.org/file15433/isoformat-2.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7413] datetime.datetime.isoformat truncation problem

2009-12-01 Thread Eric Smith

Eric Smith  added the comment:

I think you need to put an assert before the line with bufflen-x, since
that's the calculation you're trying to ensure doesn't underflow. And I
guess that technically you should inspect the result of PyOS_snprintf
for an error, but given that we know the buffer sizes it's not so important.

Other than that, looks good. Sorry for the piecemeal patch review.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7413] datetime.datetime.isoformat truncation problem

2009-12-29 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc  added the comment:

Fixed with r77122 (trunk) and r77125 (release26-maint).

py3k uses PyUnicode_FromFormat directly and does not have this problem.
I merged the test there nonetheless.

--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com