From 3602e5eb52cfe801bbf4222755530dd58635a515 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Sun, 29 Aug 2021 14:26:43 -0400 Subject: [PATCH] Demonstrate that this is not a bug --- tests/test_embed/test_interpreter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_embed/test_interpreter.cpp b/tests/test_embed/test_interpreter.cpp index bf9d80f3f..ce3c5c553 100644 --- a/tests/test_embed/test_interpreter.cpp +++ b/tests/test_embed/test_interpreter.cpp @@ -306,13 +306,13 @@ TEST_CASE("Reload module from file") { class TestObject { public: - TestObject(std::function f) : _id(++_count), _f(f) {} + TestObject(std::function f) : _id(++_count), _f(std::move(f)) {} ~TestObject() { - py::print("~TestObject(" + std::to_string(_id) + ")"); --_count; + py::print("~TestObject(" + std::to_string(_id) + ")"); } - int GetCount() { return _id; } + int GetCount() const { return _id; } static int _count; int _id; @@ -337,6 +337,7 @@ from test_memory_leak import TestObject guard = TestObject(lambda: None) )", local, local); REQUIRE(1 == TestObject::_count); + local.clear(); } py::finalize_interpreter();