NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.85k stars 13.23k forks source link

krop core dumps when attempting to crop a PDF #226012

Open emmanuelrosa opened 1 year ago

emmanuelrosa commented 1 year ago

Describe the bug

When attempting to crop a PDF with krop, it crashes with the message: PyPDF2.errors.DeprecationError: PdfFileReader is deprecated and was removed in PyPDF2 3.0.0. Use PdfReader instead.

Steps To Reproduce

  1. krop --grid=2x1 --go -o output.pdf input.pdf

Screenshots

If applicable, add screenshots to help explain your problem.

WARNING: Something got in our way
The following unexpected error has occured:

PdfFileReader is deprecated and was removed in PyPDF2 3.0.0. Use PdfReader instead.
Traceback (most recent call last):
  File "/nix/store/v2m75p3qaj3lq00chsicqxb8bf88kfn9-krop-0.6.0/lib/python3.10/site-packages/krop/mainwindow.py", line 450, in slotKrop
    raise err
  File "/nix/store/v2m75p3qaj3lq00chsicqxb8bf88kfn9-krop-0.6.0/lib/python3.10/site-packages/krop/mainwindow.py", line 414, in slotKrop
    pdf.loadFromFile(inputFileName)
  File "/nix/store/v2m75p3qaj3lq00chsicqxb8bf88kfn9-krop-0.6.0/lib/python3.10/site-packages/krop/pdfcropper.py", line 45, in loadFromFile
    self.loadFromStream(open(filename, "rb"))
  File "/nix/store/v2m75p3qaj3lq00chsicqxb8bf88kfn9-krop-0.6.0/lib/python3.10/site-packages/krop/pdfcropper.py", line 66, in loadFromStream
    self.reader = PdfFileReader(stream, strict=False)
  File "/nix/store/kz3rjc7dqhj0z2hmap2rx2fdqs5ki8x5-python3.10-PyPDF2-3.0.1/lib/python3.10/site-packages/PyPDF2/_reader.py", line 1974, in __init__
    deprecation_with_replacement("PdfFileReader", "PdfReader", "3.0.0")
  File "/nix/store/kz3rjc7dqhj0z2hmap2rx2fdqs5ki8x5-python3.10-PyPDF2-3.0.1/lib/python3.10/site-packages/PyPDF2/_utils.py", line 369, in deprecation_with_replacement
    deprecation(DEPR_MSG_HAPPENED.format(old_name, removed_in, new_name))
  File "/nix/store/kz3rjc7dqhj0z2hmap2rx2fdqs5ki8x5-python3.10-PyPDF2-3.0.1/lib/python3.10/site-packages/PyPDF2/_utils.py", line 351, in deprecation
    raise DeprecationError(msg)
PyPDF2.errors.DeprecationError: PdfFileReader is deprecated and was removed in PyPDF2 3.0.0. Use PdfReader instead.
Aborted (core dumped)

Expected behavior

I expected the input PDF to be cropped.

Notify maintainers

@leenaars

Metadata

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.2.8, NixOS, 23.05 (Stoat), 23.05.20230328.686ddd4`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.3`
 - nixpkgs: `/nix/store/lspbzb6zy39xa69in03sqqkm1w77bjnb-source`
bquast commented 1 year ago

Have the same issue, anyone have an idea of a workaround on Arch Linux?

bquast commented 1 year ago

I uninstalled pypdf2 v. 3.0.1 and installed pypdf (all smalls) 2.12.1, then it works

jluttine commented 10 months ago

I suppose this is already fixed in krop but they just haven't made a release with the fix yet. See: https://github.com/arminstraub/krop/pull/39

emmanuelrosa commented 3 months ago

@leenaars, since upstream hasn't released an update with the commit which fixes this issue, would you consider updating the Nix package to use a commit as the version, rather than using the "0.6.0" tag?

You can probably use the current master as the commit.