Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Catching exceptions in embedded code no longer works on 3.7.2?
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 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

exceptions are used in try/except clauses
(Feb-01-2019, 10:54 PM)Larz60+ Wrote: exceptions are used in try/except clauses

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

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.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  code works at command line but not in .py ridgerunnersjw 4 109 Sep-12-2019, 11:09 PM
Last Post: ridgerunnersjw
  Everything works except for one line of code 357mag 3 126 Sep-06-2019, 06:03 PM
Last Post: 357mag
  multi-line messages in raised exceptions? Skaperen 3 186 Aug-01-2019, 02:17 AM
Last Post: Skaperen
  Change linenumber and filename printed in exceptions like #line in C kryptomatrix 2 229 Jul-12-2019, 06:01 AM
Last Post: Gribouillis
  Code works in IDLE, appears to work in CMD, but won't produce files in CMD/Windows ChrisPy33 3 492 Jun-12-2019, 05:56 AM
Last Post: ChrisPy33
  Catching Errors Alienspecimen 1 227 May-18-2019, 11:07 PM
Last Post: Larz60+
  Trouble Understanding Why This Code Works crocolicious 2 335 Apr-09-2019, 05:24 PM
Last Post: crocolicious
  Creating custom exceptions that co-operate LadySvetlana 4 382 Mar-19-2019, 04:24 PM
Last Post: LadySvetlana
  My code is taking longer time to give result rajeshwin 4 380 Feb-20-2019, 08:18 PM
Last Post: ichabod801
  Pexpect not catching embeded ssh response luchoArg32 0 277 Feb-08-2019, 08:45 AM
Last Post: luchoArg32

Forum Jump:

Users browsing this thread: 1 Guest(s)