-
Notifications
You must be signed in to change notification settings - Fork 89
[configdb]: Adopt get_table method to work with python3. #26
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
[configdb]: Adopt get_table method to work with python3. #26
Conversation
Decode data from redis DB into UTF-8 in python3.
| import time | ||
| from .dbconnector import SonicV2Connector | ||
|
|
||
| PY3K = sys.version_info >= (3, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
K [](start = 3, length = 1)
What does K mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
py3k is py3000, py3.0 same meaning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears "Python 3000" (or "py3k") was the initial name for what was eventually changed to "Python 3.0" to keep in line with the old versioning scheme before its actual release. I wasn't aware of the early name, and others might not be, either. We can always change it to "PY3X" or similar in the future.
Whatever we choose, we should probably use the same convention in all of our scripts whenever we need to make them compatible with both Python 2 and Python 3.
| for key in raw_data: | ||
| for raw_key in raw_data: | ||
| key = raw_key | ||
| if PY3K: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PY3K [](start = 15, length = 4)
Why we need to check python3? Is it possible not to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Library supposes to work with Python 2 and 3. Current implementation doesn't handle encoding correctly in Python 3. Python 2 has different API to works with encoding than Python 3. So it is not possible to not check.
* msft_github/master: [configdb]: Addopt get_table method to work with python3. (sonic-net#26) [configdb]: add mod_entry, rename set_config to mod_config (sonic-net#25) [configdb] fix bug of leaving unwanted columns in a hash (sonic-net#23) Revert "Add support to remove the key of table entry (sonic-net#15)" (sonic-net#24) Add support to remove the key of table entry (sonic-net#15) [configdb] support redis connecting methods other than TCP (sonic-net#22) [interface]: Extend the max data wait time to 60s (sonic-net#21)
Decode data from redis DB into UTF-8 in python3.