Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bibtexparser/entrypoint.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import codecs
import warnings
from typing import Iterable
from typing import List
Expand Down Expand Up @@ -125,7 +126,13 @@ def parse_file(

:param encoding: Encoding of the .bib file. Default encoding is ``"UTF-8"``.
:return: Library: Parsed BibTeX library
:raises LookupError: If the specified encoding is not recognized.
"""
try:
codecs.lookup(encoding)
except LookupError:
raise LookupError(f"Unknown encoding: {encoding!r}")

with open(path, encoding=encoding) as f:
bibtex_str = f.read()
return parse_string(
Expand Down
Loading