pymupdf / PyMuPDF

PyMuPDF is a high performance Python library for data extraction, analysis, conversion & manipulation of PDF (and other) documents.

Home Page:https://pymupdf.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`PyMuPDF==1.24.1`: AttributeError: property 'metadata' of 'Document' object has no setter

ucomru opened this issue · comments

Description of the bug

OS: Mac OS 14.4.1 (23E224) (M1)
Python 3.12.2

I'm getting an error with PyMuPDF==1.24.1:

def my_pdf(file: Path):
    doc = Document(file.with_suffix(".pdf"))
    doc.metadata = {}
    . . .
    . . .
    doc.metadata = {}
    ^^^^^^^^^^^^
AttributeError: property 'metadata' of 'Document' object has no setter

Before updating this code have worked correct.
When I'm reinstalling PyMuPDF to the version 1.24, there are no errors.

How to reproduce the bug

$ python
Python 3.12.2 (main, Feb  6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from fitz import Document, version
>>> version
('1.24.1', '1.24.1', '20240402000001')
>>> doc = Document('9b9d04.pdf')
>>> doc.metadata
{'format': 'PDF 1.3', 'title': '', 'author': '', 'subject': '', 'keywords': '', 'creator': '', 'producer': 'macOS Версия 14.4.1 (Выпуск 23E224) Quartz PDFContext', 'creationDate': "D:20240406170142Z00'00'", 'modDate': "D:20240406170142Z00'00'", 'trapped': '', 'encryption': None}
>>> doc.metadata = {}
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: property 'metadata' of 'Document' object has no setter
>>> ^D

$ pip install PyMuPDF==1.24.0
Collecting PyMuPDF==1.24.0
  Using cached PyMuPDF-1.24.0-cp312-none-macosx_11_0_arm64.whl.metadata (3.4 kB)
Collecting PyMuPDFb==1.24.0 (from PyMuPDF==1.24.0)
  Using cached PyMuPDFb-1.24.0-py3-none-macosx_11_0_arm64.whl.metadata (1.4 kB)
Using cached PyMuPDF-1.24.0-cp312-none-macosx_11_0_arm64.whl (3.3 MB)
Using cached PyMuPDFb-1.24.0-py3-none-macosx_11_0_arm64.whl (29.5 MB)
Installing collected packages: PyMuPDFb, PyMuPDF
  Attempting uninstall: PyMuPDFb
    Found existing installation: PyMuPDFb 1.24.1
    Uninstalling PyMuPDFb-1.24.1:
      Successfully uninstalled PyMuPDFb-1.24.1
  Attempting uninstall: PyMuPDF
    Found existing installation: PyMuPDF 1.24.1
    Uninstalling PyMuPDF-1.24.1:
      Successfully uninstalled PyMuPDF-1.24.1
Successfully installed PyMuPDF-1.24.0 PyMuPDFb-1.24.0

$ python
Python 3.12.2 (main, Feb  6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from fitz import Document, version
>>> version
('1.24.0', '1.24.0', '20240321000001')
>>> doc = Document('9b9d04.pdf')
>>> doc.metadata
{'format': 'PDF 1.3', 'title': '', 'author': '', 'subject': '', 'keywords': '', 'creator': '', 'producer': 'macOS Версия 14.4.1 (Выпуск 23E224) Quartz PDFContext', 'creationDate': "D:20240406170142Z00'00'", 'modDate': "D:20240406170142Z00'00'", 'trapped': '', 'encryption': None}
>>> doc.metadata = {}
>>> doc.metadata
{}
>>> ^D

PyMuPDF version

1.24.1

Operating system

MacOS

Python version

3.12

Thanks for reporting this. I have a fix in my tree.

Fixed in 1.24.2.