rename warn_unicode_error to raise_unicode_errors for clarity

additionally change the default accordingly
This commit is contained in:
Michal Stolarczyk
2024-11-13 18:34:35 +01:00
parent 396c5e3669
commit 138ababb3b
2 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -310,7 +310,7 @@ class Page(Container):
try:
extras[k] = v.decode("utf-16")
except UnicodeDecodeError:
if not self.pdf.warn_unicode_error:
if self.pdf.raise_unicode_errors:
raise
warn(f"Could not decode {k} for annotation. {k} will be missing.")
+4 -4
View File
@@ -35,7 +35,7 @@ class PDF(Container):
password: Optional[str] = None,
strict_metadata: bool = False,
unicode_norm: Optional[Literal["NFC", "NFKC", "NFD", "NFKD"]] = None,
warn_unicode_error: bool = False,
raise_unicode_errors: bool = True,
):
self.stream = stream
self.stream_is_external = stream_is_external
@@ -44,7 +44,7 @@ class PDF(Container):
self.laparams = None if laparams is None else LAParams(**laparams)
self.password = password
self.unicode_norm = unicode_norm
self.warn_unicode_error = warn_unicode_error
self.raise_unicode_errors = raise_unicode_errors
self.doc = PDFDocument(PDFParser(stream), password=password or "")
self.rsrcmgr = PDFResourceManager()
@@ -78,7 +78,7 @@ class PDF(Container):
repair: bool = False,
gs_path: Optional[Union[str, pathlib.Path]] = None,
repair_setting: T_repair_setting = "default",
warn_unicode_error: bool = False,
raise_unicode_errors: bool = True,
) -> "PDF":
stream: Union[BufferedReader, BytesIO]
@@ -110,7 +110,7 @@ class PDF(Container):
strict_metadata=strict_metadata,
unicode_norm=unicode_norm,
stream_is_external=stream_is_external,
warn_unicode_error=warn_unicode_error,
raise_unicode_errors=raise_unicode_errors,
)
except PSException: