Skip to content

Document.__init__() got an unexpected keyword argument 'encoding' #4746

@DeltaFlyerW

Description

@DeltaFlyerW

Description of the bug

doc.subset_fonts(verbose=True, fallback=True)

raise

Traceback (most recent call last):
    doc.subset_fonts(verbose=True, fallback=True)  # build subset fonts to reduce file size
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "venv\Lib\site-packages\pymupdf\__init__.py", line 7710, in subset_fonts
    new_buffer = build_subset(old_buffer, subsets[0], subsets[1])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "venv\Lib\site-packages\pymupdf\__init__.py", line 7562, in build_subset
    with open(f"{tmp_dir}/uncfile.txt", "w", encoding='utf8') as unc_file:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Document.__init__() got an unexpected keyword argument 'encoding'

How to reproduce the bug

This issue seems to be caused by the open attr is override in pymupdf.init.py

PyMuPDF version

1.26.6

Operating system

Windows

Python version

3.11

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions