Skip to content

Commit

Permalink
Don’t use deprecated "read_bytes" function when "files" is available
Browse files Browse the repository at this point in the history
Related to #1753.
  • Loading branch information
liZe committed Oct 26, 2022
1 parent f5373c9 commit 66e1656
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion weasyprint/pdf/pdfa.py
@@ -1,7 +1,16 @@
"""PDF/A generation."""

try:
# Available in Python 3.9+
from importlib.resources import files
except ImportError:
# Deprecated in Python 3.11+
from importlib.resources import read_binary
else:
def read_binary(package, resource):
return (files(package) / resource).read_bytes()

from functools import partial
from importlib.resources import read_binary

import pydyf

Expand Down

0 comments on commit 66e1656

Please sign in to comment.