Update of /cvsroot/pywin32/pywin32/win32/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31679/win32/src
Modified Files:
win32trace.cpp
Log Message:
* Fix handling of local vs global object detection yet again :(
* Make py3k-friendly by using encoding as latin-1.
Index: win32trace.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32trace.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** win32trace.cpp 3 Jan 2009 06:43:58 -0000 1.21
--- win32trace.cpp 25 Jan 2009 03:19:22 -0000 1.22
***************
*** 115,129 ****
}
static PyObject *PyTraceObject_write(PyObject *self, PyObject *args)
{
int len;
! char *data;
! if (!PyArg_ParseTuple(args, "s#:write", &data, &len))
return NULL;
BOOL ok = static_cast<PyTraceObject*>(self)->WriteData(data, len);
if (!ok)
return NULL;
! Py_INCREF(Py_None);
! return Py_None;
}
--- 115,133 ----
}
+ // In an attempt to allow py2k and py3k readers and writers to work together,
+ // we assume a 'latin1' encoding for the bytes on the wire. When pulling the
+ // bytes off the wire, in py2k we return a string while in py3k we return
+ // a latin-1 decoded unicode object.
static PyObject *PyTraceObject_write(PyObject *self, PyObject *args)
{
int len;
! char *data = NULL;
! if (!PyArg_ParseTuple(args, "et#:write", "latin-1", &data, &len))
return NULL;
BOOL ok = static_cast<PyTraceObject*>(self)->WriteData(data, len);
+ PyMem_Free(data);
if (!ok)
return NULL;
! Py_RETURN_NONE;
}
***************
*** 137,141 ****
--- 141,149 ----
if (!ok)
return NULL;
+ #if (PY_VERSION_HEX < 0x03000000)
PyObject *result = PyString_FromStringAndSize(data, len);
+ #else
+ PyObject *result = PyUnicode_DecodeLatin1(data, len, "replace");
+ #endif
free(data);
return result;
***************
*** 152,156 ****
--- 160,168 ----
if (!ok)
return NULL;
+ #if (PY_VERSION_HEX < 0x03000000)
PyObject *result = PyString_FromStringAndSize(data, len);
+ #else
+ PyObject *result = PyUnicode_DecodeLatin1(data, len, "replace");
+ #endif
free(data);
return result;
***************
*** 648,651 ****
--- 660,664 ----
// no local one exists - see if we can create it globally - if
// we can, we go global, else we stick with local.
+ use_global_namespace = TRUE;
HANDLE h2 = CreateFileMapping((HANDLE)-1, &sa, PAGE_READWRITE,
0, BUFFER_SIZE,
|