Repository: redis/redis-py

Issue:
slowlog_get() return value count less than Redis Doc mentioned and redis-cli returned.
Thanks for wanting to report an issue you've found in redis-py. Please delete this text and fill in the template below.  
It is of course not always possible to reduce your code to a small test case, but it's highly appreciated to have as much data as possible. Thank you!

**Version**: What redis-py and what redis version is the issue happening on?
```
redis-py version: 4.5.3 (and 4.5.1 before I upgrade version that try to solve the problem)
redis version: Redis server v=7.0.8 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=12b7d21b977d6ccd
```

**Platform**: What platform / version? (For example Python 3.5.1 on Windows 7 / Ubuntu 15.10 / Azure)
```
Platform: Python 3.8.10 on Ubuntu 20.04-05 TLS
```

**Description**: Description of your issue, stack traces from errors and code that reproduces the issue
As Redis doc mentioned, 'slowlog get' command will return 6 values for each item:
```
Each entry from the slow log is comprised of the following six values:

1. A unique progressive identifier for every slow log entry.
2. The unix timestamp at which the logged command was processed.
3. The amount of time needed for its execution, in microseconds.
4. The array composing the arguments of the command.
5. Client IP address and port.
6. Client name if set via the [CLIENT SETNAME](https://redis.io/commands/client-setname) command.

Doc URL: https://redis.io/commands/slowlog-get/
```
Here is my redis-cli output sample:
```
1) 1) (integer) 19
   2) (integer) 1680064492
   3) (integer) 10187
   4) 1) "LRANGE"
      2) "mylist:{8M}}"
      3) "0"
      4) "599"
   5) "192.168.8.1:48132"
   6) ""
```
And this is redis-py output sample:
```
[{'id': 673, 'start_time': 1680018547, 'duration': 17716, 'command': b'CLUSTER NODES'}]
```

I have try both execute_command() and slowlog_get() to get result, but no luck.
My code snippet:

```
    def get_slowlog(self, num=None):
        redis_command='SLOWLOG GET'
        try:
            # result = self.r.execute_command(redis_command)
            if num:
                result = self.r.slowlog_get(num=num)
            else:
                result = self.r.slowlog_get()
```
Remark: where 'r' in the code is Redis client:
```
                self.r = Redis(
                    host=host, 
                    port=port, 
                    db=0, 
                    password=self.PASSWORD, 
                    retry=self.RETRY, 
                    # retry_on_error=self.RETRY_ON_ERROR, 
                    socket_timeout=60, 
                    socket_connect_timeout=10
                    )
```



Discussion:
[This](https://github.com/redis/redis-py/blob/master/redis/client.py#L413) is where the response is parsed and needs to be updated to capture the missing fields.

Resolving patch:
diff --git a/redis/client.py b/redis/client.py
--- a/redis/client.py
+++ b/redis/client.py
@@ -420,9 +420,13 @@ def parse_item(item):
         # an O(N) complexity) instead of the command.
         if isinstance(item[3], list):
             result["command"] = space.join(item[3])
+            result["client_address"] = item[4]
+            result["client_name"] = item[5]
         else:
             result["complexity"] = item[3]
             result["command"] = space.join(item[4])
+            result["client_address"] = item[5]
+            result["client_name"] = item[6]
         return result
 
     return [parse_item(item) for item in response]


Test patch:
diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -861,6 +861,8 @@ def test_slowlog_get(self, r, slowlog):
         # make sure other attributes are typed correctly
         assert isinstance(slowlog[0]["start_time"], int)
         assert isinstance(slowlog[0]["duration"], int)
+        assert isinstance(slowlog[0]["client_address"], bytes)
+        assert isinstance(slowlog[0]["client_name"], bytes)
 
         # Mock result if we didn't get slowlog complexity info.
         if "complexity" not in slowlog[0]: