Skip to content

Commit

Permalink
removed support for Python 2.7 / small cleanups (#6804)
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Sep 16, 2024
1 parent 7be1dff commit 08b5016
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 29 deletions.
19 changes: 5 additions & 14 deletions cmake/findDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,20 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)

if(CMAKE_VERSION VERSION_EQUAL "3.12" OR CMAKE_VERSION VERSION_GREATER "3.12")
find_package(Python COMPONENTS Interpreter)
if(NOT Python_Interpreter_FOUND)
message(WARNING "No python interpreter found - disabling matchcompiler.")
set(USE_MATCHCOMPILER_OPT "Off")
endif()
else()
find_package(PythonInterp 3 QUIET)
if(NOT PYTHONINTERP_FOUND)
set(PYTHONINTERP_FOUND "")
find_package(PythonInterp 2.7 QUIET)
if(NOT PYTHONINTERP_FOUND AND NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
message(WARNING "No python interpreter found - disabling matchcompiler.")
set(USE_MATCHCOMPILER_OPT "Off")
else()
message(WARNING "Support for Python 2.7 is deprecated (it went EOL in January 2020) and will be removed in Cppcheck 2.16 - please use Python 3.x instead.")
endif()
endif()
if(PYTHONINTERP_FOUND)
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
set(Python_VERSION ${PYTHON_VERSION_STRING})
set(Python_Interpreter_FOUND ${PYTHONINTERP_FOUND})
endif()
endif()

if(NOT Python_Interpreter_FOUND AND NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
message(WARNING "No python interpreter found - disabling matchcompiler.")
set(USE_MATCHCOMPILER_OPT "Off")
endif()

if(NOT USE_BUNDLED_TINYXML2)
find_package(tinyxml2 QUIET)
if(TARGET tinyxml2::tinyxml2)
Expand Down
2 changes: 1 addition & 1 deletion htmlreport/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cppcheck-htmlreport
This is a little utility to generate a html report of a XML file produced by
cppcheck.

The utility is implemented in Python (2.7+) and requires the pygments module
The utility is implemented in Python and requires the pygments module
to generate syntax highlighted source code.
If you are using a Debian based Linux system, the pygments package can be
installed by following command:
Expand Down
1 change: 1 addition & 0 deletions releasenotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Changed interface:
-

Deprecations:
- The previously deprecated support for Python 2.7 has been removed. please use Python 3 instead.
-

Other:
Expand Down
6 changes: 1 addition & 5 deletions test/tools/htmlreport/test_htmlreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
import sys
import tempfile

if sys.version_info < (2, 7):
# For TestCase.assertIn().
import unittest2 as unittest
else:
import unittest
import unittest

TEST_TOOLS_DIR = os.path.abspath(os.path.dirname(__file__))
ROOT_DIR = os.path.split(os.path.dirname(os.path.dirname(TEST_TOOLS_DIR)))[0]
Expand Down
11 changes: 2 additions & 9 deletions tools/reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,10 @@ def print_info(self):
print('FILE=' + self.__file)

def __communicate(self, p, timeout=None, **kwargs):
if sys.version_info[0] < 3:
return p.communicate(**kwargs)
else:
return p.communicate(timeout=timeout)
return p.communicate(timeout=timeout)

def runtool(self, filedata=None):
if sys.version_info[0] < 3:
class TimeoutExpired(Exception):
pass
else:
TimeoutExpired = subprocess.TimeoutExpired
TimeoutExpired = subprocess.TimeoutExpired

timeout = None
if self.__elapsed_time:
Expand Down

0 comments on commit 08b5016

Please sign in to comment.