In the latest release (2.7), calling connect with user/password = None fails. In versions < 2.6.2 this would succeed
>>> from psycopg2 import connect
>>> connect(host='localhost', port=5432, database='basedb', user=None, password=None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/patrick/.virtualenvs/sigopt/lib/python2.7/site-packages/psycopg2/__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL: role "None" does not exist
Is this new expected behaviour? If so, should 2.7 be a new major release (3.0) to indicate backwards-incompatible changes?
It wasn't expected, no. However the fact that None was interpreted as unspecified seems an undocumented side effect to me. I think we can fix it and drop the None kwargs, but it seems to me your use of connect() is a bit stretched.
Hm, okay. I am happy to fix this on my end but this does seem to me to be a pretty natural way to specify no user/password. I suspect that 2.7 will break other code in the wild as well
Thanks @dvarrazzo !
You are right: although undocumented it is quite idiomatic, so I'm inclined to fix it anyway.
Confirming that fix resolved the issue for me (#524, biocommons/hgvs#398). Thanks!
Most helpful comment
You are right: although undocumented it is quite idiomatic, so I'm inclined to fix it anyway.