We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fc6748d commit 26bca9cCopy full SHA for 26bca9c
1 file changed
bibtexparser/entrypoint.py
@@ -1,3 +1,4 @@
1
+import codecs
2
import warnings
3
from typing import Iterable
4
from typing import List
@@ -125,7 +126,14 @@ def parse_file(
125
126
127
:param encoding: Encoding of the .bib file. Default encoding is ``"UTF-8"``.
128
:return: Library: Parsed BibTeX library
129
+ :raises LookupError: If the specified encoding is not recognized.
130
"""
131
+ # Validate encoding before opening file to provide clearer error message
132
+ try:
133
+ codecs.lookup(encoding)
134
+ except LookupError:
135
+ raise LookupError(f"Unknown encoding: {encoding!r}")
136
+
137
with open(path, encoding=encoding) as f:
138
bibtex_str = f.read()
139
return parse_string(
0 commit comments