You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.2 KiB
37 lines
1.2 KiB
2 weeks ago
|
From 822a00d2001fa4de06ca854c3047b8687d6c1a32 Mon Sep 17 00:00:00 2001
|
||
|
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
|
||
|
Date: Wed, 29 Nov 2023 08:14:32 -0500
|
||
|
Subject: [PATCH] Handle importlib.resources.path removal in Python 3.13
|
||
|
|
||
|
---
|
||
|
src/cffsubr/__init__.py | 15 ++++++++++++---
|
||
|
1 file changed, 12 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/src/cffsubr/__init__.py b/src/cffsubr/__init__.py
|
||
|
index 4428dcd..1d4eef2 100644
|
||
|
--- a/src/cffsubr/__init__.py
|
||
|
+++ b/src/cffsubr/__init__.py
|
||
|
@@ -8,10 +8,19 @@
|
||
|
import sys
|
||
|
|
||
|
try:
|
||
|
- from importlib.resources import path
|
||
|
+ # Python >= 3.9
|
||
|
+ from importlib.resources import as_file, files
|
||
|
except ImportError:
|
||
|
- # use backport for python < 3.7
|
||
|
- from importlib_resources import path
|
||
|
+ try:
|
||
|
+ # python >= 3.7, deprecated in python 3.11, removed in 3.13
|
||
|
+ from importlib.resources import path
|
||
|
+ except ImportError:
|
||
|
+ # use backport for python < 3.7
|
||
|
+ from importlib_resources import path
|
||
|
+else:
|
||
|
+ # https://docs.python.org/3.11/library/importlib.resources.html#importlib.resources.as_file
|
||
|
+ def path(package, resource):
|
||
|
+ return as_file(files(package).joinpath(resource))
|
||
|
|
||
|
from fontTools import ttLib
|
||
|
|