{"id":169639,"date":"2013-02-17T16:39:03","date_gmt":"2013-02-17T12:39:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=169639"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=169639","title":{"rendered":"<span class=\"post_title\">\u041f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 C++ \u0432 Python \u0438\u043b\u0438 \u00ab\u0422\u0443\u0434\u0430 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u00bb<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0412 \u044d\u0442\u043e\u0439 \u0433\u043b\u0430\u0432\u0435 \u0441\u043a\u0430\u0437\u0430 \u043f\u0440\u043e \u0434\u0440\u0443\u0436\u0431\u0443 C++ \u0438 Python \u0431\u0443\u0434\u0435\u0442 \u043d\u0430 \u0443\u0434\u0438\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u0430\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Boost.Python. \u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0442\u0443\u0434\u0430 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0441\u0443\u0442\u0438 \u0441\u043b\u0430\u0431\u044b\u043c \u043c\u0435\u0441\u0442\u043e\u043c \u0434\u0430\u043d\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0411\u0443\u0434\u0435\u043c \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0440\u043e\u0434\u043d\u044b\u043c API \u044f\u0437\u044b\u043a\u0430 Python, \u0430 \u0433\u0434\u0435 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Boost.Python.<br \/>  \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 Boost.Python \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u0437 C++ \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 Python \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e RuntimeError, \u0430 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0438\u0437 Python \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 C++ \u0442\u0438\u043f\u0430 error_already_set, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u00ab\u0442\u0435\u0431\u0435 \u0447\u0442\u043e-\u0442\u043e \u043f\u0440\u0438\u043b\u0435\u0442\u0435\u043b\u043e, \u0441\u0445\u043e\u0434\u0438 \u0441\u0430\u043c \u043f\u043e\u0447\u0438\u0442\u0430\u0439 \u0447\u0442\u043e \u0442\u0430\u043c\u00bb. \u0418 \u0432\u043e\u0442 \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u043c \u043a\u0430\u043a \u0440\u0430\u0437 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043b\u0438\u0448\u043d\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c C-API \u044f\u0437\u044b\u043a\u0430 Python, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e \u043b\u043e\u0433\u0438\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<br \/>  \u041a \u0447\u0435\u043c\u0443 \u0442\u0430\u043a\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438? \u2014 \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 Python, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 C++, \u043a\u0440\u043e\u043c\u0435 \u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u0435\u0433\u043e \u0442\u0438\u043f\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0435\u0449\u0451 \u0438 traceback \u2014 \u0441\u0442\u0435\u043a \u0434\u043e \u043c\u0435\u0441\u0442\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 std::exception \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e stacktrace, \u0430 \u0437\u0430\u043e\u0434\u043d\u043e \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0442\u0443\u0434\u0430 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 C++ \u0432 \u043a\u043b\u0430\u0441\u0441\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 Python.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0435\u0440\u0438\u044f\u0445<\/h4>\n<p>  <a href=\"http:\/\/habrahabr.ru\/post\/168083\/\">1. Boost.Python. \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435. \u041e\u0431\u0451\u0440\u0442\u043a\u0438 C++ \u0432 Python.<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/168233\/\">2. Boost.Python. \u041e\u0431\u0451\u0440\u0442\u043a\u0430 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 C++.<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/168827\/\">3. Boost.Python. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u043e\u0432 \u0442\u0438\u043f\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 C++ \u0438 Python.<\/a><\/p>\n<h4>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u0430\u044f \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 C++ \u0438 \u0432 Python \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442\u0435 \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 C++ \u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432\u043e\u0439 \u043e\u0431\u0432\u044f\u0437\u043a\u0438 \u043d\u0430 Python, \u043b\u0438\u0431\u043e \u0435\u0441\u043b\u0438 \u043f\u0438\u0448\u0435\u0442\u0435 \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f Python \u043d\u0430 C++ \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439. \u0420\u0430\u043d\u043e \u0438\u043b\u0438 \u043f\u043e\u0437\u0434\u043d\u043e \u043c\u044b \u0443\u043f\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0435\u0433\u043e \u0438\u0437 C++ \u0432 Python \u0438\u043b\u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442. <\/p>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0432\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 Boost.Python \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u0437 C++ \u0432 Python \u0432 \u0432\u0438\u0434\u0435 RuntimeException \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0438\u043c \u0438\u0437 exception::what(). \u041d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0421++ \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 <b>error_already_set<\/b> \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u043e\u0434\u043d\u043e\u0435 API \u044f\u0437\u044b\u043a\u0430 Python, \u043d\u043e \u0437\u0430\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043f \u0438 \u0442\u0435\u043a\u0441\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u043d\u043e \u0438 traceback \u2014 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<br \/>  \u041d\u043e \u043e\u0431\u043e \u0432\u0441\u0451\u043c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443.<\/p>\n<h4>\u041f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0433\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u0437 C++ \u0432 Python<\/h4>\n<p>  \u0418\u0442\u0430\u043a, \u0432\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0430 C++ \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Boost.Python, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u0435\u0433\u043e \u0432 \u043a\u043e\u0434\u0435 \u043d\u0430 Python \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 <b>import<\/b> \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u043e\u0434\u043d\u0443 \u0438\u0437 \u043e\u0431\u0451\u0440\u0442\u043e\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0432 \u043a\u043e\u0434\u0435 \u043d\u0430 C++ \u043a\u0438\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u043e\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u043e\u043b\u044c \u0436\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 <b>throw<\/b>. \u0412 \u043a\u043e\u0434\u0435 \u043d\u0430 Python \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 RuntimeException \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c \u0438\u0437 exception::what() \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0440\u043e\u0436\u0434\u0435\u043d\u043e \u043e\u0442 std::exception.<br \/>  \u0415\u0441\u043b\u0438 \u0432\u0430\u0441 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u0442\u043e, \u0447\u0442\u043e \u0432\u044b \u043a\u0440\u043e\u043c\u0435 \u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u0430\u0436\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u0438 \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c. \u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u043e\u0432\u0438\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043e\u0448\u0438\u0431\u043e\u043a, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<p>  \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 Boost.Python \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u044e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0438\u0434\u0430\u044e\u0449\u0435\u0433\u043e \u0440\u043e\u0434\u043d\u044b\u0435 \u043f\u0435\u043d\u0430\u0442\u044b \u043c\u043e\u0434\u0443\u043b\u044f, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430 C++. \u0412\u0441\u0451 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c: \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044f \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e boost::python::<b>register_exception_translator<\/b>&lt;T,F&gt;(F), \u0433\u0434\u0435 T \u2014 \u0442\u0438\u043f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 C++, \u0430 F \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0430\u044f \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0438 \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0430\u044f \u0441\u0432\u043e\u0439 \u0434\u043e\u043b\u0433 \u043f\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043e\u0434 \u0443\u0436\u0435 \u0432 Python. \u0412 \u043e\u0431\u0449\u0435\u043c \u0432\u0438\u0434\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cpp\">class error : public exception { ... }; ...  void translate_error( error const& ); ...  BOOST_PYTHON_MODULE( ... ) {     ...     register_exception_translator&lt;error&gt;( translate_error ); }  ... void translate_error( error const& e ) {     PyErr_SetString( PyExc_Exception, e.what() ); } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 Exception \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0435 \u0432 Python, \u043d\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043b\u044e\u0431\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435: <a href=\"http:\/\/docs.python.org\/3\/c-api\/exceptions.html?highlight=pyexc_exception#standard-exceptions\">\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435<\/a>, \u0432\u043d\u0435\u0448\u043d\u0435\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0435 \u0447\u0435\u0440\u0435\u0437 import \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u043c PyObject* \u0447\u0435\u0440\u0435\u0437 <b>object::ptr<\/b>() \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0441\u0432\u043e\u0451 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u044f\u043c\u043e \u0442\u0443\u0442 \u0436\u0435 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435 \u0447\u0435\u0440\u0435\u0437 <a href=\"http:\/\/docs.python.org\/3\/c-api\/exceptions.html?highlight=pyerr_newexception#PyErr_NewException\">PyErr_NewException<\/a>.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0442\u044b \u043e\u0449\u0443\u0449\u0435\u043d\u0438\u0439 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0449\u0451 \u043f\u0430\u0440\u0443 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0430\u043d\u0430\u043b\u043e\u0433 ZeroDivisionError \u0438 ValueError \u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0441\u0447\u0430\u0441\u0442\u044c\u044f \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0438\u0445 \u043e\u0442 \u043d\u0430\u0448\u0435\u0433\u043e error, \u043d\u0430\u0437\u043e\u0432\u0451\u043c \u0438\u0445 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e zero_division_error \u0438 value_error:  <\/p>\n<pre><code class=\"cpp\">class error : public exception { public:     error();     error( string const& message );     error( string const& message, string const& details );      virtual const char* what() const;      virtual string const& get_message() const;     virtual string const& get_details() const;      virtual const char* type() const;  private:     string m_message;     string m_details; };  class value_error : public error { public:     value_error();     value_error( string const& message );     value_error( string const& message, string const& details );      virtual const char* type() const; };  class zero_division_error : public error { public:     zero_division_error();     zero_division_error( string const& message );     zero_division_error( string const& message, string const& details );      virtual const char* type() const; }; <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0435 <b>m_details<\/b> \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u043f\u0443\u0442\u0438 \u0438\u0437 Python \u0432 C++, \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f traceback \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440. \u0410 \u043c\u0435\u0442\u043e\u0434 type() \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435. \u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u0430\u044f \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044f.<\/p>\n<p>  \u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0442\u043e\u0440\u044b \u0432 Python:  <\/p>\n<pre><code class=\"cpp\">void translate_error( error const& ); void translate_value_error( value_error const& ); void translate_zero_division_error( zero_division_error const& ); ... BOOST_PYTHON_MODULE( ... ) {     ...     register_exception_translator&lt;error&gt;( translate_error );     register_exception_translator&lt;value_error&gt;( translate_value_error );     register_exception_translator&lt;zero_division_error&gt;( translate_zero_division_error ); } ... void translate_error( error const& e ) {     PyErr_SetString( PyExc_Exception, e.what() ); }  void translate_value_error( value_error const& e ) {     PyErr_SetString( PyExc_ValueError, e.what() ); }  void translate_zero_division_error( zero_division_error const& e ) {     PyErr_SetString( PyExc_ZeroDivisionError, e.what() ); } <\/code><\/pre>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0432\u0435\u0441\u0442\u0438 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 C++ \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438 \u0431\u0443\u0434\u0443\u0442 \u043a\u0438\u0434\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u0438\u043c\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\u043c\u0438:  <\/p>\n<pre><code class=\"cpp\">double divide( double a, double b ) {     if( abs( b ) &lt; numeric_limits&lt;double&gt;::epsilon() )         throw zero_division_error();     return a \/ b; }  double to_num( const char* val ) {     double res;     if( !val || !sscanf( val, &quot;%LG&quot;, &res ) )         throw value_error();     return res; }  void test( bool val ) {     if( !val )         throw error( &quot;Test failure.&quot;, &quot;test&quot; ); } <\/code><\/pre>\n<p>  \u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0438 \u043d\u0435\u0442, \u044d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0435 \u0445\u0443\u0436\u0435 \u043b\u044e\u0431\u044b\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0438 \u043a\u0438\u0434\u0430\u044e\u0442 \u0440\u043e\u0432\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0430\u0434\u043e.<br \/>  \u041e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0438\u0445:  <\/p>\n<pre><code class=\"cpp\">... BOOST_PYTHON_MODULE( python_module ) {     register_exception_translator&lt;error&gt;( translate_error );     register_exception_translator&lt;value_error&gt;( translate_value_error );     register_exception_translator&lt;zero_division_error&gt;( translate_zero_division_error );      def( &quot;divide&quot;,  divide, args( &quot;a&quot;, &quot;b&quot; ) );     def( &quot;to_num&quot;,  to_num, args( &quot;val&quot; ) );     def( &quot;test&quot;,    test,   args( &quot;val&quot; ) ); } ... <\/code><\/pre>\n<p>  \u041d\u0443 \u0447\u0442\u043e \u0436, \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0430\u0448 \u043c\u043e\u0434\u0443\u043b\u044c, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c <b>import python_module<\/b>, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0448\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f (\u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 Python 3.x):  <\/p>\n<pre><code class=\"python\">import python_module as pm  try:     res = pm.divide( 1, 0 ) except ZeroDivisionError:     print( &quot;ZeroDivisionError - OK&quot; ) except Exception as e:     print( &quot;Expected ZeroDivisionError, but exception of type '{t}' with text: '{e}'&quot;.format(t=type(e),e=e) ) else:     print( &quot;Expected ZeroDivisionError, but no exception raised! Result: {r}&quot;.format(r=res) )  try:     res = pm.to_num( 'qwe' ) except ValueError:     print( &quot;ValueError - OK&quot; ) except Exception as e:     print( &quot;Expected ValueError, but exception of type '{t}' with text: '{e}'&quot;.format(t=type(e),e=e) ) else:     print( &quot;Expected ValueError, but no exception raised! Result: {r}&quot;.format(r=res) )  try:     res = pm.test( False ) except Exception as e:     if type(e) is Exception:         print( &quot;Exception - OK&quot; )     else:         print( &quot;Exception of type '{t}', expected type 'Exception', message: '{e}'&quot;.format(t=type(e),e=e) ) else:     print( &quot;Expected Exception, but no exception raised! Result: {r}&quot;.format(r=res) ) <\/code><\/pre>\n<p>  \u0412\u044b\u0432\u043e\u0434 \u0441\u043a\u0440\u0438\u043f\u0442\u0430:<br \/>  ZeroDivisionError \u2014 OK<br \/>  ValueError \u2014 OK<br \/>  Exception \u2014 OK<br \/>  \u041f\u043e\u043a\u0430 \u0432\u0441\u0451 \u0445\u043e\u0440\u043e\u0448\u043e. \u041f\u043e\u0435\u0445\u0430\u043b\u0438 \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443.<\/p>\n<h4>\u041f\u0440\u0438\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u043f\u0443\u0442\u0438 \u0438\u0437 Python \u0432 C++<\/h4>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u044b\u0434\u0435\u043b\u0438\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0442\u0438\u043f\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <b>error_types<\/b>. \u041c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f Python \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 <b>python_module<\/b>.<br \/>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0432\u0435\u0434\u0451\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 C++ \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u043c \u043b\u043e\u0432\u0438\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u0437 Python, \u043d\u0430\u0437\u043e\u0432\u0451\u043c \u0435\u0433\u043e <b>catch_exceptions<\/b>.<br \/>  \u0412\u0441\u0451 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e, \u044d\u0442\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043d\u0430\u0448 \u043c\u043e\u0434\u0443\u043b\u044c \u0447\u0435\u0440\u0435\u0437 import(\u00abpython_module\u00bb), \u043f\u043e\u0442\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u043c\u043e\u0434\u0443\u043b\u044f \u0447\u0435\u0440\u0435\u0437 attr(\u00abdivide\u00bb), attr(\u00abto_num\u00bb), attr(\u00abtest\u00bb). \u0411\u0443\u0434\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u0445, \u043e\u043d\u0438 \u043f\u043e\u0440\u043e\u0434\u044f\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 C++ \u043a\u043e\u0434\u0430, \u043f\u0440\u043e\u0439\u0434\u0443\u0442 \u0432 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 Python \u0438 \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u044f\u0442\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 C++, \u0432\u044b\u0437\u0432\u0430\u0432 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <b>error_already_set<\/b> \u2014 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Boost.Python \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u043a\u0430\u043a \u0440\u0430\u0437 \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432.<\/p>\n<p>  \u0421\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0438\u043f\u0430 <b>error_already_set<\/b>, \u0432\u0430\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0439\u043c\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435. \u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0442\u0430\u043a\u043e\u0433\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cpp\">catch( error_already_set const& ) {     PyObject *exc, *val, *tb;     PyErr_Fetch( &exc, &val, &tb );     PyErr_NormalizeException( &exc, &val, &tb );      handle&lt;&gt; hexc(exc), hval( allow_null( val ) ), htb( allow_null( tb ) );      throw error( extract&lt;string&gt;( !hval ? str( hexc ) : str( hval ) ) ); } <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u0442\u0438\u043f\u0430, \u043d\u043e \u0445\u043e\u0442\u044f \u0431\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0442\u0435\u043a\u0441\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u041d\u043e \u043d\u0430\u043c \u0432\u0435\u0434\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0442\u0438\u043f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e exc, \u0441\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 val \u0438 \u0434\u0430\u0436\u0435 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u043e \u0441\u0442\u0435\u043a\u043e\u043c \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u0434\u0448\u0435\u0433\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 tb. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u0434\u0448\u0435\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432 zero_division_error \u0438 value_error, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0448\u043b\u043e ZeroDivisionError \u0438\u043b\u0438 ValueError \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p>  \u0421\u0442\u043e\u043f! \u041d\u0435 \u0432\u0441\u0435\u043c \u0432\u0441\u0451 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u043e\u0447\u0435\u043c\u0443 \u0432\u0441\u0451 PyObject*, \u043e\u0442\u043a\u0443\u0434\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 C-API \u0435\u0441\u043b\u0438 \u0432 \u0421\u0438 \u0438\u0445 \u043d\u0435\u0442, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435.<br \/>  \u0414\u0430, \u0432 \u0447\u0438\u0441\u0442\u043e\u043c \u0421\u0438 \u043d\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439, \u0437\u0430\u0442\u043e \u0432 Python \u043e\u043d\u0438 \u0435\u0441\u0442\u044c \u0438 \u0435\u0433\u043e API \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0442\u044f\u043d\u0443\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u0434\u0448\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438. \u0412 Python C-API \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0442\u0438\u043f\u044b, \u0434\u0430 \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0451, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 PyObject*, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 E \u0442\u0438\u043f\u0430 T \u2014 \u044d\u0442\u043e \u043f\u0430\u0440\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0442\u0438\u043f\u0430 PyObject*, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a \u044d\u0442\u043e\u043c\u0443 \u0435\u0449\u0451 \u0438 PyObject* \u0434\u043b\u044f traceback \u2014 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u043e\u0433\u043e \u0441\u0442\u0435\u043a\u0430, \u0433\u0434\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<br \/>  \u0412\u044b\u0442\u044f\u043d\u0443\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u0434\u0448\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <a href=\"http:\/\/docs.python.org\/3\/c-api\/exceptions.html?highlight=pyerr_fetch#PyErr_Fetch\">PyErr_Fetch<\/a>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c (\u0435\u0441\u043b\u0438 \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0432 \u0432\u0438\u0434\u0435 tuple) \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <a href=\"http:\/\/docs.python.org\/3\/c-api\/exceptions.html?highlight=pyerr_fetch#PyErr_NormalizeException\">PyErr_NormalizeException<\/a>.<br \/>  \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u043f\u0430\u0440\u044b \u044d\u0442\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043c\u044b \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0442\u0440\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 PyObject*, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e: \u043a\u043b\u0430\u0441\u0441 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 (\u043e\u0431\u044a\u0435\u043a\u0442) \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u0441\u0442\u0435\u043a (traceback) \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0439 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043a\u0443\u0434\u0430 \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 Boost.Python, \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c PyObject* \u0432 boost::python::<b>handle<\/b>&lt;&gt;, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c \u0441 \u043b\u044e\u0431\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Boost.Python, \u043d\u0430\u043c \u043a\u0430\u043a \u0440\u0430\u0437 \u043d\u0443\u0436\u0435\u043d boost::python::<b>str<\/b>. \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0430\u043d\u0430\u043b\u043e\u0433\u0443 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u0438\u0442\u043e\u043d\u0430 \u0432 Boost.Python \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0442\u044f\u043d\u0443\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0440\u043e\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 std::string \u044f\u0437\u044b\u043a\u0430 C++. \u041f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0442\u044f\u043d\u0443\u0442\u044c \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 const char*.<\/p>\n<p>  \u0421 \u043f\u0435\u0440\u0432\u044b\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0432\u0441\u0451 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043e\u043d\u0438 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u043a \u0441\u0442\u0440\u043e\u043a\u0435, \u0430 \u0432\u043e\u0442 \u0441 traceback \u0435\u0449\u0451 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u043a \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0432\u0438\u0434\u0443. \u041f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u043e\u0434\u0443\u043b\u044f <b>traceback<\/b>, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u043d\u0430\u0448\u0438 \u0442\u0440\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <b>format_exception<\/b>. \u0424\u0443\u043d\u043a\u0446\u0438\u044f traceback.format_exception( exc, val, tb ) \u0432\u0435\u0440\u043d\u0451\u0442 \u043d\u0430\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0442\u0440\u043e\u043a \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e <b>list <\/b>\u044f\u0437\u044b\u043a\u0430 Python, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0436\u043e\u0439\u043d\u0438\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u0443 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0442\u043e\u043b\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443. <br \/>  \u041d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 C++, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Boost.Python, \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cpp\">    ...     format_exception = import( &quot;traceback&quot; ).attr( &quot;format_exception&quot; );     return extract&lt;string&gt;( str( &quot;&quot; ).join( format_exception( exc, val, tb ) ) ); } <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0437 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043e\u0434\u043d\u0430\u043a\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u044b\u0437\u043e\u0432 import() \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043a \u043d\u0435\u0434\u0435\u0448\u0451\u0432\u043e\u043c\u0443 \u0432\u044b\u0437\u043e\u0432\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0439 \u0438\u0437 import( \u00abtraceback\u00bb ).attr( \u00abformat_exception\u00bb ) \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 object, \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 import(\u00abpython_module\u00bb). \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0442\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0433\u0434\u0435-\u0442\u043e \u043c\u0435\u0436\u0434\u0443 Py_Initialize() \u0438 Py_Finalize(), \u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043b\u0435\u0439 \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u0430 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443 \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442.<\/p>\n<h4>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 Python API \u0447\u0435\u0440\u0435\u0437 \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d<\/h4>\n<p>  \u0418\u0442\u0430\u043a, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u0432\u0435\u0434\u0451\u043c \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d, \u044d\u0442\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442 \u043a\u043e\u0434 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u043e\u043c, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0432\u0441\u0451 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c:  <\/p>\n<pre><code class=\"cpp\">class python_interpreter { public:     static double divide( double, double );     static double to_num( string const& );     static void   test( bool );      static string format_error( handle&lt;&gt; const&, handle&lt;&gt; const&, handle&lt;&gt; const& );  private:     object m_python_module;     object m_format_exception;      python_interpreter();     ~python_interpreter();      static python_interpreter& instance();      object& python_module();     string  format_error( object const&, object const&, object const& ); }; <\/code><\/pre>\n<p>  \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u043e\u043c, \u0430 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0437\u0430\u0447\u0438\u0449\u0430\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u0438 \u0434\u0435-\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u043e\u043c, \u043c\u0435\u0442\u043e\u0434\u044b python_module \u0438 format_error \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u0430\u0436\u0434\u044b:  <\/p>\n<pre><code class=\"cpp\">python_interpreter::python_interpreter() {     Py_Initialize(); }  python_interpreter::~python_interpreter() {     m_python_module = object();     m_format_exception = object();      Py_Finalize(); }  double python_interpreter::divide( double a, double b ) {     return extract&lt;double&gt;( instance().python_module().attr(&quot;divide&quot;)( a, b ) ); }  double python_interpreter::to_num( string const& val ) {     return extract&lt;double&gt;( instance().python_module().attr(&quot;to_num&quot;)( val ) ); }  void python_interpreter::test( bool val ) {     instance().python_module().attr(&quot;test&quot;)( val ); }  string python_interpreter::format_error( handle&lt;&gt; const& exc, handle&lt;&gt; const& msg, handle&lt;&gt; const& tb ) {     return instance().format_error( object(exc), object(msg), object(tb) ); }  python_interpreter& python_interpreter::instance() {     static python_interpreter single;     return single; }  object& python_interpreter::python_module() {     if( m_python_module.is_none() )         m_python_module = import( &quot;python_module&quot; );     return m_python_module; }  string python_interpreter::format_error( object const& exc, object const& val, object const& tb ) {     if( m_format_exception.is_none() )         m_format_exception = import( &quot;traceback&quot; ).attr( &quot;format_exception&quot; );     return extract&lt;string&gt;( str( &quot;&quot; ).join( m_format_exception( exc, val, tb ) ) ); } <\/code><\/pre>\n<p>  \u0418\u0442\u043e\u0433\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u044b\u0439 \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 C++, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u0433\u043e Python \u043a\u0430\u043a \u043c\u043e\u0449\u043d\u044b\u0439 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0441 \u043a\u0443\u0447\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a.<br \/>  \u041f\u043e\u0440\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430\u0448 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439!<\/p>\n<h4>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 Python \u0432 C++<\/h4>\n<p>  \u0417\u0430\u0432\u0435\u0434\u0451\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:  <\/p>\n<pre><code class=\"cpp\">void rethrow_python_exception() {     PyObject *exc, *val, *tb;     PyErr_Fetch( &exc, &val, &tb );     PyErr_NormalizeException( &exc, &val, &tb );      handle&lt;&gt; hexc(exc), hval( allow_null( val ) ), htb( allow_null( tb ) );      string message, details;     message = extract&lt;string&gt;( !hval ? str( hexc ) : str( hval ) );     details = !tb ? extract&lt;string&gt;( str( hexc ) ) : python_interpreter::format_error( hexc, hval, htb );      if( PyObject_IsSubclass( exc, PyExc_ZeroDivisionError ) )         throw zero_division_error( message, details );     else if( PyObject_IsSubclass( exc, PyExc_ValueError ) )         throw value_error( message, details );     else         throw error( message, details ); } <\/code><\/pre>\n<p>  \u0422\u043e\u0433\u0434\u0430 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0441\u0432\u0435\u0434\u0451\u0442\u0441\u044f \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0445\u0435\u043c\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043a\u0430\u043a \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f divide:  <\/p>\n<pre><code class=\"cpp\">        try         {             try             {                 python_interpreter::divide( 1, 0 );             }             catch( error_already_set const& )             {                 rethrow_python_exception();             }         }         catch( error const& e )         {             output_error( e );         } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c output_error \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u043e\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cpp\">void output_error( error const& e ) {     cerr &lt;&lt; &quot;\\nError type: &quot; &lt;&lt; e.type() &lt;&lt; &quot;\\nMessage: &quot; &lt;&lt; e.get_message() &lt;&lt; &quot;\\nDetails: &quot; &lt;&lt; e.get_details() &lt;&lt; endl; } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043a\u0430\u043a \u0440\u0430\u0437 \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u043b\u0441\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 type() \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0437\u0430\u0432\u0435\u043b\u0438 \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 error.<\/p>\n<p>  \u0417\u0430\u0432\u043e\u0434\u0438\u043c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0441\u0435\u043a\u0446\u0438\u0438 \u0434\u043b\u044f to_num \u0438 \u0434\u043b\u044f test, \u0430 \u0435\u0449\u0451 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0447\u0442\u043e \u043f\u0440\u0438\u0434\u0451\u0442 \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432 Python \u0441\u0442\u0440\u043e\u043a\u0443 \u00ab1 \/ 0\u00bb \u0447\u0435\u0440\u0435\u0437 exec:  <\/p>\n<pre><code class=\"cpp\">        try         {             try             {                 exec( &quot;1 \/ 0&quot; );             }             catch( error_already_set const& )             {                 rethrow_python_exception();             }         }         catch( error const& e )         {             output_error( e );         } <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u2026<br \/>  \u0412\u044b\u0432\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0438\u043c:<\/p>\n<p>  Error type: zero_division_error<br \/>  Message: Division by zero!<br \/>  Details: &lt;class &#8216;ZeroDivisionError&#8217;&gt;<\/p>\n<p>  Error type: value_error<br \/>  Message: Inappropriate value!<br \/>  Details: &lt;class &#8216;ValueError&#8217;&gt;<\/p>\n<p>  Error type: error<br \/>  Message: Test failure.<br \/>  Details: &lt;class &#8216;Exception&#8217;&gt;<\/p>\n<p>  Error type: zero_division_error<br \/>  Message: division by zero<br \/>  Details: Traceback (most recent call last):<br \/>   File &quot;&quot;, line 1, in ZeroDivisionError: division by zero<\/p>\n<h4>\u042d\u043f\u0438\u043b\u043e\u0433<\/h4>\n<p>  \u0418\u0442\u043e\u0433\u043e: \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0432\u0437\u0430\u0438\u043c\u043d\u043e\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 Python \u0432 C++ \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e.<br \/>  \u041c\u0438\u043d\u0443\u0441 \u0437\u0430\u043c\u0435\u0442\u0435\u043d \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u2014 \u044d\u0442\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0421++ \u043a\u043b\u0430\u0441\u0441 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u0437 Python, \u0440\u0430\u0432\u043d\u043e \u043a\u0430\u043a \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442. \u0415\u0441\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u00ab\u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u0435\u0439\u00bb \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u043e\u0431\u0451\u0440\u0442\u043a\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 C++ \u0434\u043b\u044f Python, \u043d\u043e \u044d\u0442\u043e \u0432\u0441\u0451 \u0442\u0430\u043a \u0436\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432 \u0441\u0432\u043e\u0451\u043c \u044f\u0437\u044b\u043a\u0435.<br \/>  \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0432 C++, \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u0437\u0430\u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u0435 \u0430\u043d\u0430\u043b\u043e\u0433 \u0432 Python \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c .py \u043c\u043e\u0434\u0443\u043b\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <a href=\"http:\/\/docs.python.org\/3\/c-api\/exceptions.html?highlight=pyerr_newexception#PyErr_NewException\">PyErr_NewException<\/a>, \u0430 \u0437\u0430\u0442\u0435\u043c \u0433\u0434\u0435-\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u043e \u0438 \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438 \u043a\u043e\u0434\u0443.<br \/>  \u041d\u0435 \u0437\u043d\u0430\u044e \u043a\u0430\u043a \u0432\u044b, \u0430 \u044f \u0441 \u043d\u0435\u0442\u0435\u0440\u043f\u0435\u043d\u0438\u0435\u043c \u0436\u0434\u0443, \u043a\u043e\u0433\u0434\u0430 Boost.Python \u043e\u0431\u0437\u0430\u0432\u0435\u0434\u0451\u0442\u0441\u044f \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u044b\u043c \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0442\u043e\u0440\u043e\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439, \u0438\u043b\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u043c boost::python::bases \u0434\u043b\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u0451\u0440\u0442\u043a\u0438 \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 Python. \u0412 \u0446\u0435\u043b\u043e\u043c Boost.Python \u043e\u0442\u043b\u0438\u0447\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043d\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u0430\u0441\u043f\u0435\u043a\u0442 \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0433\u0435\u043c\u043c\u043e\u0440\u043e\u044f \u043f\u0440\u0438 \u0440\u0430\u0437\u0431\u043e\u0440\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 Python \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 C++. \u0422\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u044f \u0432 Python \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0442\u043e\u0440\u0430 register_exception_translator&lt;E,F&gt;(F) \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043f\u043e\u043b\u043d\u0435 \u0443\u0434\u0430\u0447\u043d\u043e\u0439 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 A \u0432 C++, \u0432 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 B \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 Python, \u043d\u043e \u0445\u043e\u0442\u044f \u0431\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438.<br \/>  \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 error_already_set \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432\u044b\u0448\u0435, \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0430\u043c\u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0441\u0435\u0431\u0435 \u0440\u0435\u0446\u0435\u043f\u0442\u0443\u0440\u0443 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <a href=\"http:\/\/docs.python.org\/3\/c-api\/exceptions.html?highlight=pyerr_newexception#exception-handling\">Python API \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 Python<\/a>.<\/p>\n<p>  \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f <a href=\"http:\/\/www.2shared.com\/file\/PQ58Qabk\/throw2py.html\">\u0437\u0434\u0435\u0441\u044c (~223 KB)<\/a>. \u041f\u0440\u043e\u0435\u043a\u0442 MSVS v11 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 \u0441\u0431\u043e\u0440\u043a\u0443 \u0441 Boost 1.52 \u0438 Python 3.3 x64.<\/p>\n<h4>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/h4>\n<p>  <a href=\"http:\/\/wiki.python.org\/moin\/boost.python\/EmbeddingPython#Extracting_Python_Exceptions\">PyWiki \u2014 \u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 C++<\/a><br \/>  <a href=\"http:\/\/docs.python.org\/3\/c-api\/exceptions.html?highlight=pyerr_newexception#exception-handling\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 Python C-API<\/a><br \/>  <a href=\"http:\/\/www.boost.org\/doc\/libs\/1_43_0\/libs\/python\/doc\/v2\/exception_translator.html\">\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0442\u043e\u0440\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 C++ \u0432 Python<\/a>    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/169639\/\"> http:\/\/habrahabr.ru\/post\/169639\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0412 \u044d\u0442\u043e\u0439 \u0433\u043b\u0430\u0432\u0435 \u0441\u043a\u0430\u0437\u0430 \u043f\u0440\u043e \u0434\u0440\u0443\u0436\u0431\u0443 C++ \u0438 Python \u0431\u0443\u0434\u0435\u0442 \u043d\u0430 \u0443\u0434\u0438\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u0430\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Boost.Python. \u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0442\u0443\u0434\u0430 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0441\u0443\u0442\u0438 \u0441\u043b\u0430\u0431\u044b\u043c \u043c\u0435\u0441\u0442\u043e\u043c \u0434\u0430\u043d\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0411\u0443\u0434\u0435\u043c \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0440\u043e\u0434\u043d\u044b\u043c API \u044f\u0437\u044b\u043a\u0430 Python, \u0430 \u0433\u0434\u0435 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Boost.Python.<br \/>  \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 Boost.Python \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u0437 C++ \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 Python \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e RuntimeError, \u0430 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0438\u0437 Python \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 C++ \u0442\u0438\u043f\u0430 error_already_set, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u00ab\u0442\u0435\u0431\u0435 \u0447\u0442\u043e-\u0442\u043e \u043f\u0440\u0438\u043b\u0435\u0442\u0435\u043b\u043e, \u0441\u0445\u043e\u0434\u0438 \u0441\u0430\u043c \u043f\u043e\u0447\u0438\u0442\u0430\u0439 \u0447\u0442\u043e \u0442\u0430\u043c\u00bb. \u0418 \u0432\u043e\u0442 \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u043c \u043a\u0430\u043a \u0440\u0430\u0437 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043b\u0438\u0448\u043d\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c C-API \u044f\u0437\u044b\u043a\u0430 Python, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e \u043b\u043e\u0433\u0438\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<br \/>  \u041a \u0447\u0435\u043c\u0443 \u0442\u0430\u043a\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438? \u2014 \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 Python, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 C++, \u043a\u0440\u043e\u043c\u0435 \u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u0435\u0433\u043e \u0442\u0438\u043f\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0435\u0449\u0451 \u0438 traceback \u2014 \u0441\u0442\u0435\u043a \u0434\u043e \u043c\u0435\u0441\u0442\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 std::exception \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e stacktrace, \u0430 \u0437\u0430\u043e\u0434\u043d\u043e \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0442\u0443\u0434\u0430 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 C++ \u0432 \u043a\u043b\u0430\u0441\u0441\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 Python.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-169639","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/169639","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=169639"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/169639\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=169639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=169639"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=169639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}