Bug report #15606

DBManager python error on master

Added by Nikolay Lebedev about 3 years ago. Updated over 2 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:-
Category:DB Manager
Affected QGIS version:master Regression?:No
Operating System:Arch Linux Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:23529

Description

When trying to expand or refresh postgis connection in DBManager I get a python error:

@An error has occurred while executing Python code: 
TypeError: argument 1 must be str, not bytes

Traceback (most recent call last):
  File "/usr/share/qgis/python/plugins/db_manager/db_model.py", line 439, in rowCount
    self._refreshIndex(parent, True)
  File "/usr/share/qgis/python/plugins/db_manager/db_model.py", line 490, in _refreshIndex
    if item.populate():
  File "/usr/share/qgis/python/plugins/db_manager/db_model.py", line 166, in populate
    if not connection.connect():
  File "/usr/share/qgis/python/plugins/db_manager/db_plugins/postgis/plugin.py", line 99, in connect
    return self.connectToUri(uri)
  File "/usr/share/qgis/python/plugins/db_manager/db_plugins/plugin.py", line 108, in connectToUri
    self.db = self.databasesFactory(self, uri)
  File "/usr/share/qgis/python/plugins/db_manager/db_plugins/postgis/plugin.py", line 69, in databasesFactory
    return PGDatabase(connection, uri)
  File "/usr/share/qgis/python/plugins/db_manager/db_plugins/postgis/plugin.py", line 107, in __init__
    Database.__init__(self, connection, uri)
  File "/usr/share/qgis/python/plugins/db_manager/db_plugins/plugin.py", line 217, in __init__
    self.connector = self.connectorsFactory(uri)
  File "/usr/share/qgis/python/plugins/db_manager/db_plugins/postgis/plugin.py", line 110, in connectorsFactory
    return PostGisDBConnector(uri)
  File "/usr/share/qgis/python/plugins/db_manager/db_plugins/postgis/connector.py", line 67, in __init__
    self.connection = psycopg2.connect(expandedConnInfo.encode('utf-8'))
  File "/usr/lib/python3.5/site-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
TypeError: argument 1 must be str, not bytes

Python version: 3.5.2 (default, Jun 28 2016, 08:46:01) [GCC 6.1.1 20160602] 
QGIS version: 2.99.0-Master Master, e7c9400 
Python Path:

/usr/share/qgis/python
/home/bezdna/.qgis-dev//python
/home/bezdna/.qgis-dev//python/plugins
/usr/share/qgis/python/plugins
/usr/lib/python35.zip
/usr/lib/python3.5
/usr/lib/python3.5/plat-linux
/usr/lib/python3.5/lib-dynload
/usr/lib/python3.5/site-packages
/home/bezdna/.qgis-dev//python

Seems like python3 expandedConnInfo.encode('utf-8') returns binary instead of string.

History

#1 Updated by Giovanni Manghi over 2 years ago

  • Subject changed from DBManager postgis connector crashes on master to DBManager python error on master
  • Status changed from Open to Feedback

Was this on qgis3/master?

#2 Updated by Nikolay Lebedev over 2 years ago

Yes, it was on qgis3/master

QGIS version: 2.99.0-Master Master, e7c9400

#3 Updated by Giovanni Manghi over 2 years ago

  • Status changed from Feedback to Open
  • Target version set to Version 3.0
  • Priority changed from Normal to Severe/Regression

#4 Updated by Arnaud Morvan over 2 years ago

  • % Done changed from 0 to 100
  • Status changed from Open to Closed

This should have been fixed by #9cd39e79dd6bac0b79d3f2da9217777f60c70d66

expandedConnInfo.encode('utf-8') => expandedConnInfo

We now pass str not bytes.

Also available in: Atom PDF