Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Commit fa1e7e7

Browse files
committed
Fix unpacking of negative timestamps from msgpack
1 parent 7b03673 commit fa1e7e7

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

influxdb/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ def _parse_netloc(netloc):
12441244

12451245
def _msgpack_parse_hook(code, data):
12461246
if code == 5:
1247-
(epoch_s, epoch_ns) = struct.unpack(">QI", data)
1247+
(epoch_s, epoch_ns) = struct.unpack(">qi", data)
12481248
timestamp = datetime.datetime.utcfromtimestamp(epoch_s)
12491249
timestamp += datetime.timedelta(microseconds=(epoch_ns / 1000))
12501250
return timestamp.isoformat() + 'Z'

influxdb/tests/client_test.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,8 @@ def test_query_msgpack(self):
575575
example_response = bytes(bytearray.fromhex(
576576
"81a7726573756c74739182ac73746174656d656e745f696400a673657269"
577577
"65739183a46e616d65a161a7636f6c756d6e7392a474696d65a176a67661"
578-
"6c7565739192c70c05000000005d26178a019096c8cb3ff0000000000000"
578+
"6c7565739292c70c05000000005d26178a019096c8cb3ff0000000000000"
579+
"92c70c05fffffffffffee6c0ff439eb2cb4000000000000000"
579580
))
580581

581582
with requests_mock.Mocker() as m:
@@ -590,7 +591,10 @@ def test_query_msgpack(self):
590591

591592
self.assertListEqual(
592593
list(rs.get_points()),
593-
[{'v': 1.0, 'time': '2019-07-10T16:51:22.026253Z'}]
594+
[
595+
{"v": 1.0, "time": "2019-07-10T16:51:22.026253Z"},
596+
{"v": 2.0, "time": "1969-12-31T03:59:59.987654Z"},
597+
],
594598
)
595599

596600
def test_select_into_post(self):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy