From b7f7866768f540e18cd4df55689c54d197490642 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 24 Nov 2023 23:31:12 +0100 Subject: [PATCH 1/2] Building test case --- testdata/klayout_main/main.rb | 12 ++++++++++++ testdata/klayout_main/test12.py | 4 ++++ testdata/klayout_main/test12.rb | 5 +++++ 3 files changed, 21 insertions(+) create mode 100644 testdata/klayout_main/test12.py create mode 100644 testdata/klayout_main/test12.rb diff --git a/testdata/klayout_main/main.rb b/testdata/klayout_main/main.rb index 279c20417..f867f4339 100644 --- a/testdata/klayout_main/main.rb +++ b/testdata/klayout_main/main.rb @@ -191,6 +191,18 @@ class KLayoutMain_TestClass < TestBase end + def test_12 + + # Application.exit(0) - Python + out = `#{self.klayout_bin} -z -r #{File.join(File.dirname(__FILE__), "test12.py")} 2>&1` + assert_equal(out, "Before exit()\n") + + # Application.exit(0) - Ruby + out = `#{self.klayout_bin} -z -r #{File.join(File.dirname(__FILE__), "test12.rb")} 2>&1` + assert_equal(out, "Before exit()\n") + + end + end load("test_epilogue.rb") diff --git a/testdata/klayout_main/test12.py b/testdata/klayout_main/test12.py new file mode 100644 index 000000000..b1e545993 --- /dev/null +++ b/testdata/klayout_main/test12.py @@ -0,0 +1,4 @@ + +print("Before exit()") +pya.Application.instance().exit(0) + diff --git a/testdata/klayout_main/test12.rb b/testdata/klayout_main/test12.rb new file mode 100644 index 000000000..304a4bf6d --- /dev/null +++ b/testdata/klayout_main/test12.rb @@ -0,0 +1,5 @@ + +$stdout.puts("Before exit()") +$stdout.flush +RBA::Application::instance.exit(0) + From dd0cfe9b9787e9dbd46852e64077ef74bbcfa786 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 25 Nov 2023 01:00:20 +0100 Subject: [PATCH 2/2] Trying to fix issue --- src/pya/pya/pya.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pya/pya/pya.cc b/src/pya/pya/pya.cc index 377c7211f..8c617f71d 100644 --- a/src/pya/pya/pya.cc +++ b/src/pya/pya/pya.cc @@ -390,6 +390,8 @@ PythonInterpreter::~PythonInterpreter () m_stdout = PythonPtr (); m_stderr = PythonPtr (); + sp_interpreter = 0; + if (m_embedded) { Py_Finalize (); @@ -400,8 +402,6 @@ PythonInterpreter::~PythonInterpreter () } } - - sp_interpreter = 0; } char *