You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior
Expected the partial function to just work.
Screenshots
N/A
Specifics (please complete the following information):
Python Version: 3.13
Reflex Version: 0.6.7
OS: Ubuntu 24.04
Browser (Optional): Chrome
Additional context
In method _render of class Foreach in file foreach.py the props["index_var_name"] can be derived from a hash of the render function's byte code. However, functools.partial() functions do not have bytecode.
Suggested fix
The following code fixes the issue. Since the bytecode will be the same for all partial functions derived from the same base function, the 'frozen' parameters are made part of the hash by using the repr.
...
code_hash= (
hash(
getattr(self.render_fn, "__code__", None) or# Fall back to the repr of the function if the code object is not available.# This will handle functools.partial() functions nicely, including the fixed paramater values.repr(self.render_fn)
)
.to_bytes(
length=8,
byteorder="big",
signed=True,
)
.hex()
)
...
The text was updated successfully, but these errors were encountered:
Describe the bug
rx.foreach()
crashes on hashing the render function's code when the render function is afunctools.partial
function.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Expected the partial function to just work.
Screenshots
N/A
Specifics (please complete the following information):
Additional context
In method
_render
of classForeach
in fileforeach.py
theprops["index_var_name"]
can be derived from a hash of the render function's byte code. However,functools.partial()
functions do not have bytecode.Suggested fix
The following code fixes the issue. Since the bytecode will be the same for all partial functions derived from the same base function, the 'frozen' parameters are made part of the hash by using the repr.
The text was updated successfully, but these errors were encountered: