Crash on shutdown when embedding Python in C#

Environment

  • Pythonnet version: a80c685
  • Python version: 3.9.10
  • Operating System: Windows (probably others too)
  • .NET Runtime: mono/Unity

Details

Using the Python for Unity package with at a commit hash later or equal to the one above, pythonnet causes a crash on Shutdown. I've traced the issue to this PR: #1780 which is cause by checking a Python internal without holding the GIL; which the shutdown process isn't doing (or at least not at this point).