Package: python3-fakeredis
Version: 2.26.1-1
Severity: important

Dear maintainer,

While working on mentors.debian.net, we started to have CI failure
following the new version of fakeredis 2.26 [1].

It appears that the new version try to import lua51 from lupa, which is
not available in Debian, presumably because the embedded version of lua
is removed from lupa source.

This snippet below can be used to reproduce the bug:

```py
#!/usr/bin/python3

from django.core.cache import cache
from django.conf import settings
from fakeredis import FakeConnection


SETTINGS = {
    "CACHES": {
        "default": {
            "BACKEND": "django_redis.cache.RedisCache",
            "LOCATION": "redis://127.0.0.1:6379/1",
            "OPTIONS": {
                "CLIENT_CLASS": "django_redis.client.DefaultClient",
                "CONNECTION_POOL_KWARGS": {"connection_class": FakeConnection},
            }
        }
    },
}

settings.configure(**SETTINGS)

with cache.lock("key"):
    print("locked")
```

With the following packages installed, this should work but it produce
the same stacktrace as on mentors' CI :

- python3-django-redis
- python3-fakeredis
- python3-lupa

Note that python3-lupa is not pulled by fakeredis and I think it should
since it's required to use the locking feature and more broadly, any
redis lua script dependent feature. Maybe as a Recommends or Suggests?

I'm not sure how to solve that, as in if it's a lupa issue and they
should add the lua51 module alias to lua, or if this should be fixed in
fakeredis.

Anyhow, an simple one liner fix would be:

```diff
diff --git a/fakeredis/commands_mixins/scripting_mixin.py 
b/fakeredis/commands_mixins/scripting_mixin.py
index a0bd66d..c89690f 100644
--- a/fakeredis/commands_mixins/scripting_mixin.py
+++ b/fakeredis/commands_mixins/scripting_mixin.py
@@ -22 +22 @@ __LUA_RUNTIMES_MAP = {
-    "5.1": "lupa.lua51",
+    "5.1": "lupa.lua",
```

Best,

[1]: 
https://salsa.debian.org/mentors.debian.net-team/debexpo/-/jobs/7618262#L2642

-- 
Baptiste Beauplat

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to