Skip to content

Commit

Permalink
Fix repair=True proc args (stderr being captured)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsvine committed Jun 7, 2024
1 parent 2e9819c commit 70534a7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pdfplumber/repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def _repair(

repair_args = [
executable,
"-sstdout=%stderr",
"-o",
"-",
"-sDEVICE=pdfwrite",
Expand All @@ -41,14 +42,16 @@ def _repair(
stdin = path_or_fp
repair_args += ["-"]

stdout, stderr = subprocess.Popen(
proc = subprocess.Popen(
repair_args,
stdin=subprocess.PIPE if stdin else None,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
).communicate(stdin.read() if stdin else None)
)

stdout, stderr = proc.communicate(stdin.read() if stdin else None)

if len(stderr):
if proc.returncode:
raise Exception(f"{stderr.decode('utf-8')}")

return BytesIO(stdout)
Expand Down

0 comments on commit 70534a7

Please sign in to comment.