Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError Exception raised when calling ConfigDBConnector().get_config in Python3 #44

Open
lvphuc133 opened this issue Jan 9, 2019 · 0 comments

Comments

@lvphuc133
Copy link

root@sonic:~# python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.

import swsssdk
db = swsssdk.ConfigDBConnector()
db.connect()
cfg = db.get_config()
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.5/dist-packages/swsssdk-2.0.1-py3.5.egg/swsssdk/configdb.py", line 284, in get_config
(table_name, row) = key.split(self.TABLE_NAME_SEPARATOR, 1)
TypeError: a bytes-like object is required, not 'str'

FIX:
Current code:
for key in keys:
try:
(table_name, row) = key.split(self.TABLE_NAME_SEPARATOR, 1)

Proposed code change:
for key in keys:
if PY3K:
key = key.decode('utf-8')
try:
(table_name, row) = key.split(self.TABLE_NAME_SEPARATOR, 1)

madhupalu pushed a commit to madhupalu/sonic-py-swsssdk that referenced this issue Jan 15, 2019
madhupalu added a commit to madhupalu/sonic-py-swsssdk that referenced this issue Jan 15, 2019
madhupalu added a commit to madhupalu/sonic-py-swsssdk that referenced this issue Jan 15, 2019
madhupalu added a commit to madhupalu/sonic-py-swsssdk that referenced this issue Jan 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant