Cannot use datetimes before UNIX epoch on Windows
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 42/100
Hướng nghiên cứu
Bắt đầu với dòng được liên kết trong py-pgproto's codecs/datetime.pyx và so sánh hành vi của dòng này với issue CPython Windows được tham chiếu. Tái hiện việc bind datetime.datetime(1969, 12, 31) thông qua executemany() trên Windows. Hoàn tất khi các datetimes trước UNIX epoch không còn gây ra OSError trong quá trình mã hóa.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
- asyncpg version: 0.29.0
- PostgreSQL version: 15.5
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: Local PostgreSQL install - Python version: 3.10.1
- Platform: Windows
- Do you use pgbouncer?: No
- Did you install asyncpg with pip?: Yes
- If you built asyncpg locally, which version of Cython did you use?: N/A
- Can the issue be reproduced under both asyncio and
uvloop?: N/A
If I have this query:
INSERT INTO process.start_and_end (user_id, process_id, start_dt, end_dt) VALUES ($1, $2, $3, $4);
and in Python I do:
await conn.executemany(query, [(1325, 1001, datetime.datetime(1969, 12, 31, 0, 0), None)])
this line throws the following exception:
Traceback (most recent call last):
File "asyncpg\protocol\prepared_stmt.pyx", line 175, in asyncpg.protocol.protocol.PreparedStatementState._encode_bind_msg
File "asyncpg\protocol\codecs/base.pyx", line 227, in asyncpg.protocol.protocol.Codec.encode
File "asyncpg\protocol\codecs/base.pyx", line 129, in asyncpg.protocol.protocol.Codec.encode_scalar
File "asyncpg\pgproto\./codecs/datetime.pyx", line 222, in asyncpg.pgproto.pgproto.timestamptz_encode
OSError: [Errno 22] Invalid argument
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "main.py", line 919, in <module>
loop.run_until_complete(async_main())
File "C:\Scoop\apps\python\current\lib\asyncio\base_events.py", line 641, in run_until_complete
return future.result()
[...]
File "main.py", line 401, in __insert_tape
await conn.executemany(query, [(1325, 1001, datetime.datetime(1969, 12, 31, 0, 0), None)])
File ".venv\lib\site-packages\asyncpg\connection.py", line 391, in executemany
return await self._executemany(command, args, timeout)
File ".venv\lib\site-packages\asyncpg\connection.py", line 1911, in _executemany
result, _ = await self._do_execute(query, executor, timeout)
File ".venv\lib\site-packages\asyncpg\connection.py", line 1945, in _do_execute
result = await executor(stmt, None)
File "asyncpg\protocol\protocol.pyx", line 267, in bind_execute_many
File "asyncpg\protocol\coreproto.pyx", line 974, in asyncpg.protocol.protocol.CoreProtocol._bind_execute_many_more
File "asyncpg\protocol\protocol.pyx", line 230, in genexpr
File "asyncpg\protocol\prepared_stmt.pyx", line 204, in asyncpg.protocol.protocol.PreparedStatementState._encode_bind_msg
asyncpg.exceptions.DataError: invalid input for query argument $3 in element #0 of executemany() sequence: datetime.datetime(1969, 12, 31, 0, 0) ([Errno 22] Invalid argument)
Digging into it a bit more, I found that the culprit is this line in the codec for datetime objects, which is related to this old CPython issue on Windows: https://github.com/python/cpython/issues/80940.
The fix looks quite simple, but unfortunately I do not have the time to work on that, so I'm opening an issue instead of a PR.
- Ngôn ngữ chính
- Python
- Star
- 8.1k
- Fork
- 469
- Merge trung bình
- 4 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 14
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của MagicStack/asyncpg
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
MagicStack/asyncpg#1357 · 1 bình luận · 1 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
MagicStack/asyncpg#1342 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 56/100
MagicStack/asyncpg#1340 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 28/100
MagicStack/asyncpg#1337 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
MagicStack/asyncpg#1330 · 1 bình luận ·
Tất cả issue của MagicStack/asyncpg
Issue tương tự
-
[Bug] reef-hermes tells me to resume with hermes --resume, which does not work from my shell Đang mởarea: harness bug status: needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Human-Agent-Society/reef#625 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
learningequality/kolibri#15351 · 2 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Name consistency Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
eellak/triplestore#65 · 1 bình luận ·