This repository has been archived on 2025-03-20. You can view files and clone it, but cannot push or open issues or pull requests.
sonic-buildimage/src/sonic-py-common
Joe LeVeque 980a024dd4
Fix Python 3 'importlib' bug; Add support for Python 2 back in sonic-py-common (#6933)
Fix a strange bug introduced by https://github.com/Azure/sonic-buildimage/pull/6832 which would only occur in environments with both Python 2 and Python 3 installed (e.g., the PMon container). Error messages such as the following would be seen:

```
ERR pmon#ledd[29]: Failed to load ledutil: module 'importlib' has no attribute 'machinery'
```

This is very odd, and it seems like the Python 2 version of importlib, which is basically just a stub, is taking precedence over the Python 3 version. I found that this occurs when calling `import importlib`. However, calling `import importlib.machinery` and `import importlib.util` causes the proper package to be referenced, and the `machinery` and `util` modules are loaded successfully. This is how it is specified in examples in the official documentation, however there is nothing mentioned regarding that it *should* be done this way or that `import importlib` is unreliable.

Also, since sonic-py-common is still used in environments with Python 2 installed we should maintain support for both Python 2 and 3 until we completely deprecate Python 2, so I have added this back in.
2021-03-02 18:31:19 -08:00
..
sonic_py_common Fix Python 3 'importlib' bug; Add support for Python 2 back in sonic-py-common (#6933) 2021-03-02 18:31:19 -08:00
tests [sonic-py-common] Relocate some functions from sonic-utilities (#5269) 2020-08-30 08:24:29 -07:00
.gitignore [sonic-py-common] Add unit test framework (#5238) 2020-08-24 10:35:22 -07:00
pytest.ini [sonic-py-common] Add unit test framework (#5238) 2020-08-24 10:35:22 -07:00
setup.cfg [sonic-py-common] Add unit test framework (#5238) 2020-08-24 10:35:22 -07:00
setup.py [python-click] No longer build our own package, let pip/setuptools install vanilla (#5549) 2020-10-14 10:16:35 -07:00