Skip to content

NameError: name 'hiredis' is not defined due to hiredis version being lower than 3 #3393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
helissonomc opened this issue Sep 30, 2024 · 2 comments

Comments

@helissonomc
Copy link

helissonomc commented Sep 30, 2024

Version: 5.1.0

Platform: Python 3.12 / ubuntu 22.04

Description: I started to get the error
output.append(hiredis.pack_command(args)) NameError: name 'hiredis' is not defined

I Believe the reason for this issue is because of the code inside redis/utils.py

try:
    import hiredis  # noqa

    # Only support Hiredis >= 3.0:
    HIREDIS_AVAILABLE = int(hiredis.__version__.split(".")[0]) >= 3
    HIREDIS_PACK_AVAILABLE = hasattr(hiredis, "pack_command")
except ImportError:
    HIREDIS_AVAILABLE = False
    HIREDIS_PACK_AVAILABLE = False

If the hiredis version is lower than 3 (which mine is) the HIREDIS_AVAILABLE is going to be false, therefore it will keep giving error inside the redis/connection.py file, because the import hiredis will not be executed, but the code still relies on this import.

I believe there should be a better error handling here warning people about this breaking change.

@helissonomc helissonomc changed the title NameError: name 'hiredis' is not defined NameError: name 'hiredis' is not defined due to hiredis version being lower than 3 Sep 30, 2024
@Endzel
Copy link

Endzel commented Oct 1, 2024

Upvoting this, disrupting our builds since yesterday evening.

@helissonomc
Copy link
Author

@Endzel #3392 check this out, they will fix the bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants