eliminate nontrivial Reset(...) from TypedPythonObject

Summary:
This deletes `Reset(...)`, except for the no-argument form `Reset()`
from `TypedPythonObject`, and therefore from `PythonString`, `PythonList`,
etc.

It updates the various callers to use assignment, `As<>`, `Take<>`,
and `Retain<>`, as appropriate.

followon to https://reviews.llvm.org/D69080

Reviewers: JDevlieghere, clayborg, labath, jingham

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69133

llvm-svn: 375350
This commit is contained in:
Lawrence D'Anna
2019-10-19 18:43:49 +00:00
parent 1d509201e2
commit 722b618924
4 changed files with 78 additions and 46 deletions

View File

@@ -27,8 +27,7 @@ public:
void SetUp() override {
PythonTestSuite::SetUp();
PythonString sys_module("sys");
m_sys_module.Reset(PyRefType::Owned, PyImport_Import(sys_module.get()));
m_sys_module = unwrapIgnoringErrors(PythonModule::Import("sys"));
m_main_module = PythonModule::MainModule();
m_builtins_module = PythonModule::BuiltinsModule();
}
@@ -70,13 +69,10 @@ TEST_F(PythonDataObjectsTest, TestResetting) {
PythonDictionary dict(PyInitialValue::Empty);
PyObject *new_dict = PyDict_New();
dict.Reset(PyRefType::Owned, new_dict);
dict = Take<PythonDictionary>(new_dict);
EXPECT_EQ(new_dict, dict.get());
dict.Reset(PyRefType::Owned, nullptr);
EXPECT_EQ(nullptr, dict.get());
dict.Reset(PyRefType::Owned, PyDict_New());
dict = Take<PythonDictionary>(PyDict_New());
EXPECT_NE(nullptr, dict.get());
dict.Reset();
EXPECT_EQ(nullptr, dict.get());