question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

3.4.0 changed argument positions for constructor

See original GitHub issue

Version: redis-py 3.4.0, redis 4.0.9

Platform: Python 3.6.6, Ubuntu 18.04

Description: Version 3.4.0 added an extra username argument to the redis.Redis constructor, but because it was added near the front of the list, and the arguments are not marked keyword-only, it breaks code that passes arguments to the constructor positionally.

Here’s a (somewhat contrived) example, that works on 3.3.11 but breaks on 3.4.0. This is the cause of jamesls/fakeredis#260.

#!/usr/bin/env python3
import redis

r = redis.Redis('localhost', 6379, 0, None, None, None, None, None, None, None, 'utf-8')
print(r.ping())

On 3.4.0 the ‘utf-8’ gets interpreted as unix_socket_path instead of encoding, leading to

Traceback (most recent call last):
  File "/home/bmerry/work/sdp/env3/lib/python3.6/site-packages/redis/connection.py", line 550, in connect
    sock = self._connect()
  File "/home/bmerry/work/sdp/env3/lib/python3.6/site-packages/redis/connection.py", line 892, in _connect
    sock.connect(self.path)
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./bad2.py", line 5, in <module>
    print(r.ping())
  File "/home/bmerry/work/sdp/env3/lib/python3.6/site-packages/redis/client.py", line 1357, in ping
    return self.execute_command('PING')
  File "/home/bmerry/work/sdp/env3/lib/python3.6/site-packages/redis/client.py", line 881, in execute_command
    conn = self.connection or pool.get_connection(command_name, **options)
  File "/home/bmerry/work/sdp/env3/lib/python3.6/site-packages/redis/connection.py", line 1178, in get_connection
    connection.connect()
  File "/home/bmerry/work/sdp/env3/lib/python3.6/site-packages/redis/connection.py", line 555, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 2 connecting to unix socket: utf-8. No such file or directory.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
andymccurdycommented, Jan 31, 2020

I moved the username arg to the end of the list in 5a1f3c4. 3.4.1 will be published shortly.

0reactions
bmerrycommented, Feb 3, 2020

Yes, it’s a fakeredis issue, and I’m hoping to get a fix out this week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

3.4.0 changed argument positions for constructor · Issue #1276
Redis constructor, but because it was added near the front of the list, and the arguments are not marked keyword-only, it breaks code...
Read more >
Subclasses and Inheritance (Java in a Nutshell)
If a class does not declare any constructors, it is given a no-argument constructor by default. Classes declared public are given public constructors....
Read more >
Documentation - Classes - TypeScript
Constructor (MDN). Class constructors are very similar to functions. You can add parameters with type annotations, default values, and overloads:.
Read more >
Using the this Keyword (The Java™ Tutorials > Learning the ...
This class contains a set of constructors. Each constructor initializes some or all of the rectangle's member variables. The constructors provide a default ......
Read more >
`std::move` an Eigen object in a constructor? - Stack Overflow
Node(Eigen::Vector3d position_, const double temperature_) : position(std::move(position_)), temperature(temperature_) {} // or must it be this?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found