siemens / CtrlppCheck

GNU General Public License v3.0
14 stars 11 forks source link

Lizard script not working with Python version 3.11+ #74

Closed cbv08 closed 11 months ago

cbv08 commented 1 year ago

Describe the bug This relates to discussion #73 Summary, having installed version 1.0.x of CtrlppCheck, Python Version 3.12 and Lizard I do not get any "per File"/"per Fctn" outputs. parsing "-dbg ScriptData" to gedi gives the following output:

WCCOAui1:2023.11.07 10:05:47.413["ScriptData::calculate"]["!!! check if lizard is installed"][1]["C:/Users/USER/AppData/Local/Programs/Python/Python312/python.exe D:\Source\WinCCOA_QualityChecks\v1_0_2\data\lizard\lizard.py --csv C:/Users/USER/AppData/Local/Temp/WCCOAui.pGltLn.ctl"]["Traceback (most recent call last): WCCOAui1: File \"D:\Source\WinCCOA_QualityChecks\v1_0_2\data\lizard\lizard.py\", line 991, in <module> WCCOAui1: main() WCCOAui1: File \"D:\Source\WinCCOA_QualityChecks\v1_0_2\data\lizard\lizard.py\", line 985, in main WCCOAui1: warning_count = printer(result, options, schema) WCCOAui1: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ WCCOAui1: File \"D:\Source\WinCCOA_QualityChecks\v1_0_2\data\lizard\lizard_ext\__init__.py\", line 17, in print_csv WCCOAui1: csv_output(list(results), options.verbose) WCCOAui1: ^^^^^^^^^^^^^ WCCOAui1: File \"D:\Source\WinCCOA_QualityChecks\v1_0_2\data\lizard\lizard.py\", line 512, in __call__ WCCOAui1: filename, auto_read(filename)) WCCOAui1: ^^^^^^^^^^^^^^^^^^^ WCCOAui1: File \"D:\Source\WinCCOA_QualityChecks\v1_0_2\data\lizard\lizard_ext\auto_open.py\", line 31, in auto_read WCCOAui1: with auto_open(filename, 'rU') as current_file: WCCOAui1: ^^^^^^^^^^^^^^^^^^^^^^^^^ WCCOAui1: File \"D:\Source\WinCCOA_QualityChecks\v1_0_2\data\lizard\lizard_ext\auto_open.py\", line 26, in auto_open WCCOAui1: return open(*args, **kwargs) WCCOAui1: ^^^^^^^^^^^^^^^^^^^^^ WCCOAui1:ValueError: invalid mode: 'rU' WCCOAui1:"]

The error is thrown in ScriptData::calculate Checking python documentation U was removed in version 3.11 https://docs.python.org/3/library/functions.html#open

To Reproduce Steps to reproduce the behavior:

  1. Using Python version 3.12
  2. Open gedi with argument -dbg ScriptData
  3. Click on CtrlppCheck in a ctl script
  4. See error

Expected behavior Either the lizard_ext\auto_open.py script should be updated to not use rU Or the documentation should state that python version should be less than 3.11

Screenshots Please see discussion #73

Software version and environment (please complete the following information):

dhoegerlETM commented 11 months ago

@cbv08 please check if your fix also works with older python version.

cbv08 commented 11 months ago

Hello @dhoegerlETM

How old? I tested version 3.6.8 and it works.

I am having some trouble finding when U mode was depricated (forum posts online range from version 3.1 - 3.4) In the python documentation it seems to be from version 3.4 https://docs.python.org/3.4/library/functions.html#open

As far as i have been able to read, the default behaviour was changed to the old U mode. As such it should work as far back as version 3.4 maybe earlier too.

Kind regards Olav

dhoegerlETM commented 11 months ago

That's old enough - thank you very much!