Skip to content

Issue with doc.close() not closing the document in PyMuPDF #3039

Closed
@albeiroep

Description

@albeiroep

Description of the bug

Hello PyMuPDF community,

I am encountering an issue with PyMuPDF where a PDF file, once opened using fitz.open, does not close properly even after calling doc.close(). This is causing my Python script to not terminate as expected.

Steps to Reproduce:

  1. Open a PDF file using PyMuPDF: doc = fitz.open(pdf_path)
  2. Attempt to close the document: doc.close()
  3. Check if the document is closed: print(doc.is_closed)

Expected Behavior:
The doc.is_closed should return True after calling doc.close().

Actual Behavior:
The doc.is_closed returns False, indicating that the document remains open. As a result, my Python script does not terminate properly.

Environment:

  • PyMuPDF version: (1.23.13)
  • Python version: (e.g., Python 3.11)
  • Operating System: (e.g., Lubuntu 23.04)

Additional Information:

  • I am using the latest version of PyMuPDF. I have even tried installing directly from the GitHub repository to ensure I have the most recent updates.
  • I am aware that this issue was addressed in previous versions of PyMuPDF, but it seems to have resurfaced.

Any assistance in resolving this issue would be greatly appreciated. Thank you in advance for your help.

How to reproduce the bug

The bug can be reproduced following the code i have provided in my main message

PyMuPDF version

Built from source

Operating system

Linux

Python version

3.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    fix developedrelease schedule to be determined

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions