pyshark
pyshark copied to clipboard
Replace py dependency with termcolor.
Only the colored terminal printing feature of the borderline deprecated py library is used so swap it out for termcolor which is slimmer. Doing so also fixes the pains that py's submodule deprecations sculdugery have been causing PyInstaller users (e.g. #245, #447, plus a new regression specific to pyshark 0.5.2 leading to a ModuleNotFoundError: No module named 'py._io').
Normally I'd raise an issue first to see what you think about the idea but it looked like the easiest way to measure feasibility of this change was just to try it and see.
This is great. If you have the time, this is also a good chance to change strings to f-strings
This is great. If you have the time, this is also a good chance to change strings to f-strings
Done.
I also found this bug when running my program packaged with pyinstaller which the version of pyshark was 0.5.3.

...
File "PyInstaller\loader\pyimod02_importers.py", line 493, in exec_module
File "pyshark\__init__.py", line 13, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 493, in exec_module
File "pyshark\capture\live_capture.py", line 7, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 493, in exec_module
File "pyshark\capture\capture.py", line 11, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 493, in exec_module
File "pyshark\packet\packet.py", line 8, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 493, in exec_module
File "pyshark\packet\layers\base.py", line 11, in <module>
File "pyshark\packet\layers\base.py", line 61, in BaseLayer
File "py\_vendored_packages\apipkg\__init__.py", line 157, in __makeattr
File "py\_vendored_packages\apipkg\__init__.py", line 75, in importobj
ModuleNotFoundError: No module named 'py._io'
Could you please fix the bug by merging this PR ASAP?
cc @KimiNewt
I've reluctantly put a fragile temporary fix (https://github.com/pyinstaller/pyinstaller-hooks-contrib/pull/477) into PyInstaller since this PR hasn't moved in the last 6 weeks. If you pip install "pyinstaller-hooks-contrib>=v2022.9" then run your next pyinstaller build adding the --clean flag (or just delete the build directory) then it should work.
And come on @KimiNewt! I didn't refactor all those f-strings for fun you know/
I've reluctantly put a fragile temporary fix (pyinstaller/pyinstaller-hooks-contrib#477) into PyInstaller since this PR hasn't moved in the last 6 weeks. If you
pip install "pyinstaller-hooks-contrib>=v2022.9"then run your nextpyinstallerbuild adding the--cleanflag (or just delete thebuilddirectory) then it should work.And come on @KimiNewt! I didn't refactor all those f-strings for fun you know/
Wow, thank you very much!
@KimiNewt can we get a new release with this included so folks can upgrade pyshark and close out CVE-2022-42969?