Skip to content

Commit

Permalink
Don’t use deprecated "read_text" function when "files" is available
Browse files Browse the repository at this point in the history
Fix #1753.
  • Loading branch information
liZe committed Oct 26, 2022
1 parent 1a46da3 commit c7d1c52
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion weasyprint/html.py
Expand Up @@ -7,8 +7,17 @@
"""

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

import re
from importlib.resources import read_text

from . import CSS, css
from .css import get_child_text
Expand Down

0 comments on commit c7d1c52

Please sign in to comment.