Update of /cvsroot/pywin32/pywin32/win32/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv2024/win32/src
Modified Files:
PyWinTypes.h PyWinTypesmodule.cpp
Log Message:
merge py3k compatibility macros from py3k branch
Index: PyWinTypesmodule.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypesmodule.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -d -r1.48 -r1.49
*** PyWinTypesmodule.cpp 8 Jan 2009 02:56:17 -0000 1.48
--- PyWinTypesmodule.cpp 26 Jan 2009 00:12:35 -0000 1.49
***************
*** 32,35 ****
--- 32,87 ----
#endif
+
+ #if (PY_VERSION_HEX >= 0x03000000)
+ // For py3k, a function that returns new memoryview object instead of buffer.
+ // ??? Byte array object is mutable, maybe just use that directly as a substitute ???
+ // Docs do not specify that you can pass NULL buffer to PyByteArray_FromStringAndSize, but it works
+ PyObject *PyBuffer_New(Py_ssize_t size){
+ PyObject *bah = PyByteArray_FromStringAndSize(NULL, size);
+ if (bah==NULL)
+ return NULL;
+ PyObject *ret = PyMemoryView_FromObject(bah);
+ Py_DECREF(bah); // Memory view keeps its own ref to base object
+ return ret;
+ }
+
+ PyObject *PyBuffer_FromReadWriteMemory(void *buf, Py_ssize_t size){
+ // buf is not freed by returned object !!!!!!!
+ Py_buffer info={
+ buf,
+ NULL, // obj added in 3.0b3
+ size,
+ FALSE, // readonly
+ NULL, // format
+ 0, // ndim
+ NULL, // shape
+ NULL, // strided
+ NULL, // suboffsets
+ 0, // itemsize
+ NULL, // internal
+ };
+ return PyMemoryView_FromBuffer(&info);
+ }
+
+ PyObject *PyBuffer_FromMemory(void *buf, Py_ssize_t size){
+ // buf is not freed by returned object !!!!!!!
+ Py_buffer info={
+ buf,
+ NULL, // obj added in 3.0b3
+ size,
+ TRUE, // readonly
+ NULL, // format
+ 0, // ndim
+ NULL, // shape
+ NULL, // strided
+ NULL, // suboffsets
+ 0, // itemsize
+ NULL, // internal
+ };
+ return PyMemoryView_FromBuffer(&info);
+ }
+ #endif
+
+
// See comments in pywintypes.h for why we need this!
void PyWin_MakePendingCalls()
***************
*** 878,881 ****
--- 930,961 ----
// @tupleitem 3|None/int|argerror|The index of the argument in error, or (usually) None or -1
}
+
+ /* PyType_Ready needs to be called anytime pywintypesxx.dll is loaded, since
+ other extension modules can use types defined here without pywintypes itself
+ having been imported.
+ ??? All extension modules that call this need to be changed to check the exit code ???
+ */
+ if (PyType_Ready(&PyHANDLEType) == -1
+ ||PyType_Ready(&PyOVERLAPPEDType) == -1
+ ||PyType_Ready(&PyDEVMODEType) == -1
+ ||PyType_Ready(&PyDEVMODEWType) == -1
+ ||PyType_Ready(&PyWAVEFORMATEXType) == -1
+ #ifndef NO_PYWINTYPES_TIME
+ ||PyType_Ready(&PyTimeType) == -1
+ #endif // NO_PYWINTYPES_TIME
+ #ifndef NO_PYWINTYPES_IID
+ ||PyType_Ready(&PyIIDType) == -1
+ #endif // NO_PYWINTYPES_IID
+ #ifndef NO_PYWINTYPES_SECURITY
+ ||PyType_Ready(&PySECURITY_DESCRIPTORType) == -1
+ ||PyType_Ready(&PySECURITY_ATTRIBUTESType) == -1
+ ||PyType_Ready(&PySIDType) == -1
+ ||PyType_Ready(&PyACLType) == -1
+ #endif
+ )
+ return -1;
+
+ if (!_PyWinDateTime_Init())
+ return -1;
return 0;
}
Index: PyWinTypes.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v
retrieving revision 1.60
retrieving revision 1.61
diff -C2 -d -r1.60 -r1.61
*** PyWinTypes.h 8 Jan 2009 02:56:17 -0000 1.60
--- PyWinTypes.h 26 Jan 2009 00:12:35 -0000 1.61
***************
*** 131,135 ****
*/
#define PYWIN_ATTR_CONVERT _PyUnicode_AsString
! #endif // PY_VERSION_HEX
// See PEP-353 - this is the "official" test...
--- 131,157 ----
*/
#define PYWIN_ATTR_CONVERT _PyUnicode_AsString
!
! /* Some API functions changed/removed in python 3.0
! Definitions for the string functions are in stringobject.h,
! but comments indicate that this header is likely to go away in 3.1.
! */
! #define PyString_Check PyBytes_Check
! #define PyString_Size PyBytes_Size
! #define PyString_AsString PyBytes_AsString
! #define PyString_AsStringAndSize PyBytes_AsStringAndSize
! #define PyString_FromString PyBytes_FromString
! #define PyString_FromStringAndSize PyBytes_FromStringAndSize
! #define _PyString_Resize _PyBytes_Resize
! #define PyString_AS_STRING PyBytes_AS_STRING
! #define PyString_GET_SIZE PyBytes_GET_SIZE
! #define PyString_Concat PyBytes_Concat
! #define PyInt_Check PyLong_Check
! #define PyInt_FromLong PyLong_FromLong
! #define PyInt_AsLong PyLong_AsLong
! #define PyInt_AS_LONG PyLong_AS_LONG
! #define PyInt_FromSsize_t PyLong_FromSsize_t
! #define PyInt_AsSsize_t PyLong_AsSsize_t
! #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
! #endif // (PY_VERSION_HEX < 0x03000000)
// See PEP-353 - this is the "official" test...
|