The Fix
pip install redis==7.1.0
Based on closed redis/redis-py issue #1788 · PR/commit linked
@@ -1530,6 +1530,8 @@ def handle_message(self, response, ignore_subscribe_messages=False):
message being returned.
"""
+ if response is None:
+ return None
message_type = str_if_bytes(response[0])
import time
import redis
db = redis.from_url('redis://redis_server', health_check_interval=1.0)
ps = db.pubsub(ignore_subscribe_messages=True)
ps.subscribe('CHANNEL_NOT_EXISTS')
time.sleep(2)
for msg in ps.listen():
print(msg)
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install redis==7.1.0\nWhen NOT to use: Do not use this fix if the application relies on receiving None responses.\n\n
Why This Fix Works in Production
- Trigger: for msg in ps.listen():
- Mechanism: The listen method raises an exception when a health-check response is received as None
- Why the fix works: Fixes an exception raised in the listen method when a health-check response is received. (first fixed release: 7.1.0).
Why This Breaks in Prod
- Shows up under Python 3.9 in real deployments (not just unit tests).
- The listen method raises an exception when a health-check response is received as None
- Surfaces as: Traceback (most recent call last):
Proof / Evidence
- GitHub issue: #1788
- Fix PR: https://github.com/redis/redis-py/pull/1823
- First fixed release: 7.1.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-07
- Confidence: 0.95
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.53
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“will raise exception: parse_response returns None, since the first response is a health-check response. Happens on 3.5.2 and 4.0.2 fix is straight forward:”
Failure Signature (Search String)
- for msg in ps.listen():
Error Message
Stack trace
Error Message
-------------
Traceback (most recent call last):
File "test_listen.py", line 7, in <module>
for msg in ps.listen():
File ".../lib/python3.9/site-packages/redis/client.py", line 3605, in listen
response = self.handle_message(self.parse_response(block=True))
File ".../lib/python3.9/site-packages/redis/client.py", line 3635, in handle_message
message_type = nativestr(response[0])
TypeError: 'NoneType' object is not subscriptable
Minimal Reproduction
import time
import redis
db = redis.from_url('redis://redis_server', health_check_interval=1.0)
ps = db.pubsub(ignore_subscribe_messages=True)
ps.subscribe('CHANNEL_NOT_EXISTS')
time.sleep(2)
for msg in ps.listen():
print(msg)
Environment
- Python: 3.9
What Broke
The application crashes with a TypeError when attempting to listen for messages.
Why It Broke
The listen method raises an exception when a health-check response is received as None
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install redis==7.1.0
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/redis/redis-py/pull/1823
First fixed release: 7.1.0
Last verified: 2026-02-07. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if the application relies on receiving None responses.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Version Compatibility Table
| Version | Status |
|---|---|
| 7.1.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.