[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.
K [](start = 3, length = 1)
What does K mean?
There was a problem hiding this comment.
py3k is py3000, py3.0 same meaning.
There was a problem hiding this comment.
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.
PY3K [](start = 15, length = 4)
Why we need to check python3? Is it possible not to?
There was a problem hiding this comment.
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.