pyshark icon indicating copy to clipboard operation
pyshark copied to clipboard

Replace py dependency with termcolor.

Open bwoodsend opened this issue 3 years ago • 5 comments

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.

bwoodsend avatar Jul 14 '22 14:07 bwoodsend

This is great. If you have the time, this is also a good chance to change strings to f-strings

KimiNewt avatar Jul 14 '22 15:07 KimiNewt

This is great. If you have the time, this is also a good chance to change strings to f-strings

Done.

bwoodsend avatar Jul 16 '22 15:07 bwoodsend

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

miaotony avatar Aug 26 '22 20:08 miaotony

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/

bwoodsend avatar Aug 26 '22 23:08 bwoodsend

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 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/

Wow, thank you very much!

miaotony avatar Aug 27 '22 08:08 miaotony

@KimiNewt can we get a new release with this included so folks can upgrade pyshark and close out CVE-2022-42969?

vihangm avatar Mar 30 '23 05:03 vihangm