Skip to content

Commit 6ff2749

Browse files
authored
fix: Increase stash key length from 1 to 2
Cross-reference stash keys start with `_` and preserve the rendered identifier length. One-character and two-character identifiers therefore share a keyspace of only 62 keys. Once all keys are present, `_gen_stash_key` retries random choices forever. This happens for example in mkdocstrings when rendering an attribute value that has 62 names in it or more. We increase the minimum key length by 1, to reach a keyspace of 3844, making it very unlikely to hit the limit again. PR-336: #336
1 parent 0fa2d2e commit 6ff2749

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/mkdocstrings_handlers/python/_internal/rendering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class _StashCrossRefFilter:
107107

108108
@staticmethod
109109
def _gen_key(length: int) -> str:
110-
return "_" + "".join(random.choice(string.ascii_letters + string.digits) for _ in range(max(1, length - 1))) # noqa: S311
110+
return "_" + "".join(random.choice(string.ascii_letters + string.digits) for _ in range(max(2, length - 1))) # noqa: S311
111111

112112
def _gen_stash_key(self, length: int) -> str:
113113
key = self._gen_key(length)

0 commit comments

Comments
 (0)