Python Forum

Full Version: Catching exceptions in embedded code no longer works on 3.7.2?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In an older project of mine I used to catch exceptions in the code by doing ...

// simplified code ...
PyObject * PyRes = PyRun_String( ... )
...
PyObject* ex = PyErr_Occurred();
...
if (!PyErr_ExceptionMatches(PyExc_SystemExit))
{
  // there was a non-system error
}
But now I get the error, (in VS2017)

Error:
Error LNK2001 unresolved external symbol PyExc_SystemExit
I suspect i need to include something to my project/files?
Any suggestions as to what might be missing?

Many thanks

FFMG
exceptions are used in try/except clauses
see: http://openbookproject.net/thinkcs/pytho...tions.html
(Feb-01-2019, 10:54 PM)Larz60+ Wrote: [ -> ]exceptions are used in try/except clauses
see: http://openbookproject.net/thinkcs/pytho...tions.html

Thanks, but my question was about embedded python code, (in c++), rather than straight Python code.

FFMG
OK, see that now, I'm an old C++ programmer, but it's been quite a while.
I have to pass.
I found what the issue is/was

It is a clear case of not reading the manual properly :) ...

In the readme.txt

Quote:Static library
--------------

The solution has no configuration for static libraries. However it is
easy to build a static library instead of a DLL. You simply have to set
the "Configuration Type" to "Static Library (.lib)" and alter the
preprocessor macro "Py_ENABLE_SHARED" to "Py_NO_ENABLE_SHARED". You may
also have to change the "Runtime Library" from "Multi-threaded DLL
(/MD)" to "Multi-threaded (/MT)".
Thanks for sharing.