[pywin32-checkins] pywin32/win32/src PythonService.cpp,1.25,1.26
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2008-12-28 10:43:49
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv24180 Modified Files: PythonService.cpp Log Message: Use py3k-friendly PYWIN_MODULE_* macros Index: PythonService.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PythonService.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** PythonService.cpp 13 Nov 2008 11:11:58 -0000 1.25 --- PythonService.cpp 28 Dec 2008 10:43:45 -0000 1.26 *************** *** 542,562 **** ! #define ADD_CONSTANT(tok) if (PyModule_AddIntConstant(module, #tok, tok) == -1) RETURN_ERROR; ! extern "C" __declspec(dllexport) void ! initservicemanager(void) { HMODULE advapi32_module; - PyObject *dict, *module; - module = Py_InitModule("servicemanager", servicemanager_functions); - #define RETURN_ERROR return // towards py3k - if (!module) /* Eeek - some serious error! */ - return; - dict = PyModule_GetDict(module); - if (!dict) return; /* Another serious error!*/ - servicemanager_startup_error = PyErr_NewException("servicemanager.startup_error", NULL, NULL); if (servicemanager_startup_error == NULL) ! RETURN_ERROR; PyDict_SetItemString(dict, "startup_error", servicemanager_startup_error); --- 542,555 ---- ! #define ADD_CONSTANT(tok) if (PyModule_AddIntConstant(module, #tok, tok) == -1) PYWIN_MODULE_INIT_RETURN_ERROR; ! PYWIN_MODULE_INIT_FUNC(servicemanager) { + PYWIN_MODULE_INIT_PREPARE(servicemanager, servicemanager_functions, + "A module that interfaces with the Windows Service Control Manager."); HMODULE advapi32_module; servicemanager_startup_error = PyErr_NewException("servicemanager.startup_error", NULL, NULL); if (servicemanager_startup_error == NULL) ! PYWIN_MODULE_INIT_RETURN_ERROR; PyDict_SetItemString(dict, "startup_error", servicemanager_startup_error); *************** *** 577,581 **** ADD_CONSTANT(EVENTLOG_AUDIT_SUCCESS); ADD_CONSTANT(EVENTLOG_AUDIT_FAILURE); - PyWinGlobals_Ensure(); // Check if we can use the newer control handler registration function --- 570,573 ---- *************** *** 594,597 **** --- 586,591 ---- } } + + PYWIN_MODULE_INIT_RETURN_SUCCESS; } *************** *** 608,612 **** // This, however, shouldnt be a problem, as Python itself // knows how to get the .EXE name when it needs. ! Py_SetProgramName(__argv[0]); #ifdef BUILD_FREEZE PyInitFrozenExtensions(); --- 602,615 ---- // This, however, shouldnt be a problem, as Python itself // knows how to get the .EXE name when it needs. ! int pyargc; ! #if (PY_VERSION_HEX < 0x03000000) ! pyargc = __argc; ! char **pyargv = __argv; ! #else ! WCHAR **pyargv; ! pyargv = CommandLineToArgvW(GetCommandLineW(), &pyargc); ! #endif ! Py_SetProgramName(pyargv[0]); ! #ifdef BUILD_FREEZE PyInitFrozenExtensions(); *************** *** 618,624 **** // Ensure we are set for threading. PyEval_InitThreads(); ! PySys_SetArgv(__argc, __argv); ! initservicemanager(); } --- 621,631 ---- // Ensure we are set for threading. PyEval_InitThreads(); ! PySys_SetArgv(pyargc, pyargv); ! #if (PY_VERSION_HEX < 0x03000000) initservicemanager(); + #else + PyInit_servicemanager(); + LocalFree(pyargv); + #endif } |