Update of /cvsroot/pywin32/pywin32/win32/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9817/win32/src
Modified Files:
PySECURITY_DESCRIPTOR.cpp PySID.cpp PyWinObjects.h
PyWinTypesmodule.cpp PythonService.cpp _win32sysloader.cpp
_winxptheme.i mmapfilemodule.cpp win2krasmodule.cpp
win32event.i win32file_comm.cpp win32helpmodule.cpp
win32process.i win32service.i win32trace.cpp
Log Message:
Yet more TCHAR/64bit and other misc changes from py3k branch.
Index: win32process.i
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32process.i,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** win32process.i 13 Nov 2008 04:04:51 -0000 1.34
--- win32process.i 13 Nov 2008 11:11:58 -0000 1.35
***************
*** 191,205 ****
return gethandle(pO->m_obStdErr, pO->m_startupinfo.hStdError);
// @prop string/None|lpDesktop|
! if (strcmp("lpDesktop", name)==0) {
! PyObject *rc = pO->m_obDesktop ? pO->m_obDesktop : Py_None;
! Py_INCREF(rc);
! return rc;
! }
// @prop string/None|lpTitle|
! if (strcmp("lpTitle", name)==0) {
! PyObject *rc = pO->m_obTitle ? pO->m_obTitle : Py_None;
! Py_INCREF(rc);
! return rc;
! }
return PyMember_Get((char *)self, memberlist, name);
}
--- 191,199 ----
return gethandle(pO->m_obStdErr, pO->m_startupinfo.hStdError);
// @prop string/None|lpDesktop|
! if (strcmp("lpDesktop", name)==0)
! return PyWinObject_FromTCHAR(pO->m_startupinfo.lpDesktop);
// @prop string/None|lpTitle|
! if (strcmp("lpTitle", name)==0)
! return PyWinObject_FromTCHAR(pO->m_startupinfo.lpTitle);
return PyMember_Get((char *)self, memberlist, name);
}
***************
*** 238,258 ****
if (strcmp("lpDesktop", name)==0) {
! if (PyWinObject_AsTCHAR(v, &pO->m_startupinfo.lpDesktop, TRUE)) {
! Py_XDECREF(pO->m_obDesktop);
! pO->m_obDesktop = v;
! Py_INCREF(v);
! return 0;
! } else
return -1;
! }
if (strcmp("lpTitle", name)==0) {
! if (PyWinObject_AsTCHAR(v, &pO->m_startupinfo.lpTitle, TRUE)) {
! Py_XDECREF(pO->m_obTitle);
! pO->m_obTitle = v;
! Py_INCREF(v);
! return 0;
! } else
return -1;
! }
return PyMember_Set((char *)self, memberlist, name, v);
}
--- 232,251 ----
if (strcmp("lpDesktop", name)==0) {
! TCHAR *val;
! if (!PyWinObject_AsTCHAR(v, &val, TRUE))
return -1;
! PyWinObject_FreeTCHAR(pO->m_startupinfo.lpDesktop);
! pO->m_startupinfo.lpDesktop = val;
! return 0;
! }
!
if (strcmp("lpTitle", name)==0) {
! TCHAR *val;
! if (!PyWinObject_AsTCHAR(v, &val, TRUE))
return -1;
! PyWinObject_FreeTCHAR(pO->m_startupinfo.lpTitle);
! pO->m_startupinfo.lpTitle=val;
! return 0;
! }
return PyMember_Set((char *)self, memberlist, name, v);
}
Index: win32trace.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32trace.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** win32trace.cpp 30 Oct 2008 02:38:55 -0000 1.15
--- win32trace.cpp 13 Nov 2008 11:11:58 -0000 1.16
***************
*** 41,48 ****
const unsigned long BUFFER_SIZE = 0x20000; // Includes size integer.
! const char *MAP_OBJECT_NAME = "Global\\PythonTraceOutputMapping";
! const char *MUTEX_OBJECT_NAME = "Global\\PythonTraceOutputMutex";
! const char *EVENT_OBJECT_NAME = "Global\\PythonTraceOutputEvent";
! const char *EVENT_EMPTY_OBJECT_NAME = "Global\\PythonTraceOutputEmptyEvent";
// Global\\ etc goodness:
--- 41,48 ----
const unsigned long BUFFER_SIZE = 0x20000; // Includes size integer.
! const TCHAR *MAP_OBJECT_NAME = _T("Global\\PythonTraceOutputMapping");
! const TCHAR *MUTEX_OBJECT_NAME = _T("Global\\PythonTraceOutputMutex");
! const TCHAR *EVENT_OBJECT_NAME = _T("Global\\PythonTraceOutputEvent");
! const TCHAR *EVENT_EMPTY_OBJECT_NAME = _T("Global\\PythonTraceOutputEmptyEvent");
// Global\\ etc goodness:
***************
*** 72,79 ****
BOOL use_global_namespace = FALSE;
! static const char *FixupObjectName(const char *global_name)
{
if (!use_global_namespace)
! return strchr(global_name, '\\')+1;
// global prefix is ok.
return global_name;
--- 72,79 ----
BOOL use_global_namespace = FALSE;
! static const TCHAR *FixupObjectName(const TCHAR *global_name)
{
if (!use_global_namespace)
! return _tcschr(global_name, '\\')+1;
// global prefix is ok.
return global_name;
***************
*** 175,179 ****
static PyMethodDef PyTraceObject_methods[] = {
! {"blockingread", PyTraceObject_blockingread, METH_VARARGS}, // @pytmeth blockingread
{"read", PyTraceObject_read, METH_VARARGS }, // @pymeth read|
{"write", PyTraceObject_write, METH_VARARGS }, // @pymeth write|
--- 175,179 ----
static PyMethodDef PyTraceObject_methods[] = {
! {"blockingread", PyTraceObject_blockingread, METH_VARARGS}, // @pymeth blockingread
{"read", PyTraceObject_read, METH_VARARGS }, // @pymeth read|
{"write", PyTraceObject_write, METH_VARARGS }, // @pymeth write|
***************
*** 611,619 ****
PyObject *dict;
PyObject* pModMe = Py_InitModule("win32trace", win32trace_functions);
if (!pModMe) return;
dict = PyModule_GetDict(pModMe);
if (!dict) return;
- Py_INCREF(PyWinExc_ApiError);
PyDict_SetItemString(dict, "error", PyWinExc_ApiError);
--- 611,619 ----
PyObject *dict;
PyObject* pModMe = Py_InitModule("win32trace", win32trace_functions);
+ #define RETURN_ERROR return // towards py3k
if (!pModMe) return;
dict = PyModule_GetDict(pModMe);
if (!dict) return;
PyDict_SetItemString(dict, "error", PyWinExc_ApiError);
***************
*** 671,675 ****
if (hMutex==NULL) {
PyWin_SetAPIError("CreateMutex");
! return ;
}
assert (hEvent==NULL);
--- 671,675 ----
if (hMutex==NULL) {
PyWin_SetAPIError("CreateMutex");
! RETURN_ERROR ;
}
assert (hEvent==NULL);
***************
*** 677,681 ****
if (hEvent==NULL) {
PyWin_SetAPIError("CreateEvent");
! return ;
}
assert (hEventEmpty==NULL);
--- 677,681 ----
if (hEvent==NULL) {
PyWin_SetAPIError("CreateEvent");
! RETURN_ERROR;
}
assert (hEventEmpty==NULL);
***************
*** 683,687 ****
if (hEventEmpty==NULL) {
PyWin_SetAPIError("CreateEvent");
! return ;
}
}
--- 683,687 ----
if (hEventEmpty==NULL) {
PyWin_SetAPIError("CreateEvent");
! RETURN_ERROR ;
}
}
Index: PyWinObjects.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinObjects.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** PyWinObjects.h 25 May 2008 00:34:23 -0000 1.14
--- PyWinObjects.h 13 Nov 2008 11:11:58 -0000 1.15
***************
*** 3,55 ****
#define __PYWINTYPES_H__
-
- #ifndef PYWIN_USE_PYUNICODE
-
- class PYWINTYPES_EXPORT PyUnicode : public PyObject
- {
- public:
- BSTR m_bstrValue;
-
- PyUnicode(void);
- PyUnicode(const char *value);
- PyUnicode(const char *value, unsigned int numBytes);
- PyUnicode(const OLECHAR *value);
- PyUnicode(const OLECHAR *value, int numChars);
- PyUnicode(const BSTR value, BOOL takeOwnership=FALSE);
- PyUnicode(PyObject *value);
- ~PyUnicode();
-
- /* Python support */
- int compare(PyObject *ob);
- PyObject * concat(PyObject *ob);
- PyObject * repeat(int count);
- PyObject * item(int index);
- PyObject * slice(int start, int end);
- PyObject * getattr(char *name);
- long hash(void);
- PyObject *asStr(void);
- int print(FILE *fp, int flags);
- PyObject *repr();
- PyObject * upper(void);
- PyObject * lower(void);
-
- static void deallocFunc(PyObject *ob);
- static int compareFunc(PyObject *ob1, PyObject *ob2);
- static long hashFunc(PyObject *ob);
- static PyObject * strFunc(PyObject *ob);
- static int printFunc(PyObject *ob, FILE *fp, int flags);
- static PyObject * reprFunc(PyObject *ob);
- static int lengthFunc(PyObject *ob);
- static PyObject * concatFunc(PyObject *ob1, PyObject *ob2);
- static PyObject * repeatFunc(PyObject *ob1, int count);
- static PyObject * itemFunc(PyObject *ob1, int index);
- static PyObject * sliceFunc(PyObject *ob1, int start, int end);
- static PyObject * getattrFunc(PyObject *ob, char *name);
- static PyObject * upperFunc(PyObject *ob, PyObject *args);
- static PyObject * lowerFunc(PyObject *ob, PyObject *args);
- };
-
- #endif // PYWIN_USE_PYUNICODE
-
#ifndef NO_PYWINTYPES_IID
// NOTE - In general, you should not use "new PyIID", but use the
--- 3,6 ----
***************
*** 190,193 ****
--- 141,145 ----
static int nonzeroFunc(PyObject *ob);
static long hashFunc(PyObject *ob);
+
static PyObject * strFunc(PyObject *ob);
static PyObject * intFunc(PyObject *ob);
Index: win32file_comm.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file_comm.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** win32file_comm.cpp 21 May 2001 12:42:42 -0000 1.5
--- win32file_comm.cpp 13 Nov 2008 11:11:58 -0000 1.6
***************
*** 19,23 ****
PyObject *PyWinObject_FromCOMMTIMEOUTS( COMMTIMEOUTS *p)
{
! return Py_BuildValue("iiiii",
p->ReadIntervalTimeout,
p->ReadTotalTimeoutMultiplier,
--- 19,23 ----
PyObject *PyWinObject_FromCOMMTIMEOUTS( COMMTIMEOUTS *p)
{
! return Py_BuildValue("kkkkk",
p->ReadIntervalTimeout,
p->ReadTotalTimeoutMultiplier,
***************
*** 29,33 ****
BOOL PyWinObject_AsCOMMTIMEOUTS( PyObject *ob, COMMTIMEOUTS *p)
{
! return PyArg_ParseTuple(ob, "iiiii",
&p->ReadIntervalTimeout,
&p->ReadTotalTimeoutMultiplier,
--- 29,33 ----
BOOL PyWinObject_AsCOMMTIMEOUTS( PyObject *ob, COMMTIMEOUTS *p)
{
! return PyArg_ParseTuple(ob, "kkkkk",
&p->ReadIntervalTimeout,
&p->ReadTotalTimeoutMultiplier,
Index: _winxptheme.i
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/_winxptheme.i,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** _winxptheme.i 3 Jun 2007 14:53:07 -0000 1.3
--- _winxptheme.i 13 Nov 2008 11:11:58 -0000 1.4
***************
*** 85,97 ****
}
! %apply long {HTHEME};
! typedef long HTHEME;
!
!
! %apply HWND {long};
! typedef long HWND
! %apply HDC {long};
! typedef long HDC
%typemap(python,ignore) RECT *OUTPUT(RECT temp)
--- 85,96 ----
}
! %apply HANDLE {HTHEME};
! typedef HANDLE HTHEME;
! typedef float HDC;
! %typemap(python, in) HDC{
! if (!PyWinObject_AsHANDLE($source, (HANDLE *)&$target))
! return NULL;
! }
%typemap(python,ignore) RECT *OUTPUT(RECT temp)
Index: win32event.i
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32event.i,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** win32event.i 2 Oct 2008 01:31:28 -0000 1.10
--- win32event.i 13 Nov 2008 11:11:58 -0000 1.11
***************
*** 238,244 ****
DWORD rc;
- // Do a LoadLibrary, as the Ex version does not exist on NT3.x, Win95
// @comm This method will no longer raise a COM E_NOTIMPL exception
! // as it is no longer dynamically loaded.
Py_BEGIN_ALLOW_THREADS
rc = MsgWaitForMultipleObjectsEx(numItems, pItems, dwMilliseconds, dwWakeMask, dwFlags);
--- 238,243 ----
DWORD rc;
// @comm This method will no longer raise a COM E_NOTIMPL exception
! // as it is no longer dynamically loaded.
Py_BEGIN_ALLOW_THREADS
rc = MsgWaitForMultipleObjectsEx(numItems, pItems, dwMilliseconds, dwWakeMask, dwFlags);
***************
*** 254,258 ****
%}
-
// @pyswig <o PyHANDLE>|OpenEvent|Returns a handle of an existing named event object.
PyHANDLE OpenEvent(
--- 253,256 ----
Index: PyWinTypesmodule.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypesmodule.cpp,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -d -r1.44 -r1.45
*** PyWinTypesmodule.cpp 13 Nov 2008 04:04:51 -0000 1.44
--- PyWinTypesmodule.cpp 13 Nov 2008 11:11:58 -0000 1.45
***************
*** 875,878 ****
--- 875,879 ----
// @tupleitem 3|None/int|argerror|The index of the argument in error, or (usually) None or -1
}
+ return 0;
}
Index: PythonService.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PythonService.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** PythonService.cpp 10 Feb 2008 13:34:49 -0000 1.24
--- PythonService.cpp 13 Nov 2008 11:11:58 -0000 1.25
***************
*** 32,36 ****
PYSERVICE_EXPORT BOOL PythonService_PrepareToHostMultiple(const TCHAR *service_name, PyObject *klass);
PYSERVICE_EXPORT BOOL PythonService_StartServiceCtrlDispatcher();
! PYSERVICE_EXPORT int PythonService_main(int argc, char **argv);
TCHAR g_szEventSourceName[MAX_PATH] = _T("Python Service");
--- 32,36 ----
PYSERVICE_EXPORT BOOL PythonService_PrepareToHostMultiple(const TCHAR *service_name, PyObject *klass);
PYSERVICE_EXPORT BOOL PythonService_StartServiceCtrlDispatcher();
! PYSERVICE_EXPORT int PythonService_main(int argc, TCHAR **argv);
TCHAR g_szEventSourceName[MAX_PATH] = _T("Python Service");
***************
*** 121,129 ****
static PY_SERVICE_TABLE_ENTRY *FindPythonServiceEntry(LPCTSTR svcName);
! static PyObject *LoadPythonServiceClass(char *svcInitString);
static PyObject *LoadPythonServiceInstance(PyObject *,
DWORD dwArgc,
LPTSTR *lpszArgv );
! static BOOL LocatePythonServiceClassString( TCHAR *svcName, char *buf, int cchBuf);
--- 121,129 ----
static PY_SERVICE_TABLE_ENTRY *FindPythonServiceEntry(LPCTSTR svcName);
! static PyObject *LoadPythonServiceClass(TCHAR *svcInitString);
static PyObject *LoadPythonServiceInstance(PyObject *,
DWORD dwArgc,
LPTSTR *lpszArgv );
! static BOOL LocatePythonServiceClassString( TCHAR *svcName, TCHAR *buf, int cchBuf);
***************
*** 541,557 ****
};
- static int AddConstant(PyObject *dict, const char *key, long value)
- {
- PyObject *oval = PyInt_FromLong(value);
- if (!oval)
- {
- return 1;
- }
- int rc = PyDict_SetItemString(dict, (char*)key, oval);
- Py_DECREF(oval);
- return rc;
- }
! #define ADD_CONSTANT(tok) AddConstant(dict, #tok, tok)
extern "C" __declspec(dllexport) void
--- 541,546 ----
};
! #define ADD_CONSTANT(tok) if (PyModule_AddIntConstant(module, #tok, tok) == -1) RETURN_ERROR;
extern "C" __declspec(dllexport) void
***************
*** 561,564 ****
--- 550,554 ----
PyObject *dict, *module;
module = Py_InitModule("servicemanager", servicemanager_functions);
+ #define RETURN_ERROR return // towards py3k
if (!module) /* Eeek - some serious error! */
return;
***************
*** 567,571 ****
servicemanager_startup_error = PyErr_NewException("servicemanager.startup_error", NULL, NULL);
! if (servicemanager_startup_error == NULL) return;
PyDict_SetItemString(dict, "startup_error", servicemanager_startup_error);
--- 557,562 ----
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);
***************
*** 835,840 ****
pe = PythonServiceTable;
if (!pe->klass) {
! char svcInitBuf[256];
! LocatePythonServiceClassString(lpszArgv[0], svcInitBuf, sizeof(svcInitBuf));
pe->klass = LoadPythonServiceClass(svcInitBuf);
}
--- 826,831 ----
pe = PythonServiceTable;
if (!pe->klass) {
! TCHAR svcInitBuf[256];
! LocatePythonServiceClassString(lpszArgv[0], svcInitBuf, sizeof(svcInitBuf)/sizeof(svcInitBuf[0]));
pe->klass = LoadPythonServiceClass(svcInitBuf);
}
***************
*** 1042,1046 ****
// the service has stopped, so exit.
//
! int PythonService_main(int argc, char **argv)
{
// Note that we don't know the service name we are hosting yet!
--- 1033,1037 ----
// the service has stopped, so exit.
//
! int PythonService_main(int argc, TCHAR **argv)
{
// Note that we don't know the service name we are hosting yet!
***************
*** 1081,1086 ****
{
#ifndef BUILD_FREEZE
! if ( _stricmp( "register", argv[1]+1 ) == 0 ||
! _stricmp( "install", argv[1]+1 ) == 0 )
{
// Get out of here.
--- 1072,1077 ----
{
#ifndef BUILD_FREEZE
! if ( _tcsicmp( _T("register"), argv[1]+1 ) == 0 ||
! _tcsicmp( _T("install"), argv[1]+1 ) == 0 )
{
// Get out of here.
***************
*** 1088,1092 ****
}
#endif
! if ( _stricmp( "debug", argv[1]+1 ) == 0 ) {
/* Debugging the service. If this EXE has a service name
embedded in it, use it, otherwise insist one is passed on the
--- 1079,1083 ----
}
#endif
! if ( _tcsicmp( _T("debug"), argv[1]+1 ) == 0 ) {
/* Debugging the service. If this EXE has a service name
embedded in it, use it, otherwise insist one is passed on the
***************
*** 1149,1161 ****
// Given the string in form [path\]module.ClassName, return
// an instance of the class
! PyObject *LoadPythonServiceClass(char *svcInitString)
{
! char valueBuf[512];
// Initialize Python
PyService_InitPython();
! strncpy(valueBuf, svcInitString, sizeof(valueBuf));
// Find the last "\\"
! char *sep = strrchr(valueBuf, '\\');
! char *fname;
if (sep) {
*sep = '\0';
--- 1140,1152 ----
// Given the string in form [path\]module.ClassName, return
// an instance of the class
! PyObject *LoadPythonServiceClass(TCHAR *svcInitString)
{
! TCHAR valueBuf[512];
// Initialize Python
PyService_InitPython();
! _tcsncpy(valueBuf, svcInitString, sizeof(valueBuf)/sizeof(valueBuf[0]));
// Find the last "\\"
! TCHAR *sep = _tcsrchr(valueBuf, _T('\\'));
! TCHAR *fname;
if (sep) {
*sep = '\0';
***************
*** 1167,1171 ****
return NULL;
}
! PyObject *obNew = PyString_FromString(valueBuf);
if (obNew==NULL) {
ReportPythonError(PYS_E_NO_MEMORY_FOR_SYS_PATH);
--- 1158,1162 ----
return NULL;
}
! PyObject *obNew = PyWinObject_FromTCHAR(valueBuf);
if (obNew==NULL) {
ReportPythonError(PYS_E_NO_MEMORY_FOR_SYS_PATH);
***************
*** 1178,1182 ****
}
// Find the last "." in the name, and assume it is a module name.
! char *classNamePos = strrchr(fname, '.');
if (classNamePos==NULL) {
ReportError(PYS_E_CANT_LOCATE_MODULE_NAME);
--- 1169,1173 ----
}
// Find the last "." in the name, and assume it is a module name.
! TCHAR *classNamePos = _tcsrchr(fname, _T('.'));
if (classNamePos==NULL) {
ReportError(PYS_E_CANT_LOCATE_MODULE_NAME);
***************
*** 1187,1196 ****
// PyImport_ImportModule("foo.bar") will return 'foo', not bar.
*classNamePos++ = '\0';
! module = PyImport_ImportModule(fname);
if (module==NULL) {
ReportPythonError(E_PYS_NO_MODULE);
return NULL;
}
! PyObject *pyclass = PyObject_GetAttrString(module, classNamePos);
Py_DECREF(module);
if (pyclass==NULL) {
--- 1178,1191 ----
// PyImport_ImportModule("foo.bar") will return 'foo', not bar.
*classNamePos++ = '\0';
! PyObject *obname=PyWinObject_FromTCHAR(fname);
! module = PyImport_Import(obname);
! Py_DECREF(obname);
if (module==NULL) {
ReportPythonError(E_PYS_NO_MODULE);
return NULL;
}
! PyObject *obclassName=PyWinObject_FromTCHAR(classNamePos);
! PyObject *pyclass = PyObject_GetAttr(module, obclassName);
! Py_DECREF(obclassName);
Py_DECREF(module);
if (pyclass==NULL) {
***************
*** 1240,1251 ****
}
! BOOL LocatePythonServiceClassString( TCHAR *svcName, char *buf, int cchBuf)
{
! char keyName[1024];
// If not error loading, and not an empty string
// (NOTE: Embedding a resource to specify the service name is
// deprecated)
! if (LoadStringA(GetModuleHandle(NULL), RESOURCE_SERVICE_NAME, buf, cchBuf)>1)
// Get out of here now!
return TRUE;
--- 1235,1246 ----
}
! BOOL LocatePythonServiceClassString( TCHAR *svcName, TCHAR *buf, int cchBuf)
{
! TCHAR keyName[1024];
// If not error loading, and not an empty string
// (NOTE: Embedding a resource to specify the service name is
// deprecated)
! if (LoadString(GetModuleHandle(NULL), RESOURCE_SERVICE_NAME, buf, cchBuf)>1)
// Get out of here now!
return TRUE;
***************
*** 1253,1264 ****
HKEY key = NULL;
BOOL ok = TRUE;
! wsprintfA(keyName, "System\\CurrentControlSet\\Services\\%S\\PythonClass", svcName);
! if (RegOpenKeyA(HKEY_LOCAL_MACHINE, keyName, &key) != ERROR_SUCCESS) {
ReportAPIError(PYS_E_API_CANT_LOCATE_PYTHON_CLASS);
return FALSE;
}
DWORD dataType;
! DWORD valueBufSize = cchBuf;
! if ((RegQueryValueExA(key, "", 0, &dataType, (LPBYTE)buf, &valueBufSize)!=ERROR_SUCCESS) ||
(dataType != REG_SZ)) {
ReportAPIError(PYS_E_API_CANT_LOCATE_PYTHON_CLASS);
--- 1248,1261 ----
HKEY key = NULL;
BOOL ok = TRUE;
! _sntprintf(keyName, sizeof(keyName)/sizeof(keyName[0]),
! _T("System\\CurrentControlSet\\Services\\%s\\PythonClass"),
! svcName);
! if (RegOpenKey(HKEY_LOCAL_MACHINE, keyName, &key) != ERROR_SUCCESS) {
ReportAPIError(PYS_E_API_CANT_LOCATE_PYTHON_CLASS);
return FALSE;
}
DWORD dataType;
! DWORD valueBufSize = cchBuf * sizeof(TCHAR);
! if ((RegQueryValueEx(key, NULL, 0, &dataType, (LPBYTE)buf, &valueBufSize)!=ERROR_SUCCESS) ||
(dataType != REG_SZ)) {
ReportAPIError(PYS_E_API_CANT_LOCATE_PYTHON_CLASS);
***************
*** 1353,1428 ****
}
- #define GPEM_ERROR(what) {errorMsg = "<Error getting traceback - " ## what ## ">";goto done;}
- static char *GetPythonTraceback(PyObject *exc_tb)
- {
- char *result = NULL;
- char *errorMsg = NULL;
- PyObject *modStringIO = NULL;
- PyObject *modTB = NULL;
- PyObject *obFuncStringIO = NULL;
- PyObject *obStringIO = NULL;
- PyObject *obFuncTB = NULL;
- PyObject *argsTB = NULL;
- PyObject *obResult = NULL;
-
- /* Import the modules we need - cStringIO and traceback */
- modStringIO = PyImport_ImportModule("cStringIO");
- if (modStringIO==NULL) GPEM_ERROR("cant import cStringIO");
- modTB = PyImport_ImportModule("traceback");
- if (modTB==NULL) GPEM_ERROR("cant import traceback");
-
- /* Construct a cStringIO object */
- obFuncStringIO = PyObject_GetAttrString(modStringIO, "StringIO");
- if (obFuncStringIO==NULL) GPEM_ERROR("cant find cStringIO.StringIO");
- obStringIO = PyObject_CallObject(obFuncStringIO, NULL);
- if (obStringIO==NULL) GPEM_ERROR("cStringIO.StringIO() failed");
-
- /* Get the traceback.print_exception function, and call it. */
- obFuncTB = PyObject_GetAttrString(modTB, "print_tb");
- if (obFuncTB==NULL) GPEM_ERROR("cant find traceback.print_tb");
- argsTB = Py_BuildValue("OOO",
- exc_tb ? exc_tb : Py_None,
- Py_None,
- obStringIO);
- if (argsTB==NULL) GPEM_ERROR("cant make print_tb arguments");
-
- obResult = PyObject_CallObject(obFuncTB, argsTB);
- if (obResult==NULL) GPEM_ERROR("traceback.print_tb() failed");
-
- /* Now call the getvalue() method in the StringIO instance */
- Py_DECREF(obFuncStringIO);
- obFuncStringIO = PyObject_GetAttrString(obStringIO, "getvalue");
- if (obFuncStringIO==NULL) GPEM_ERROR("cant find getvalue function");
- Py_DECREF(obResult);
- obResult = PyObject_CallObject(obFuncStringIO, NULL);
- if (obResult==NULL) GPEM_ERROR("getvalue() failed.");
-
- /* And it should be a string all ready to go - duplicate it. */
- if (!PyString_Check(obResult))
- GPEM_ERROR("getvalue() did not return a string");
- result = strdup(PyString_AsString(obResult));
- done:
- if (result==NULL && errorMsg != NULL)
- result = strdup(errorMsg);
- Py_XDECREF(modStringIO);
- Py_XDECREF(modTB);
- Py_XDECREF(obFuncStringIO);
- Py_XDECREF(obStringIO);
- Py_XDECREF(obFuncTB);
- Py_XDECREF(argsTB);
- Py_XDECREF(obResult);
- return result;
- }
-
static void ReportPythonError(DWORD code)
{
if (PyErr_Occurred()) {
! LPTSTR inserts[4];
! inserts[3] = NULL; // terminate array
PyObject *type, *value, *traceback;
PyErr_Fetch(&type, &value, &traceback);
! WCHAR *szTracebackUse = L"<No memory!>"; // default.
! WCHAR *szTraceback = NULL; // to be freed.
! char *szmbTraceback = GetPythonTraceback(traceback);
if (szmbTraceback) {
int tb_len = strlen(szmbTraceback) + 1;
--- 1350,1362 ----
}
static void ReportPythonError(DWORD code)
{
if (PyErr_Occurred()) {
! LPTSTR inserts[4] = {NULL, NULL, NULL, NULL};
PyObject *type, *value, *traceback;
PyErr_Fetch(&type, &value, &traceback);
! TCHAR *szTracebackUse = L"<No memory!>"; // default.
! TCHAR *szTraceback = NULL; // to be freed.
! char *szmbTraceback = GetPythonTraceback(type, value, traceback);
if (szmbTraceback) {
int tb_len = strlen(szmbTraceback) + 1;
***************
*** 1437,1450 ****
}
inserts[0] = szTracebackUse;
- PyObject *obStr = PyObject_Str(type);
- PyWinObject_AsWCHAR(obStr, inserts+1);
- Py_XDECREF(obStr);
- obStr = PyObject_Str(value);
- PyWinObject_AsWCHAR(PyObject_Str(obStr), inserts+2);
- Py_XDECREF(obStr);
ReportError(code, (LPCTSTR *)inserts);
if (szTraceback) free(szTraceback);
! PyWinObject_FreeWCHAR(inserts[1]);
! PyWinObject_FreeWCHAR(inserts[2]);
if (bServiceDebug) { // If debugging, restore for traceback print,
PyErr_Restore(type, value, traceback);
--- 1371,1377 ----
}
inserts[0] = szTracebackUse;
ReportError(code, (LPCTSTR *)inserts);
if (szTraceback) free(szTraceback);
!
if (bServiceDebug) { // If debugging, restore for traceback print,
PyErr_Restore(type, value, traceback);
***************
*** 1578,1582 ****
// Our EXE entry point.
! int main(int argc, char **argv)
{
PyObject *module, *f;
--- 1505,1509 ----
// Our EXE entry point.
! int _tmain(int argc, TCHAR **argv)
{
PyObject *module, *f;
***************
*** 1591,1600 ****
Py_DECREF(module);
if (!f) goto failed;
! if (!PyString_Check(f)) {
! PyErr_SetString(PyExc_TypeError, "servicemanager.__file__ is not a string!");
goto failed;
}
! // now get the handle to the DLL, and call the main function.
! hmod = GetModuleHandleA(PyString_AsString(f));
Py_DECREF(f);
if (!hmod) {
--- 1518,1532 ----
Py_DECREF(module);
if (!f) goto failed;
!
! // now get the handle to the DLL, and call the main function.
! if (PyString_Check(f))
! hmod = GetModuleHandleA(PyString_AsString(f));
! else if (PyUnicode_Check(f))
! hmod = GetModuleHandleW(PyUnicode_AsUnicode(f));
! else{
! PyErr_SetString(PyExc_TypeError, "servicemanager.__file__ is not a string or unicode !");
goto failed;
}
!
Py_DECREF(f);
if (!hmod) {
***************
*** 1612,1617 ****
PyEval_ReleaseThread(threadState);
! typedef int (* FNPythonService_main)(int argc, char **argv);
! return ((FNPythonService_main)proc)(argc, argv);
failed:
fprintf(stderr, "PythonService was unable to locate the service manager. "
--- 1544,1549 ----
PyEval_ReleaseThread(threadState);
! typedef int (* FNPythonService_main)(int argc, TCHAR **argv);
! return (*(FNPythonService_main)proc)(argc, argv);
failed:
fprintf(stderr, "PythonService was unable to locate the service manager. "
Index: win32service.i
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32service.i,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** win32service.i 10 Jun 2008 21:34:56 -0000 1.17
--- win32service.i 13 Nov 2008 11:11:58 -0000 1.18
***************
*** 25,29 ****
%init %{
// All errors raised by this module are of this type.
- Py_INCREF(PyWinExc_ApiError);
PyDict_SetItemString(d, "error", PyWinExc_ApiError);
PyDict_SetItemString(d, "HWINSTAType", (PyObject *)&PyHWINSTAType);
--- 25,28 ----
Index: _win32sysloader.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/_win32sysloader.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** _win32sysloader.cpp 21 Oct 2005 02:25:49 -0000 1.1
--- _win32sysloader.cpp 13 Nov 2008 11:11:58 -0000 1.2
***************
*** 15,50 ****
static PyObject *PyGetModuleFilename(PyObject *self, PyObject *args)
{
! char *modName;
! if (!PyArg_ParseTuple(args, "s", &modName))
return NULL;
HINSTANCE hinst = GetModuleHandle(modName);
! if (hinst == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
! char buf[_MAX_PATH];
! if (GetModuleFileName(hinst, buf, sizeof(buf))==0) {
Py_INCREF(Py_None);
return Py_None;
}
! return PyString_FromString(buf);
}
static PyObject *PyLoadModule(PyObject *self, PyObject *args)
{
! char *modName;
! if (!PyArg_ParseTuple(args, "s", &modName))
return NULL;
HINSTANCE hinst = LoadLibrary(modName);
if (hinst == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
! char buf[_MAX_PATH];
! if (GetModuleFileName(hinst, buf, sizeof(buf))==0) {
Py_INCREF(Py_None);
return Py_None;
}
! return PyString_FromString(buf);
}
--- 15,71 ----
static PyObject *PyGetModuleFilename(PyObject *self, PyObject *args)
{
! // For py3k, will be built with UNICODE defined
! #ifdef UNICODE
! static char *fmt="u";
! #else
! static char *fmt="s";
! #endif
!
! TCHAR *modName=NULL;
! if (!PyArg_ParseTuple(args, fmt, &modName))
return NULL;
HINSTANCE hinst = GetModuleHandle(modName);
! if (hinst == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
! TCHAR buf[_MAX_PATH];
! if (GetModuleFileName(hinst, buf, sizeof(buf)/sizeof(buf[0]))==0) {
Py_INCREF(Py_None);
return Py_None;
}
! #ifdef UNICODE
! return PyUnicode_FromUnicode(buf, wcslen(buf));
! #else
! return PyString_FromString(buf);
! #endif
}
static PyObject *PyLoadModule(PyObject *self, PyObject *args)
{
! #ifdef UNICODE
! static char *fmt="u";
! #else
! static char *fmt="s";
! #endif
! TCHAR *modName=NULL;
! if (!PyArg_ParseTuple(args, fmt, &modName))
return NULL;
HINSTANCE hinst = LoadLibrary(modName);
+
if (hinst == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
! TCHAR buf[_MAX_PATH];
! if (GetModuleFileName(hinst, buf, sizeof(buf)/sizeof(buf[0]))==0) {
Py_INCREF(Py_None);
return Py_None;
}
! #ifdef UNICODE
! return PyUnicode_FromUnicode(buf, wcslen(buf));
! #else
! return PyString_FromString(buf);
! #endif
}
Index: win32helpmodule.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32helpmodule.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** win32helpmodule.cpp 27 May 2007 13:25:42 -0000 1.4
--- win32helpmodule.cpp 13 Nov 2008 11:11:58 -0000 1.5
***************
*** 22,26 ****
#include "PyWinTypes.h"
-
#define DllExport _declspec(dllexport)
--- 22,25 ----
***************
*** 45,97 ****
static PyObject *PyWinHelp(PyObject *self, PyObject *args)
{
[...968 lines suppressed...]
// Module constants:
+ #define ADD_CONSTANT(tok) if (rc=PyModule_AddIntConstant(module, #tok, tok)) return rc
! int AddConstants(PyObject *module)
{
int rc;
***************
*** 3312,3316 ****
dict = PyModule_GetDict(module);
if (!dict) return; /* Another serious error!*/
! AddConstants(dict);
PyDict_SetItemString(dict, "__version__",
PyString_FromString("$Revision$"));
--- 3144,3148 ----
dict = PyModule_GetDict(module);
if (!dict) return; /* Another serious error!*/
! AddConstants(module);
PyDict_SetItemString(dict, "__version__",
PyString_FromString("$Revision$"));
Index: win2krasmodule.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win2krasmodule.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** win2krasmodule.cpp 3 Jun 2007 14:53:07 -0000 1.6
--- win2krasmodule.cpp 13 Nov 2008 11:11:58 -0000 1.7
***************
*** 96,100 ****
};
-
PyRASEAPUSERIDENTITY::PyRASEAPUSERIDENTITY(RASEAPUSERIDENTITY *identity)
{
--- 96,99 ----
***************
*** 132,142 ****
PyRasGetEapUserIdentity( PyObject *self, PyObject *args )
{
! char *phoneBook, *entry;
int flags;
! HWND hwnd;
! PyObject *obhwnd=Py_None;
! if (!PyArg_ParseTuple(args, "zsi|O:GetEapUserIdentity",
! &phoneBook, // @pyparm string|phoneBook||string containing the full path of the phone-book (PBK) file. If this parameter is None, the function will use the system phone book.
! &entry,// @pyparm string|entry||string containing an existing entry name.
&flags, // @pyparm int|flags||Specifies zero or more of the following flags that qualify the authentication process.
// @flagh Flag|Description
--- 131,142 ----
PyRasGetEapUserIdentity( PyObject *self, PyObject *args )
{
! TCHAR *phoneBook=NULL, *entry=NULL;
! PyObject *obphoneBook, *obentry;
int flags;
! HWND hwnd=NULL;
! PyObject *ret=NULL;
! if (!PyArg_ParseTuple(args, "OOi|O&:GetEapUserIdentity",
! &obphoneBook, // @pyparm string|phoneBook||string containing the full path of the phone-book (PBK) file. If this parameter is None, the function will use the system phone book.
! &obentry,// @pyparm string|entry||string containing an existing entry name.
&flags, // @pyparm int|flags||Specifies zero or more of the following flags that qualify the authentication process.
// @flagh Flag|Description
***************
*** 144,161 ****
// @flag RASEAPF_Logon|Specifies that the user data is obtained from Winlogon.
// @flag RASEAPF_Preview|Specifies that the user should be prompted for identity information before dialing.
! &obhwnd)) // @pyparm <o PyHANDLE>|hwnd|None|Handle to the parent window for the UI dialog.
! return NULL;
! if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd))
return NULL;
! // @pyseeapi RasGetEapUserIdentity
! DWORD rc;
! RASEAPUSERIDENTITY *identity;
! Py_BEGIN_ALLOW_THREADS
! rc = RasGetEapUserIdentity(phoneBook, entry, flags, hwnd, &identity);
! Py_END_ALLOW_THREADS
! if (rc != 0)
! return ReturnRasError("RasGetEapUserIdentity",rc);
! return PyWinObject_FromRASEAPUSERIDENTITY(identity);
}
--- 144,166 ----
// @flag RASEAPF_Logon|Specifies that the user data is obtained from Winlogon.
// @flag RASEAPF_Preview|Specifies that the user should be prompted for identity information before dialing.
! PyWinObject_AsHANDLE, &hwnd)) // @pyparm <o PyHANDLE>|hwnd|None|Handle to the parent window for the UI dialog.
return NULL;
! if (PyWinObject_AsTCHAR(obphoneBook, &phoneBook, TRUE)
! && PyWinObject_AsTCHAR(obentry, &entry, FALSE)){
! // @pyseeapi RasGetEapUserIdentity
! DWORD rc;
! RASEAPUSERIDENTITY *identity;
! Py_BEGIN_ALLOW_THREADS
! rc = RasGetEapUserIdentity(phoneBook, entry, flags, hwnd, &identity);
! Py_END_ALLOW_THREADS
! if (rc != 0)
! ReturnRasError("RasGetEapUserIdentity",rc);
! else
! ret = PyWinObject_FromRASEAPUSERIDENTITY(identity);
! }
! PyWinObject_FreeTCHAR(phoneBook);
! PyWinObject_FreeTCHAR(entry);
! return ret;
}
***************
*** 167,188 ****
};
- int AddConstant(PyObject *dict, char *key, long value)
- {
- PyObject *okey = PyString_FromString(key);
- PyObject *oval = PyInt_FromLong(value);
- if (!okey || !oval) {
- Py_XDECREF(okey);
- Py_XDECREF(oval);
- return 1;
- }
- int rc = PyDict_SetItem(dict,okey, oval);
- Py_XDECREF(okey);
- Py_XDECREF(oval);
- return rc;
- }
! #define ADD_CONSTANT(tok) if (rc=AddConstant(dict,#tok, tok)) return rc
! static int AddConstants(PyObject *dict)
{
int rc;
--- 172,179 ----
};
! #define ADD_CONSTANT(tok) if (rc=PyModule_AddIntConstant(module, #tok, tok)) return rc
! static int AddConstants(PyObject *module)
{
int rc;
***************
*** 198,201 ****
--- 189,193 ----
PyWinGlobals_Ensure();
PyObject *dict, *module;
+ #define RETURN_ERROR return // towards py3k
module = Py_InitModule("win2kras", win2kras_functions);
if (!module) /* Eeek - some serious error! */
***************
*** 203,211 ****
dict = PyModule_GetDict(module);
if (!dict) return; /* Another serious error!*/
! AddConstants(dict);
#ifdef _DEBUG
! const char *modName = "win32ras_d.pyd";
#else
! const char *modName = "win32ras.pyd";
#endif
// We insist on win32ras being imported - but the least we
--- 195,203 ----
dict = PyModule_GetDict(module);
if (!dict) return; /* Another serious error!*/
! AddConstants(module);
#ifdef _DEBUG
! const TCHAR *modName = _T("win32ras_d.pyd");
#else
! const TCHAR *modName = _T("win32ras.pyd");
#endif
// We insist on win32ras being imported - but the least we
***************
*** 219,228 ****
if (hmod==NULL) {
PyErr_SetString(PyExc_RuntimeError, "You must import 'win32ras' before importing this module");
! return;
}
FARPROC fp = GetProcAddress(hmod, "ReturnRasError");
if (fp==NULL) {
PyErr_SetString(PyExc_RuntimeError, "Could not locate 'ReturnRasError' in 'win32ras'");
! return;
}
pfnReturnRasError = (PFNReturnRasError)fp;
--- 211,220 ----
if (hmod==NULL) {
PyErr_SetString(PyExc_RuntimeError, "You must import 'win32ras' before importing this module");
! RETURN_ERROR;
}
FARPROC fp = GetProcAddress(hmod, "ReturnRasError");
if (fp==NULL) {
PyErr_SetString(PyExc_RuntimeError, "Could not locate 'ReturnRasError' in 'win32ras'");
! RETURN_ERROR;
}
pfnReturnRasError = (PFNReturnRasError)fp;
Index: PySID.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PySID.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** PySID.cpp 24 May 2007 06:01:05 -0000 1.12
--- PySID.cpp 13 Nov 2008 11:11:58 -0000 1.13
***************
*** 106,110 ****
return NULL;
PySID *This = (PySID *)self;
! return PyInt_FromLong( IsValidSid(This->GetSID()) );
}
--- 106,110 ----
return NULL;
PySID *This = (PySID *)self;
! return PyBool_FromLong( IsValidSid(This->GetSID()) );
}
***************
*** 175,179 ****
SID_IDENTIFIER_AUTHORITY *psia; //wtf is this thing ? Give it back to the user, let *him* figure it out
psia = ::GetSidIdentifierAuthority(This->GetSID());
! return Py_BuildValue("(iiiiii)",psia->Value[0],psia->Value[1],psia->Value[2],psia->Value[3],psia->Value[4],psia->Value[5]);
}
--- 175,179 ----
SID_IDENTIFIER_AUTHORITY *psia; //wtf is this thing ? Give it back to the user, let *him* figure it out
psia = ::GetSidIdentifierAuthority(This->GetSID());
! return Py_BuildValue("(BBBBBB)",psia->Value[0],psia->Value[1],psia->Value[2],psia->Value[3],psia->Value[4],psia->Value[5]);
}
***************
*** 391,400 ****
}
// Space for the "PySID:" prefix.
! const char *prefix = "PySID:";
! char *buf = (char *)malloc(strlen(prefix)+bufSize);
if (buf==NULL) return PyErr_NoMemory();
! strcpy(buf, prefix);
! GetTextualSid(psid, buf+strlen(prefix), &bufSize);
! PyObject *ret = PyString_FromString(buf);
free(buf);
return ret;
--- 391,400 ----
}
// Space for the "PySID:" prefix.
! TCHAR *prefix = _T("PySID:");
! TCHAR *buf = (TCHAR *)malloc((_tcslen(prefix)+bufSize) * sizeof(TCHAR));
if (buf==NULL) return PyErr_NoMemory();
! _tcscpy(buf, prefix);
! GetTextualSid(psid, buf+_tcslen(prefix), &bufSize);
! PyObject *ret = PyWinObject_FromTCHAR(buf);
free(buf);
return ret;
Index: mmapfilemodule.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/mmapfilemodule.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** mmapfilemodule.cpp 28 Jun 2007 08:23:14 -0000 1.4
--- mmapfilemodule.cpp 13 Nov 2008 11:11:58 -0000 1.5
***************
*** 208,214 ****
CHECK_VALID;
! if (!PyArg_ParseTuple (args, "c",
&value)) // @pyparm str|char||Single byte to be placed in buffer
! return(NULL);
// read and write methods can leave pos = size, technically past end of buffer
--- 208,214 ----
CHECK_VALID;
! if (!PyArg_ParseTuple (args, "c:write_byte",
&value)) // @pyparm str|char||Single byte to be placed in buffer
! return NULL;
// read and write methods can leave pos = size, technically past end of buffer
***************
*** 500,505 ****
{
mmapfile_object * m_obj;
! char * filename;
! PyObject *obtagname, *obview_size=Py_None;
PSECURITY_ATTRIBUTES psa=NULL; // Not accepted as a parameter yet
--- 500,505 ----
{
mmapfile_object * m_obj;
! TCHAR * filename;
! PyObject *obfilename, *obtagname, *obview_size=Py_None;
PSECURITY_ATTRIBUTES psa=NULL; // Not accepted as a parameter yet
***************
*** 518,523 ****
static char *keywords[]={"File", "Name", "MaximumSize", "FileOffset", "NumberOfBytesToMap", NULL};
! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "zO|KKO", keywords,
! &filename, // @pyparm str|File||Name of file. Use None or '' when opening an existing named mapping, or to use system pagefile.
&obtagname, // @pyparm str|Name||Name of mapping object to create or open, can be None
&m_obj->mapping_size.QuadPart, // @pyparm int|MaximumSize|0|Size of file mapping to create, should be specified as a multiple
--- 518,523 ----
static char *keywords[]={"File", "Name", "MaximumSize", "FileOffset", "NumberOfBytesToMap", NULL};
! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|KKO", keywords,
! &obfilename, // @pyparm str|File||Name of file. Use None or '' when opening an existing named mapping, or to use system pagefile.
&obtagname, // @pyparm str|Name||Name of mapping object to create or open, can be None
&m_obj->mapping_size.QuadPart, // @pyparm int|MaximumSize|0|Size of file mapping to create, should be specified as a multiple
***************
*** 536,543 ****
--- 536,548 ----
return NULL;
}
+ if (!PyWinObject_AsTCHAR(obfilename, &filename, TRUE)){
+ Py_DECREF(m_obj);
+ return NULL;
+ }
if (obview_size!=Py_None){
m_obj->size=PyInt_AsSsize_t(obview_size);
if (m_obj->size==-1 && PyErr_Occurred()){
Py_DECREF(m_obj);
+ PyWinObject_FreeTCHAR(filename);
return NULL;
}
***************
*** 545,557 ****
// if an actual filename has been specified
! if (filename && strlen(filename)){
m_obj->file_handle = CreateFile (filename, GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE, psa, OPEN_ALWAYS, 0, NULL);
if (m_obj->file_handle == INVALID_HANDLE_VALUE){
Py_DECREF(m_obj);
return PyWin_SetAPIError("CreateFile");
}
}
!
// If mapping size was not specified, use existing file size
if ((!m_obj->mapping_size.QuadPart) && (m_obj->file_handle != INVALID_HANDLE_VALUE)){
--- 550,564 ----
// if an actual filename has been specified
! if (filename && _tcslen(filename)){
m_obj->file_handle = CreateFile (filename, GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE, psa, OPEN_ALWAYS, 0, NULL);
if (m_obj->file_handle == INVALID_HANDLE_VALUE){
Py_DECREF(m_obj);
+ PyWinObject_FreeTCHAR(filename);
return PyWin_SetAPIError("CreateFile");
}
}
! PyWinObject_FreeTCHAR(filename);
!
// If mapping size was not specified, use existing file size
if ((!m_obj->mapping_size.QuadPart) && (m_obj->file_handle != INVALID_HANDLE_VALUE)){
Index: PySECURITY_DESCRIPTOR.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PySECURITY_DESCRIPTOR.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** PySECURITY_DESCRIPTOR.cpp 24 May 2007 06:01:05 -0000 1.19
--- PySECURITY_DESCRIPTOR.cpp 13 Nov 2008 11:11:58 -0000 1.20
***************
*** 102,109 ****
if (!PyArg_ParseTuple(args, "O:SECURITY_DESCRIPTOR", &obsd))
return NULL;
! if (PyObject_AsReadBuffer(obsd, (const void **)&psd, &buf_len)==-1){
! PyErr_SetString(PyExc_TypeError,"Object has no data buffer");
return NULL;
- }
if (!IsValidSecurityDescriptor(psd)){
PyErr_SetString(PyExc_ValueError,"Data is not a valid security descriptor");
--- 102,107 ----
if (!PyArg_ParseTuple(args, "O:SECURITY_DESCRIPTOR", &obsd))
return NULL;
! if (PyObject_AsReadBuffer(obsd, (const void **)&psd, &buf_len)==-1)
return NULL;
if (!IsValidSecurityDescriptor(psd)){
PyErr_SetString(PyExc_ValueError,"Data is not a valid security descriptor");
|