Skip to content

Commit 869b706

Browse files
committed
fix(core): ensure compatibility with Python < 3.12 for Buffer import
Use try/except to import Buffer from collections.abc, falling back to bytes for older Python versions where Buffer is unavailable. This improves backwards compatibility of ohlcv_file.py.
1 parent 06056ff commit 869b706

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/pynecore/core/ohlcv_file.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
import os
2121
import struct
2222
from collections import Counter
23-
from collections.abc import Buffer
23+
try:
24+
from collections.abc import Buffer
25+
except ImportError:
26+
# Python < 3.12 compatibility: Buffer was added in 3.12
27+
Buffer = bytes # type: ignore
2428
from datetime import datetime, time, timedelta, timezone as dt_timezone, UTC
2529
from io import BufferedWriter, BufferedRandom
2630
from math import gcd as math_gcd

0 commit comments

Comments
 (0)