Python Forum
Catching exceptions in embedded code no longer works on 3.7.2? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Catching exceptions in embedded code no longer works on 3.7.2? (/thread-15822.html)



Catching exceptions in embedded code no longer works on 3.7.2? - FFMG - Feb-01-2019

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


RE: Catching exceptions in embedded code no longer works on 3.7.2? - Larz60+ - Feb-01-2019

exceptions are used in try/except clauses
see: http://openbookproject.net/thinkcs/python/english3e/exceptions.html


RE: Catching exceptions in embedded code no longer works on 3.7.2? - FFMG - Feb-02-2019

(Feb-01-2019, 10:54 PM)Larz60+ Wrote: exceptions are used in try/except clauses
see: http://openbookproject.net/thinkcs/python/english3e/exceptions.html

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

FFMG


RE: Catching exceptions in embedded code no longer works on 3.7.2? - Larz60+ - Feb-02-2019

OK, see that now, I'm an old C++ programmer, but it's been quite a while.
I have to pass.


RE: Catching exceptions in embedded code no longer works on 3.7.2? - FFMG - Feb-02-2019

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)".



RE: Catching exceptions in embedded code no longer works on 3.7.2? - Larz60+ - Feb-02-2019

Thanks for sharing.