Skip to content

Commit ff68ca5

Browse files
committed
Fix date/datetime negative infinity decoder regression
This was introduced in 678f683. Fixes: #62
1 parent d2be6ec commit ff68ca5

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

asyncpg/protocol/codecs/datetime.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ cdef int32_t pg_date_offset_ord = \
2525

2626
# Binary representations of infinity for datetimes.
2727
cdef int64_t pg_time64_infinity = 0x7fffffffffffffff
28-
cdef int64_t pg_time64_negative_infinity = -1
28+
cdef int64_t pg_time64_negative_infinity = <int64_t>0x8000000000000000
2929
cdef int32_t pg_date_infinity = 0x7fffffff
30-
cdef int32_t pg_date_negative_infinity = -1
30+
cdef int32_t pg_date_negative_infinity = <int32_t>0x80000000
3131

3232
infinity_datetime = datetime.datetime(
3333
datetime.MAXYEAR, 12, 31, 23, 59, 59, 999999)

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
if sys.version_info < (3, 5):
2020
raise RuntimeError('asyncpg requires Python 3.5 or greater')
2121

22-
VERSION = '0.8.3'
22+
VERSION = '0.8.4'
2323
CFLAGS = ['-O2']
2424
LDFLAGS = []
2525

tests/test_codecs.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,17 @@ def _timezone(offset):
156156
datetime.datetime(250, 1, 1, 5, 25, 10),
157157
infinity_datetime,
158158
negative_infinity_datetime,
159+
{'textinput': 'infinity', 'output': infinity_datetime},
160+
{'textinput': '-infinity', 'output': negative_infinity_datetime},
159161
]),
160162
('date', 'date', [
161163
datetime.date(3000, 5, 20),
162164
datetime.date(2000, 1, 1),
163165
datetime.date(500, 1, 1),
164-
datetime.date(1, 1, 1),
165166
infinity_date,
167+
negative_infinity_date,
168+
{'textinput': 'infinity', 'output': infinity_date},
169+
{'textinput': '-infinity', 'output': negative_infinity_date},
166170
]),
167171
('time', 'time', [
168172
datetime.time(12, 15, 20),
@@ -360,15 +364,24 @@ async def test_standard_codecs(self):
360364
"SELECT $1::" + typname
361365
)
362366

367+
textst = await self.con.prepare(
368+
"SELECT $1::text::" + typname
369+
)
370+
363371
for sample in sample_data:
364372
with self.subTest(sample=sample, typname=typname):
373+
stmt = st
365374
if isinstance(sample, dict):
366-
inputval = sample['input']
375+
if 'textinput' in sample:
376+
inputval = sample['textinput']
377+
stmt = textst
378+
else:
379+
inputval = sample['input']
367380
outputval = sample['output']
368381
else:
369382
inputval = outputval = sample
370383

371-
result = await st.fetchval(inputval)
384+
result = await stmt.fetchval(inputval)
372385
err_msg = (
373386
"unexpected result for {} when passing {!r}: "
374387
"received {!r}, expected {!r}".format(

0 commit comments

Comments
 (0)