Skip to content

Commit 7f5c92b

Browse files
committed
Migrated from deprecated open_text method to modern importlib_resources.files API
1 parent 491a765 commit 7f5c92b

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/tokenizer/abbrev.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
from threading import Lock
3939
from collections import defaultdict, OrderedDict
40-
from importlib.resources import open_text
40+
import importlib.resources as importlib_resources
4141

4242
from .definitions import BIN_Tuple
4343

@@ -311,10 +311,11 @@ def initialize():
311311
return
312312

313313
section = None
314-
config = open_text(
315-
package="tokenizer", resource="Abbrev.conf", encoding="utf-8"
316-
) # TODO: Deprecated in Python 3.13
317-
for s in config:
314+
315+
p = importlib_resources.files("tokenizer").joinpath("Abbrev.conf")
316+
config = p.read_text(encoding="utf-8")
317+
318+
for s in config.split("\n"):
318319
# Ignore comments
319320
ix = s.find("#")
320321
if ix >= 0:

src/tokenizer/tokenizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,7 @@ def parse_mixed(
19231923

19241924
# Check for currency abbreviations immediately followed by a number
19251925
if len(rt.txt) > 3 and rt.txt[0:3] in CURRENCY_ABBREV and rt.txt[3].isdigit():
1926-
# XXX: This feels a little hacky
1926+
# TODO: This feels a little hacky
19271927
temp_tok = Tok(TOK.RAW, rt.txt[3:], None)
19281928
digit_tok, _ = parse_digits(temp_tok, convert_numbers)
19291929
if digit_tok.kind == TOK.NUMBER:

0 commit comments

Comments
 (0)