Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PI: Don't load entire file into memory when passed file name #2520

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Commits on May 18, 2024

  1. TST: Don't deepcopy PdfReader objects

    This breaks if PdfReader contains any un-pickleable attributes (such as
    file pointers)
    mjsir911 committed May 18, 2024
    Configuration menu
    Copy the full SHA
    8f4ac76 View commit details
    Browse the repository at this point in the history
  2. MAINT: remove deepcopy functionality

    Was only ever being used unintentionally in the tests and doesn't really
    make sense. Use .clone() instead
    mjsir911 committed May 18, 2024
    Configuration menu
    Copy the full SHA
    bea8d90 View commit details
    Browse the repository at this point in the history
  3. TST: Use buffer instead of opening file many times

    See py-pdf#2520, basically this was the last failing (only on windows) test
    because if the pdfreaders are implicitly opening file streams that don't
    get closed until they get garbage collected the .unlinks() create file
    lock errors.
    mjsir911 committed May 18, 2024
    Configuration menu
    Copy the full SHA
    18bd9ec View commit details
    Browse the repository at this point in the history
  4. PI: Don't load entire file into memory when passed file name

    This halves allocated memory when doing a simple
    PdfWriter(clone_from=Β«strΒ»)
    
    I can't just close the self.stream in `__del__` because for some strange
    reason the unit tests mark it as unflagged even after the test block
    ends. Something about `__del__` finalizers being run on a second pass
    while `weakref.finalize()` is run on the first pass.
    mjsir911 committed May 18, 2024
    Configuration menu
    Copy the full SHA
    01ffe8d View commit details
    Browse the repository at this point in the history
  5. STY: fix typo

    mjsir911 committed May 18, 2024
    Configuration menu
    Copy the full SHA
    c8a77aa View commit details
    Browse the repository at this point in the history
  6. MAINT: Allow opening PdfReader as contextmanager

    To mirror PdfWriter, also hints towards file pointer management now that
    we keep files open sometimes.
    mjsir911 committed May 18, 2024
    Configuration menu
    Copy the full SHA
    3578bf7 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    c3fe2e7 View commit details
    Browse the repository at this point in the history