From 90537673302f13e92ffabba84901164c6b974b2d Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 25 Apr 2022 20:14:44 -0700 Subject: Remove Python 2 support from the ScriptInterpreter plugin We dropped downstream support for Python 2 in the previous release. Now that we have branched for the next release the window where this kind of change could introduce conflicts is closing too. Start by getting rid of Python 2 support in the Script Interpreter plugin. Differential revision: https://reviews.llvm.org/D124429 --- .../Python/PythonDataObjectsTests.cpp | 28 ---------------------- 1 file changed, 28 deletions(-) (limited to 'lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp') diff --git a/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp b/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp index 9bfbb37..8dd55a5 100644 --- a/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp +++ b/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp @@ -164,18 +164,6 @@ TEST_F(PythonDataObjectsTest, TestDictionaryResolutionWithDot) { TEST_F(PythonDataObjectsTest, TestPythonInteger) { // Test that integers behave correctly when wrapped by a PythonInteger. -#if PY_MAJOR_VERSION < 3 - // Verify that `PythonInt` works correctly when given a PyInt object. - // Note that PyInt doesn't exist in Python 3.x, so this is only for 2.x - PyObject *py_int = PyInt_FromLong(12); - EXPECT_TRUE(PythonInteger::Check(py_int)); - PythonInteger python_int(PyRefType::Owned, py_int); - - EXPECT_EQ(PyObjectType::Integer, python_int.GetObjectType()); - auto python_int_value = As(python_int); - EXPECT_THAT_EXPECTED(python_int_value, llvm::HasValue(12)); -#endif - // Verify that `PythonInteger` works correctly when given a PyLong object. PyObject *py_long = PyLong_FromLong(12); EXPECT_TRUE(PythonInteger::Check(py_long)); @@ -225,13 +213,8 @@ TEST_F(PythonDataObjectsTest, TestPythonBytes) { EXPECT_TRUE(PythonBytes::Check(py_bytes)); PythonBytes python_bytes(PyRefType::Owned, py_bytes); -#if PY_MAJOR_VERSION < 3 - EXPECT_TRUE(PythonString::Check(py_bytes)); - EXPECT_EQ(PyObjectType::String, python_bytes.GetObjectType()); -#else EXPECT_FALSE(PythonString::Check(py_bytes)); EXPECT_EQ(PyObjectType::Bytes, python_bytes.GetObjectType()); -#endif llvm::ArrayRef bytes = python_bytes.GetBytes(); EXPECT_EQ(bytes.size(), strlen(test_bytes)); @@ -258,23 +241,12 @@ TEST_F(PythonDataObjectsTest, TestPythonString) { static const char *test_string = "PythonDataObjectsTest::TestPythonString1"; static const char *test_string2 = "PythonDataObjectsTest::TestPythonString2"; -#if PY_MAJOR_VERSION < 3 - // Verify that `PythonString` works correctly when given a PyString object. - // Note that PyString doesn't exist in Python 3.x, so this is only for 2.x - PyObject *py_string = PyString_FromString(test_string); - EXPECT_TRUE(PythonString::Check(py_string)); - PythonString python_string(PyRefType::Owned, py_string); - - EXPECT_EQ(PyObjectType::String, python_string.GetObjectType()); - EXPECT_STREQ(test_string, python_string.GetString().data()); -#else // Verify that `PythonString` works correctly when given a PyUnicode object. PyObject *py_unicode = PyUnicode_FromString(test_string); EXPECT_TRUE(PythonString::Check(py_unicode)); PythonString python_unicode(PyRefType::Owned, py_unicode); EXPECT_EQ(PyObjectType::String, python_unicode.GetObjectType()); EXPECT_STREQ(test_string, python_unicode.GetString().data()); -#endif // Test that creating a `PythonString` object works correctly with the // string constructor -- cgit v1.1