Skip to content

Commit 4e27b8c

Browse files
committed
specify encoding when doing Path.read_text
1 parent 0b3a0f1 commit 4e27b8c

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/decaylanguage/decay/decay.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ def from_string(
899899
``"D*+ -> (D0 -> K+ pi-) pi+"``.
900900
grammar_file : str or Path, optional
901901
Path to a custom Lark grammar file for descriptor parsing.
902-
If not provided, the default grammar is used.
902+
The default grammar file is ``decaylanguage/data/descriptor.lark``.
903903
904904
Returns
905905
-------
@@ -922,12 +922,14 @@ def from_string(
922922
# Load the grammar
923923
if grammar_file is None:
924924
# Use the default descriptor grammar from the data package
925-
grammar = data.basepath.joinpath("descriptor.lark").read_text()
925+
grammar = data.basepath.joinpath("descriptor.lark").read_text(
926+
encoding="utf-8"
927+
)
926928
else:
927929
# Use custom grammar file
928930
if isinstance(grammar_file, str):
929931
grammar_file = Path(grammar_file)
930-
grammar = grammar_file.read_text()
932+
grammar = grammar_file.read_text(encoding="utf-8")
931933

932934
# Parse the descriptor
933935
try:

0 commit comments

Comments
 (0)