visual c++ - Environment passed in from Python is different in release and debug modes -
i'm building python plugin, using visual studios 2012, , generating 64 bit code. in addition, we're using bloomberg library blpapi. in python module loads our plugin, set environment variable before loading; code looks like:
import os import imp directory = os.path.dirname(os.path.realpath(__file__)) os.environ['__python_sys_path_for_prog__'] = directory fp, pathname, description = imp.find_module('pyprog', [ directory ]) if fp not none: try: _mod = imp.load_module('pyprog', fp, pathname, description) finally: fp.close() there file pyprog.pyd in path, , works fine. if import blpapi before, however, works in debug mode, not in release: function initpyprog basically:
pymodinit_func initpyprog() { try { char const* syspath = getenv( "__python_sys_path_for_prog__" ); std::string path = syspath != null ? syspath : ""; bool verbose = getenv( "__python_prog_verbose__" ) != null; if ( path.empty() ) { // ... } // ... } catch ( std::exception const& error ) { pyerr_setstring( pyexc_importerror, error.what() ); } catch ( ... ) { if ( pyerr_occurred() == null ) { pyerr_setstring( pyexc_importerror, "unknown error initializing pyprog" ); } } } in release mode, after loading blpapi, go path.empty() branch; in debug mode, no, , if don't load blpapi, no.
if set breakpoint @ entry of program, , @ environment in debugger, __python_sys_path_for_prog__ not present in error case; in debug build. , if add dllmain function, dumps environment file when dll attached, missing variable __python_sys_path_for_prog__ difference. (we don't set __python_prog_verbose__.)
also, there no static variables have constructors in module. (it's small module, nothing load other dlls real work. except doesn't far.)
has else seen similar problems? , should start looking? given error takes place before of code executes: there bug in visual studios? (but if so, why trigger after loading blpapi? related load address in way?)
Comments
Post a Comment