mirror of
https://github.com/jsvine/pdfplumber.git
synced 2026-08-29 08:34:23 +08:00
rename warn_unicode_error to raise_unicode_errors for clarity
additionally change the default accordingly
This commit is contained in:
+1
-1
@@ -310,7 +310,7 @@ class Page(Container):
|
|||||||
try:
|
try:
|
||||||
extras[k] = v.decode("utf-16")
|
extras[k] = v.decode("utf-16")
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
if not self.pdf.warn_unicode_error:
|
if self.pdf.raise_unicode_errors:
|
||||||
raise
|
raise
|
||||||
warn(f"Could not decode {k} for annotation. {k} will be missing.")
|
warn(f"Could not decode {k} for annotation. {k} will be missing.")
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -35,7 +35,7 @@ class PDF(Container):
|
|||||||
password: Optional[str] = None,
|
password: Optional[str] = None,
|
||||||
strict_metadata: bool = False,
|
strict_metadata: bool = False,
|
||||||
unicode_norm: Optional[Literal["NFC", "NFKC", "NFD", "NFKD"]] = None,
|
unicode_norm: Optional[Literal["NFC", "NFKC", "NFD", "NFKD"]] = None,
|
||||||
warn_unicode_error: bool = False,
|
raise_unicode_errors: bool = True,
|
||||||
):
|
):
|
||||||
self.stream = stream
|
self.stream = stream
|
||||||
self.stream_is_external = stream_is_external
|
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.laparams = None if laparams is None else LAParams(**laparams)
|
||||||
self.password = password
|
self.password = password
|
||||||
self.unicode_norm = unicode_norm
|
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.doc = PDFDocument(PDFParser(stream), password=password or "")
|
||||||
self.rsrcmgr = PDFResourceManager()
|
self.rsrcmgr = PDFResourceManager()
|
||||||
@@ -78,7 +78,7 @@ class PDF(Container):
|
|||||||
repair: bool = False,
|
repair: bool = False,
|
||||||
gs_path: Optional[Union[str, pathlib.Path]] = None,
|
gs_path: Optional[Union[str, pathlib.Path]] = None,
|
||||||
repair_setting: T_repair_setting = "default",
|
repair_setting: T_repair_setting = "default",
|
||||||
warn_unicode_error: bool = False,
|
raise_unicode_errors: bool = True,
|
||||||
) -> "PDF":
|
) -> "PDF":
|
||||||
|
|
||||||
stream: Union[BufferedReader, BytesIO]
|
stream: Union[BufferedReader, BytesIO]
|
||||||
@@ -110,7 +110,7 @@ class PDF(Container):
|
|||||||
strict_metadata=strict_metadata,
|
strict_metadata=strict_metadata,
|
||||||
unicode_norm=unicode_norm,
|
unicode_norm=unicode_norm,
|
||||||
stream_is_external=stream_is_external,
|
stream_is_external=stream_is_external,
|
||||||
warn_unicode_error=warn_unicode_error,
|
raise_unicode_errors=raise_unicode_errors,
|
||||||
)
|
)
|
||||||
|
|
||||||
except PSException:
|
except PSException:
|
||||||
|
|||||||
Reference in New Issue
Block a user