[New-bugs-announce] [issue29140] time_hash() reads the wrong bytes to get microseconds

STINNER Victor report at bugs.python.org
Tue Jan 3 08:57:09 EST 2017


New submission from STINNER Victor:

When the time is folded, time_hash() uses DATE_xxx() macros, instead of TIME_xxx() macros, and so reads microseconds from the wrong bytes.

Bug introduced by the implementation of the PEP 495 (Local Time Disambiguation).

#define PyDateTime_DATE_GET_MICROSECOND(o)              \
    ((((PyDateTime_DateTime*)o)->data[7] << 16) |       \
     (((PyDateTime_DateTime*)o)->data[8] << 8)  |       \
      ((PyDateTime_DateTime*)o)->data[9])

#define PyDateTime_TIME_GET_MICROSECOND(o)              \
    ((((PyDateTime_Time*)o)->data[3] << 16) |           \
     (((PyDateTime_Time*)o)->data[4] << 8)  |           \
      ((PyDateTime_Time*)o)->data[5])

Attached patch fixes time_hash().

I guess that it's a dummy copy-paste issue.

----------
components: Library (Lib)
files: time_hash.patch
keywords: patch
messages: 284561
nosy: belopolsky, haypo
priority: normal
severity: normal
status: open
title: time_hash() reads the wrong bytes to get microseconds
versions: Python 3.6, Python 3.7
Added file: http://bugs.python.org/file46123/time_hash.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29140>
_______________________________________


More information about the New-bugs-announce mailing list