Skip to content

Commit 59b6d5a

Browse files
authored
Merge pull request #7 from MarcinKonowalczyk/fix/py314-lru-cache-patch
Fix/py314 lru cache patch
2 parents 559045e + 260118b commit 59b6d5a

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

psll/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Macro-driven metalanguage which compiles to Pyramid Scheme.
33
"""
44

5-
__version__ = "0.1.8"
5+
__version__ = "0.1.9"
66

77

88
class PsllSyntaxError(SyntaxError):

psll/build.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,33 @@
11
import operator
2+
import sys
23
from functools import lru_cache, reduce, singledispatch
34
from typing import Union, overload
45

56
from .ascii_trees import AbstractTree, Pyramid
67

8+
if sys.version_info >= (3, 14):
9+
# Fix for lru_cache in Python 3.14+
10+
# See: https://github.com/python/cpython/issues/132064
11+
from functools import wraps
12+
from typing import Any, Callable, TypeVar
13+
14+
_old_lru_cache = lru_cache
15+
16+
_T = TypeVar("_T", bound=Callable)
17+
18+
def wrapped_lru_cache(*lar: Any, **lkw: Any) -> Callable[[_T], _T]:
19+
def decorator(func: _T) -> _T:
20+
@wraps(func)
21+
def wrapper(*ar: Any, **kw: Any) -> Any:
22+
return _old_lru_cache(*lar, **lkw)(func)(*ar, **kw)
23+
24+
return wrapper # type: ignore
25+
26+
return decorator
27+
28+
lru_cache = wrapped_lru_cache # type: ignore
29+
30+
731
# ===================================================================================
832
#
933
# ##### ## ## #### ## #####

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
min_version = 4.0
33
env_list =
44
; py314t
5-
; py314 # FIXME: BROKEN!!
5+
py314
66
; py313t
77
py313
88
py312

0 commit comments

Comments
 (0)