Skip to content

Commit 66e1656

Browse files
committed
Don’t use deprecated "read_bytes" function when "files" is available
Related to #1753.
1 parent f5373c9 commit 66e1656

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

weasyprint/pdf/pdfa.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
"""PDF/A generation."""
22

3+
try:
4+
# Available in Python 3.9+
5+
from importlib.resources import files
6+
except ImportError:
7+
# Deprecated in Python 3.11+
8+
from importlib.resources import read_binary
9+
else:
10+
def read_binary(package, resource):
11+
return (files(package) / resource).read_bytes()
12+
313
from functools import partial
4-
from importlib.resources import read_binary
514

615
import pydyf
716

0 commit comments

Comments
 (0)