fix: fix liquid range literal issue by hacking it

use hacking way to resolve the issue that liquid range literal has hard +/- 1024 boundary which blocks the ability of rendering RC template
This commit is contained in:
2026-09-22 11:43:29 +08:00
parent 5491092037
commit 3069ad4e26
4 changed files with 30 additions and 2 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ dependencies = [
"polib>=1.2.0",
"pycountry>=26.2.16",
"pydantic>=2.11.7",
"python-liquid>=2.2.0",
"python-liquid==2.3.1",
]
[project.urls]
+3
View File
@@ -1,10 +1,13 @@
import logging
import sys
from argparse import ArgumentParser
from . import hack
from .cmds import run, register, parse
def main() -> None:
hack.relax_liquid_range_literal_boundary()
logging.basicConfig(level=logging.INFO, format="[%(levelname)s] %(message)s")
parser = ArgumentParser(
+25
View File
@@ -0,0 +1,25 @@
"""Runtime hacks over third-party dependencies.
Each hack should be applied at the very start of ``main`` and
documents why it exists and when it can be dropped.
"""
import liquid.builtin.expressions.primitive as _primitive
# TODO:
# When python-liquid relax the boundary of range literal,
# remove this hack.
def relax_liquid_range_literal_boundary() -> None:
"""Relax python-liquid's range literal bounds.
python-liquid (pinned to 2.3.1) clamps the endpoints of range literals
such as ``(1000..1028)`` to plus/minus 1024, silently truncating the
loop to 1000..1023. Windows RC string identifiers legitimately go up
to 65535, so templates iterating numeric ID ranges lose entries
without any error. Relax the bounds the library itself defines
to a more large boundary (as its commented)
"""
_primitive.MAX_RANGE = (2**53) - 1
_primitive.MIN_RANGE = -(2**53) + 1
Generated
+1 -1
View File
@@ -108,7 +108,7 @@ requires-dist = [
{ name = "polib", specifier = ">=1.2.0" },
{ name = "pycountry", specifier = ">=26.2.16" },
{ name = "pydantic", specifier = ">=2.11.7" },
{ name = "python-liquid", specifier = ">=2.2.0" },
{ name = "python-liquid", specifier = "==2.3.1" },
]
[[package]]