Skip to content

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

Closed

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

Activity

  1. DeltaFlyerW commented on Oct 15, 2025

    @DeltaFlyerW
    Author

    Temporory fix:

    pymupdf.open = open
    
  2. julian-smith-artifex-com commented on Oct 15, 2025

    @julian-smith-artifex-com
    Collaborator

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

    We will close this issue when the fix is released.

  3. julian-smith-artifex-com commented on Nov 5, 2025

    @julian-smith-artifex-com
    Collaborator

    Fixed in pymupdf-1.26.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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