diff --git a/Pythonwin/win32uimodule.cpp b/Pythonwin/win32uimodule.cpp index 10ea1e2ccb..befd4ec7e2 100644 --- a/Pythonwin/win32uimodule.cpp +++ b/Pythonwin/win32uimodule.cpp @@ -173,10 +173,6 @@ ui_type::ui_type(const char *name, ui_type *pBase, Py_ssize_t typeSize, tp_methods = methodList; //#define funky_offsetof_weakreflist ((size_t) &((PyObject *)(ui_base_class *)0)->weakreflist) -#if (PY_VERSION_HEX < 0x03000000) - tp_flags |= Py_TPFLAGS_HAVE_WEAKREFS; // flag doesn't exist in py3k -#endif - tp_weaklistoffset -= pyobjOffset; // cast away const, as Python doesnt use it. tp_name = (char *)name; @@ -350,12 +346,7 @@ int ui_base_class::setattro(PyObject *obname, PyObject *v) CString ui_base_class::repr() { CString csRet; -#if (PY_VERSION_HEX < 0x03000000) - USES_CONVERSION; - csRet.Format(_T("object '%s'"), A2T((LPSTR)ob_type->tp_name)); -#else csRet.Format(_T("object '%S'"), ob_type->tp_name); -#endif return csRet; } void ui_base_class::cleanup() @@ -715,10 +706,6 @@ PyObject *Python_do_callback(PyObject *themeth, PyObject *thearglst) } // Copied from PyRecord.cpp, should move into pywintypes.h -#if (PY_VERSION_HEX < 0x03000000) -#define PyWinCoreString_ConcatAndDel PyBytes_ConcatAndDel -#define PyWinCoreString_Concat PyBytes_Concat -#else // Unicode versions of '_Concat' etc have different sigs. Make them the // same here... void PyWinCoreString_Concat(register PyObject **pv, register PyObject *w) @@ -733,14 +720,6 @@ void PyWinCoreString_Concat(register PyObject **pv, register PyObject *w) *pv = tmp; } -void PyWinCoreString_ConcatAndDel(register PyObject **pv, register PyObject *w) -{ - PyWinCoreString_Concat(pv, w); - Py_XDECREF(w); -} - -#endif - int Python_do_int_callback(PyObject *themeth, PyObject *thearglst) { int retVal = INT_MAX; // an identifiable, but unlikely genuine value @@ -1479,7 +1458,7 @@ static PyObject *ui_get_resource(PyObject *self, PyObject *args) return ret; } -// @pymethod |win32ui|LoadString|Loads a string from a resource file. +// @pymethod string|win32ui|LoadString|Loads a string from a resource file. static PyObject *ui_load_string(PyObject *self, PyObject *args) { UINT stringId; @@ -1852,29 +1831,6 @@ static PyObject *ui_translate_vk(PyObject *, PyObject *args) return PyBytes_FromStringAndSize(result, nc); } -/** Seems to have problems on 9x for some people (not me, though?) -// @pymethod /None|win32ui|TranslateVirtualKeyW| -static PyObject *ui_translate_vkW(PyObject *, PyObject *args) -{ - int vk; - // @pyparm int|vk||The key to translate - if (!PyArg_ParseTuple(args, "i", &vk)) - return NULL; - static HKL layout=GetKeyboardLayout(0); - static BYTE State[256]; - if (GetKeyboardState(State)==FALSE) - RETURN_ERR("Can't get keyboard state"); - WCHAR result[2]; - UINT sc=MapVirtualKeyEx(vk,0,layout); - int nc = ToUnicodeEx(vk,sc,State,result,2, 0,layout); - if (nc==-1) { // a dead char. - Py_INCREF(Py_None); - return Py_None; - } - return PyWinObject_FromWCHAR(result, nc); -} -**/ - extern PyObject *ui_get_dialog_resource(PyObject *, PyObject *args); extern PyObject *ui_create_app(PyObject *, PyObject *args); extern PyObject *ui_get_app(PyObject *, PyObject *args); @@ -2086,13 +2042,7 @@ int AddConstants(PyObject *module) int debug = 0; #endif ADD_CONSTANT(debug); // @const win32ui|debug|1 if we are current using a _DEBUG build of win32ui, else 0. - if (PyModule_AddIntConstant(module, "UNICODE", -#ifdef UNICODE - 1 -#else - 0 -#endif - ) == -1) + if (PyModule_AddIntConstant(module, "UNICODE", 1) == -1) return -1; ADD_CONSTANT(AFX_IDW_PANE_FIRST); // @const win32ui|AFX_IDW_PANE_FIRST|Id of the first splitter pane ADD_CONSTANT(AFX_IDW_PANE_LAST); // @const win32ui|AFX_IDW_PANE_LAST|Id of the last splitter pane @@ -2445,11 +2395,7 @@ PYWIN_MODULE_INIT_FUNC(win32ui) PYWIN_MODULE_INIT_RETURN_ERROR; } if (existing_module) -#if (PY_VERSION_HEX < 0x03000000) - return; -#else return existing_module; -#endif PYWIN_MODULE_INIT_PREPARE(win32ui, ui_functions, "A module, encapsulating the Microsoft Foundation Classes."); @@ -2608,12 +2554,6 @@ extern "C" PYW_EXPORT BOOL Win32uiApplicationInit(Win32uiHostGlue *pGlue, const // a risk that when Python does "import win32ui", it // will locate a different one, causing obvious grief! PyObject *argv = PySys_GetObject("argv"); -#if (PY_VERSION_HEX < 0x03000000) - initwin32ui(); - // Set sys.argv if not already done! - if (argv == NULL && __targv != NULL && __argc > 0) - PySys_SetArgv(__argc - 1, __targv + 1); -#else PyInit_win32ui(); // Decide if we render sys.argv from command line. // PY3.6- Py_Initialize sets sys.argv=NULL . @@ -2632,7 +2572,6 @@ extern "C" PYW_EXPORT BOOL Win32uiApplicationInit(Win32uiHostGlue *pGlue, const LocalFree(myargv); } } -#endif // If the versions of the .h file are not in synch, then we are in trouble! if (pGlue->versionNo != WIN32UIHOSTGLUE_VERSION) { MessageBox(0, diff --git a/Pythonwin/win32util.cpp b/Pythonwin/win32util.cpp index fe52259d01..2cb688503e 100644 --- a/Pythonwin/win32util.cpp +++ b/Pythonwin/win32util.cpp @@ -1136,28 +1136,12 @@ CString GetReprText(PyObject *objectUse) { PyObject *s; CString csRet; -#ifdef UNICODE -// PyObject_Unicode disappeared in Py3k, where PyObject_Str returns unicode object -#if (PY_VERSION_HEX < 0x03000000) - s = PyObject_Unicode(objectUse); -#else s = PyObject_Str(objectUse); -#endif if (s) { csRet = CString(PyUnicode_AsUnicode(s)); Py_DECREF(s); return csRet; } -#else - // Assumes that this will always be compiled with UNICODE defined for py3k - s = PyObject_Str(objectUse); - if (s) { - csRet = CString(PyBytes_AsString(s)); - Py_DECREF(s); - return csRet; - } -#endif - PyErr_Clear(); s = PyObject_Repr(objectUse); if (s == NULL) { @@ -1166,7 +1150,7 @@ CString GetReprText(PyObject *objectUse) return csRet; } - // repr() should return either a string or unicode object, but not sure if this is enforced. + // repr() should always return a unicode string, but for hysterical raisens we check if it is bytes. if (PyUnicode_Check(s)) csRet = CString(PyUnicode_AS_UNICODE(s)); else if (PyBytes_Check(s)) @@ -1176,16 +1160,4 @@ CString GetReprText(PyObject *objectUse) s->ob_type->tp_name); Py_DECREF(s); return csRet; - - /* This was apparently trying to remove enclosing quotes, parens, and brackets but will only succeed for quotes - Forget about it for now - Py_ssize_t len=strlen(szRepr); - if (len > 2 && strchr("\"'[(", *szRepr)) { - if (szRepr[len-1]==*szRepr) { - ++szRepr; - len-=2; // drop first and last chars. - } - } - csRet= CString( szRepr, PyWin_SAFE_DOWNCAST(len, Py_ssize_t, int) ); - */ } diff --git a/SWIG/swig_lib/python/pywintypes.i b/SWIG/swig_lib/python/pywintypes.i index 2d8008cd4c..17afe21276 100644 --- a/SWIG/swig_lib/python/pywintypes.i +++ b/SWIG/swig_lib/python/pywintypes.i @@ -98,7 +98,7 @@ typedef unsigned long ULONG; } } -// String and UniCode support +// String support %typemap(python,in) char *inNullString { if ($source==Py_None) { $target = NULL; @@ -588,13 +588,7 @@ typedef float HWND; #ifndef SWIG_PYTHONCOM /* This code only valid if non COM SWIG builds */ #ifndef PYCOM_EXPORT - PyDict_SetItemString(d,"UNICODE", PyLong_FromLong( -#ifdef UNICODE - 1 -#else - 0 -#endif - )); + PyDict_SetItemString(d,"UNICODE", PyLong_FromLong(1)); #endif PyWinGlobals_Ensure(); PyDict_SetItemString(d, "error", PyWinExc_ApiError); diff --git a/com/win32com/src/MiscTypes.cpp b/com/win32com/src/MiscTypes.cpp index b9865538db..de93a35fc3 100644 --- a/com/win32com/src/MiscTypes.cpp +++ b/com/win32com/src/MiscTypes.cpp @@ -103,9 +103,6 @@ PyComEnumTypeObject::PyComEnumTypeObject(const char *name, PyComTypeObject *pBas tp_iter = iter; tp_iternext = iternext; // Py3k does not have this flag, and depends just on presence of tp_iter -#if (PY_VERSION_HEX < 0x03000000) - tp_flags |= Py_TPFLAGS_HAVE_ITER; -#endif } // PyIEnum iter methods - generic for any "standard" COM IEnum interface, but @@ -153,9 +150,6 @@ PyComEnumProviderTypeObject::PyComEnumProviderTypeObject(const char *name, PyCom { tp_iter = iter; // tp_iternext remains NULL -#if (PY_VERSION_HEX < 0x03000000) - tp_flags |= Py_TPFLAGS_HAVE_ITER; -#endif } // PyIEnumProvider iter methods - generic for COM object that can provide an IEnum* diff --git a/com/win32com/src/PyComHelpers.cpp b/com/win32com/src/PyComHelpers.cpp index 5f4e55acf0..2bcc9ca1cb 100644 --- a/com/win32com/src/PyComHelpers.cpp +++ b/com/win32com/src/PyComHelpers.cpp @@ -53,11 +53,7 @@ PyObject *get_Decimal_class(void) PyObject *PyObject_FromCurrency(CURRENCY &cy) { -#if (PY_VERSION_HEX < 0x03000000) - static char *divname = "__div__"; -#else static char *divname = "__truediv__"; -#endif if (Decimal_class == NULL) { Decimal_class = get_Decimal_class(); if (Decimal_class == NULL) diff --git a/com/win32com/src/PyRecord.cpp b/com/win32com/src/PyRecord.cpp index 676859fb88..b26a4db29c 100644 --- a/com/win32com/src/PyRecord.cpp +++ b/com/win32com/src/PyRecord.cpp @@ -348,12 +348,6 @@ static void _FreeFieldNames(BSTR *strings, ULONG num_names) delete[] strings; } -#if (PY_VERSION_HEX < 0x03000000) -#define PyWinCoreString_ConcatAndDel PyBytes_ConcatAndDel -#define PyWinCoreString_Concat PyBytes_Concat -#else -// Unicode versions of '_Concat' etc have different sigs. Make them the -// same here... void PyWinCoreString_Concat(register PyObject **pv, register PyObject *w) { if (!w) { // hrm - string version doesn't do this, but I saw PyObject_Repr() return NULL... @@ -372,8 +366,6 @@ void PyWinCoreString_ConcatAndDel(register PyObject **pv, register PyObject *w) Py_XDECREF(w); } -#endif - PyObject *PyRecord::tp_repr(PyObject *self) { ULONG i; diff --git a/com/win32com/src/dllmain.cpp b/com/win32com/src/dllmain.cpp index 1f243a412d..5c3c74ea93 100644 --- a/com/win32com/src/dllmain.cpp +++ b/com/win32com/src/dllmain.cpp @@ -305,11 +305,7 @@ HRESULT DoRegisterUnregister(LPCSTR fileName, int argc, char **argv) PyCom_DLLAddRef(); { // A scope for _celp CEnterLeavePython _celp; -#if (PY_VERSION_HEX < 0x03000000) - PySys_SetArgv(argc, argv); -#else PySys_SetArgv(argc, __wargv); -#endif; if (PyRun_SimpleFile(fp, (char *)fileName) != 0) { // Convert the Python error to a HRESULT. diff --git a/com/win32com/src/extensions/PyIPropertyStorage.cpp b/com/win32com/src/extensions/PyIPropertyStorage.cpp index f8aa7bf10c..dc4906da8f 100644 --- a/com/win32com/src/extensions/PyIPropertyStorage.cpp +++ b/com/win32com/src/extensions/PyIPropertyStorage.cpp @@ -382,13 +382,6 @@ BOOL PyObject_AsPROPVARIANT(PyObject *ob, PROPVARIANT *pVar) pVar->vt = VT_UI4; } } -#if (PY_VERSION_HEX < 0x03000000) - // Not needed in Py3k, as PyLong_Check is defined to PyLong_Check - } - else if (PyLong_Check(ob)) { - pVar->lVal = PyLong_AsLong(ob); - pVar->vt = VT_I4; -#endif } else if (PyFloat_Check(ob)) { pVar->dblVal = PyFloat_AsDouble(ob); diff --git a/com/win32com/src/oleargs.cpp b/com/win32com/src/oleargs.cpp index 8f140b9c9a..6f62cc8776 100644 --- a/com/win32com/src/oleargs.cpp +++ b/com/win32com/src/oleargs.cpp @@ -19,11 +19,7 @@ static PyObject *PyVariant_Type; #define BYREF_ARRAY_USE_EXISTING_ARRAY // Need to put this in pywintypes.h with rest of compatibility macros -#if (PY_VERSION_HEX < 0x03000000) -#define PYWIN_BUFFER_CHECK PyBuffer_Check -#else #define PYWIN_BUFFER_CHECK(obj) (PyBytes_Check(obj) || PyByteArray_Check(obj) || PyMemoryView_Check(obj)) -#endif // A little helper just for this file static PyObject *OleSetTypeError(TCHAR *msg) @@ -124,9 +120,6 @@ BOOL PyCom_VariantFromPyObject(PyObject *obj, VARIANT *var) V_VT(var) = VT_EMPTY; if ( // In py3k we don't convert PyBytes_Check objects (ie, bytes) to BSTR... -#if (PY_VERSION_HEX < 0x03000000) - PyBytes_Check(obj) || -#endif PyUnicode_Check(obj)) { if (!PyWinObject_AsBstr(obj, &V_BSTR(var))) { PyErr_SetString(PyExc_MemoryError, "Making BSTR for variant"); @@ -223,15 +216,6 @@ BOOL PyCom_VariantFromPyObject(PyObject *obj, VARIANT *var) else if (obj == Py_None) { V_VT(var) = VT_NULL; } -#if (PY_VERSION_HEX < 0x03000000) - // This is redundant in 3.x, since PyLong_Check is #defined to PyLong_Check - else if (PyLong_Check(obj)) { - V_VT(var) = VT_I4; - V_I4(var) = PyLong_AsLong(obj); - if (V_I4(var) == -1 && PyErr_Occurred()) - return FALSE; - } -#endif else if (PyObject_HasAttrString(obj, "_oleobj_")) { if (PyCom_InterfaceFromPyInstanceOrObject(obj, IID_IDispatch, (void **)&V_DISPATCH(var), FALSE)) V_VT(var) = VT_DISPATCH; diff --git a/com/win32com/src/univgw.cpp b/com/win32com/src/univgw.cpp index dd1d9adefe..b32899da12 100644 --- a/com/win32com/src/univgw.cpp +++ b/com/win32com/src/univgw.cpp @@ -349,7 +349,6 @@ static void free_vtbl(gw_vtbl *vtbl) VirtualFree(vtbl, 0, MEM_RELEASE); } -#if PY_VERSION_HEX > 0x03010000 // Use the new capsule API const char *capsule_name = "win32com universal gateway"; @@ -359,20 +358,6 @@ static PyObject *PyVTable_Create(void *vtbl) { return PyCapsule_New(vtbl, capsul static gw_vtbl *PyVTable_Get(PyObject *ob) { return (gw_vtbl *)PyCapsule_GetPointer(ob, capsule_name); } static bool PyVTable_Check(PyObject *ob) { return PyCapsule_IsValid(ob, capsule_name) != 0; } -#else -// Use the old CObject API. -static void __cdecl do_free_vtbl(void *cobject) -{ - gw_vtbl *vtbl = (gw_vtbl *)cobject; - free_vtbl(vtbl); -} - -static PyObject *PyVTable_Create(void *vtbl) { return PyCObject_FromVoidPtr(vtbl, do_free_vtbl); } - -static gw_vtbl *PyVTable_Get(PyObject *ob) { return (gw_vtbl *)PyCObject_AsVoidPtr(ob); } - -static bool PyVTable_Check(PyObject *ob) { return PyCObject_Check(ob) != 0; } -#endif static PyObject *univgw_CreateVTable(PyObject *self, PyObject *args) { @@ -731,13 +716,9 @@ BOOL initunivgw(PyObject *parentDict) PyObject *module; -#if (PY_VERSION_HEX < 0x03000000) - module = Py_InitModule("pythoncom.__univgw", univgw_functions); -#else static PyModuleDef univgw_def = {PyModuleDef_HEAD_INIT, "pythoncom.__univgw", "Univeral gateway", -1, univgw_functions}; module = PyModule_Create(&univgw_def); -#endif if (!module) /* Eeek - some serious error! */ return FALSE; diff --git a/com/win32comext/shell/src/shell.cpp b/com/win32comext/shell/src/shell.cpp index d45aec60bd..9790807c96 100644 --- a/com/win32comext/shell/src/shell.cpp +++ b/com/win32comext/shell/src/shell.cpp @@ -947,8 +947,8 @@ BOOL PyObject_AsSHFILEOPSTRUCT(PyObject *ob, SHFILEOPSTRUCT *p) ob, "OiOO|iOO", &obhwnd, // @tupleitem 0|int|hwnd|Handle of window in which to display status messages &p->wFunc, // @tupleitem 1|int|wFunc|One of the shellcon.FO_* values - &obFrom, // @tupleitem 2|str/unicode|From|String containing source file name(s) separated by nulls - &obTo, // @tupleitem 3|str/unicode|To|String containing destination file name(s) separated by nulls, can be + &obFrom, // @tupleitem 2|string|From|String containing source file name(s) separated by nulls + &obTo, // @tupleitem 3|string|To|String containing destination file name(s) separated by nulls, can be // None &p->fFlags, // @tupleitem 4|int|flags|Combination of shellcon.FOF_* flags. Default=0 &obNameMappings, // @tupleitem 5|None|NameMappings|Maps input file names to their new names. This is @@ -1130,7 +1130,7 @@ static PyObject *PySHBrowseForFolder(PyObject *self, PyObject *args) &obhwndOwner, // @pyparm |hwndOwner|None|Parent window for the dialog box, can be None &obPIDL, // @pyparm |pidlRoot|None|PIDL identifying the place to start browsing. Desktop is used // if not specified - &obTitle, // @pyparm /string|title|None|Title to be displayed with the directory tree + &obTitle, // @pyparm string|title|None|Title to be displayed with the directory tree &bi.ulFlags, // @pyparm int|flags|0|Combination of shellcon.BIF_* flags &obcb, // @pyparm object|callback|None|A callable object to be used as the callback, or None &obcbparam)) // @pyparm object|callback_data|None|An object passed to the callback function @@ -1212,7 +1212,7 @@ static PyObject *PySHGetPathFromIDList(PyObject *self, PyObject *args) return rc; } -// @pymethod |shell|SHGetPathFromIDListW|Converts an IDLIST to a path. +// @pymethod string|shell|SHGetPathFromIDListW|Converts an IDLIST to a path. static PyObject *PySHGetPathFromIDListW(PyObject *self, PyObject *args) { WCHAR buffer[MAX_PATH]; @@ -1239,7 +1239,7 @@ static PyObject *PySHGetPathFromIDListW(PyObject *self, PyObject *args) return rc; } -// @pymethod |shell|SHGetSpecialFolderPath|Retrieves the path of a special folder. +// @pymethod string|shell|SHGetSpecialFolderPath|Retrieves the path of a special folder. static PyObject *PySHGetSpecialFolderPath(PyObject *self, PyObject *args) { HWND hwndOwner; @@ -1269,7 +1269,7 @@ static PyObject *PySHGetSpecialFolderPath(PyObject *self, PyObject *args) return PyWinObject_FromWCHAR(buf); } -// @pymethod |shell|SHGetKnownFolderPath|Retrieves the full path of a known folder identified by the folder's KNOWNFOLDERID. +// @pymethod string|shell|SHGetKnownFolderPath|Retrieves the full path of a known folder identified by the folder's KNOWNFOLDERID. static PyObject *PySHGetKnownFolderPath(PyObject *self, PyObject *args) { PyObject *obfid; @@ -1374,7 +1374,7 @@ static PyObject *PySHGetFileInfo(PyObject *self, PyObject *args) return ret; } -// @pymethod string/|shell|SHGetFolderPath|Retrieves the path of a folder. +// @pymethod string|shell|SHGetFolderPath|Retrieves the path of a folder. static PyObject *PySHGetFolderPath(PyObject *self, PyObject *args) { HWND hwndOwner; @@ -1426,7 +1426,7 @@ static PyObject *PySHSetFolderPath(PyObject *self, PyObject *args) return OleSetOleError(E_NOTIMPL); if (!PyArg_ParseTuple(args, "lO|O:SHSetFolderPath", &csidl, // @pyparm int|csidl||One of the shellcon.CSIDL_* values - &obPath, // @pyparm str/unicode|Path||The full path to be set + &obPath, // @pyparm string|Path||The full path to be set &obToken)) // @pyparm |hToken|None|Handle to an access token, can be None return NULL; if (!PyWinObject_AsHANDLE(obToken, &hToken)) @@ -1679,7 +1679,7 @@ static PyObject *PySHQueryRecycleBin(PyObject *self, PyObject *args) WCHAR *RootPath = NULL; SHQUERYRBINFO info; if (!PyArg_ParseTuple(args, "|O:SHQueryRecycleBin", - &obRootPath)) // @pyparm |RootPath|None|A path containing the drive whose + &obRootPath)) // @pyparm string|RootPath|None|A path containing the drive whose // recycle bin will be queried, or None for all drives return NULL; if (!PyWinObject_AsWCHAR(obRootPath, &RootPath, TRUE)) @@ -1704,7 +1704,7 @@ static PyObject *PyWinObject_FromSHNAMEMAPPINGS(LPVOID hNameMappings) // according to the SDK, SHFILEOPSTRUCT.hNameMappings should be interpreted thusly: struct SHNAMEMAPPINGS { UINT nbr_of_mappings; - LPSHNAMEMAPPINGW pmappings; // on WinNT and up, the unicode version will always be returned + LPSHNAMEMAPPINGW pmappings; }; SHNAMEMAPPINGS *mappings = (SHNAMEMAPPINGS *)hNameMappings; ret = PyTuple_New(mappings->nbr_of_mappings); @@ -1970,7 +1970,7 @@ static PyObject *PyDragQueryFile(PyObject *self, PyObject *args) return ret; } -// @pymethod int/|shell|DragQueryFileW|Retrieves the names (or count) of dropped files +// @pymethod int/string|shell|DragQueryFileW|Retrieves the names (or count) of dropped files static PyObject *PyDragQueryFileW(PyObject *self, PyObject *args) { HDROP hglobal; @@ -2174,12 +2174,8 @@ static PyObject *PyFILEGROUPDESCRIPTORAsString(PyObject *self, PyObject *args) // you only need specify attributes you care about. // In general, you can omit dwFlags - it will be set correctly based // on what other attributes exist. - // @pyparm bool|make_unicode|False on py2k, True on py3k|If true, a FILEDESCRIPTORW object is created -#ifdef UNICODE + // @pyparm bool|make_unicode|True|If true, a FILEDESCRIPTORW object is created int make_unicode = TRUE; -#else - int make_unicode = FALSE; -#endif if (!PyArg_ParseTuple(args, "O|i", &ob, &make_unicode)) return NULL; if (!PySequence_Check(ob)) @@ -2692,7 +2688,7 @@ static PyObject *PySHGetViewStatePropertyBag(PyObject *self, PyObject *args) return OleSetOleError(E_NOTIMPL); if (!PyArg_ParseTuple(args, "OOkO", &obpidl, // @pyparm |pidl||An item id list that identifies the folder - &obbagname, // @pyparm |BagName||Name of the property bag to retrieve + &obbagname, // @pyparm string|BagName||Name of the property bag to retrieve &flags, // @pyparm int|Flags||Combination of SHGVSPB_* flags &obriid)) // @pyparm |riid||The interface to return, usually IID_IPropertyBag return NULL; @@ -2728,7 +2724,7 @@ static PyObject *PySHILCreateFromPath(PyObject *self, PyObject *args) return OleSetOleError(E_NOTIMPL); if (!PyArg_ParseTuple( args, "Ok:SHILCreateFromPath", - &obpath, // @pyparm |Path||The path whose PIDL will be returned + &obpath, // @pyparm string|Path||The path whose PIDL will be returned &flags)) // @pyparm int|Flags||A combination of SFGAO_* constants as used with GetAttributesOf return NULL; if (!PyWinObject_AsWCHAR(obpath, &path, FALSE)) diff --git a/isapi/src/PythonEng.cpp b/isapi/src/PythonEng.cpp index 82b9b5377a..4c8cf44fe3 100644 --- a/isapi/src/PythonEng.cpp +++ b/isapi/src/PythonEng.cpp @@ -134,11 +134,7 @@ bool CPythonEngine::AddToPythonPath(LPCTSTR pPathName) pPathName += 4; len -= 4; } -#if (PY_VERSION_HEX < 0x03000000) - PyObject *obNew = PyBytes_FromStringAndSize(pPathName, len); -#else PyObject *obNew = PyUnicode_FromWideChar(pPathName, len); -#endif if (obNew == NULL) { return false; } diff --git a/isapi/src/Utils.cpp b/isapi/src/Utils.cpp index da58a0cf97..af452ca964 100644 --- a/isapi/src/Utils.cpp +++ b/isapi/src/Utils.cpp @@ -36,14 +36,12 @@ static WCHAR *source_name = L"ISAPI Filter or Extension"; const char *PyISAPIString_AsBytes(PyObject *ob, DWORD *psize /* = NULL */) { PyObject *obNew = NULL; -#if (PY_VERSION_HEX >= 0x03000000) // py3k - check for unicode object and use utf-8 encoding. if (PyUnicode_Check(ob)) { obNew = ob = PyUnicode_AsUTF8String(ob); if (ob == NULL) return NULL; } -#endif // These 'PyString_' calls are all mapped to the bytes API in py3k... if (!PyBytes_Check(ob)) { PyErr_Format(PyExc_ValueError, "Expected a string object (got %s)", ob->ob_type->tp_name); diff --git a/setup.py b/setup.py index 18e1b7144f..62dd8a22d7 100644 --- a/setup.py +++ b/setup.py @@ -1445,7 +1445,7 @@ def finalize_options(self): """, ), ("win32pdh", "", None, "win32/src/win32pdhmodule.cpp"), - ("win32pipe", "", None, "win32/src/win32pipe.i win32/src/win32popen.cpp"), + ("win32pipe", "", None, "win32/src/win32pipe.i"), ( "win32print", "winspool user32 gdi32", diff --git a/win32/Lib/winxptheme.py b/win32/Lib/winxptheme.py index 9b32dbacd9..3f61c3de58 100644 --- a/win32/Lib/winxptheme.py +++ b/win32/Lib/winxptheme.py @@ -1,26 +1,7 @@ """A useful wrapper around the "_winxptheme" module. -Unlike _winxptheme, this module will load on any version of Windows. -If _winxptheme is not available, then this module will have only 2 functions - -IsAppThemed() and IsThemeActive, which will both always return False. - -If _winxptheme is available, this module will have all methods in that module, -including real implementations of IsAppThemed() and IsThemeActive(). +Originally used when we couldn't be sure Windows XP apis were going to +be available. In 2022, it's safe to assume they are, so this is just a wrapper +around _winxptheme. """ - -import win32api - -try: - win32api.FreeLibrary(win32api.LoadLibrary("Uxtheme.dll")) - # Life is good, everything is available. - from _winxptheme import * -except win32api.error: - # Probably not running XP. - def IsAppThemed(): - return False - - def IsThemeActive(): - return False - - -del win32api +from _winxptheme import * diff --git a/win32/src/PyDEVMODE.cpp b/win32/src/PyDEVMODE.cpp index 155b600d88..890f9036fd 100644 --- a/win32/src/PyDEVMODE.cpp +++ b/win32/src/PyDEVMODE.cpp @@ -355,56 +355,8 @@ PyObject *PyDEVMODEA::tp_new(PyTypeObject *typ, PyObject *args, PyObject *kwargs return new PyDEVMODEA(DriverExtra); } -// If pywintypes is compiled with UNICODE defined, all modules that use these -// objects will also need to be UNICODE -#ifndef UNICODE -BOOL PyWinObject_AsDEVMODE(PyObject *ob, PDEVMODE *ppDEVMODE, BOOL bNoneOk) -{ - if (ob == Py_None) - if (bNoneOk) { - *ppDEVMODE = NULL; - return TRUE; - } - else { - PyErr_SetString(PyExc_ValueError, "PyDEVMODE cannot be None in this context"); - return FALSE; - } - if (!PyDEVMODE_Check(ob)) - return FALSE; - *ppDEVMODE = ((PyDEVMODEA *)ob)->GetDEVMODE(); - return TRUE; -} - -PyObject *PyWinObject_FromDEVMODE(PDEVMODEA pdevmode) -{ - static WORD dmSize = sizeof(DEVMODE); - if (pdevmode == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - - // make sure we can't overflow the fixed size DEVMODE in PyDEVMODE - if (pdevmode->dmSize > dmSize) { - PyErr_Format(PyExc_WindowsError, "DEVMODE structure of size %d greater than supported size of %d", - pdevmode->dmSize, dmSize); - return NULL; - } - PyObject *ret = new PyDEVMODEA(pdevmode); - // check that variable sized pdevmode is allocated - if (((PyDEVMODEA *)ret)->GetDEVMODE() == NULL) { - Py_DECREF(ret); - ret = NULL; - } - return ret; -} -#endif - // DEVMODEW support // @object PyDEVMODEW|Unicode version of object -/* PyDEVMODEW is only needed when win32api, win32gui, or win32print - are built with UNICODE defined. Currently, you must explicitely ask - for the unicode version. -*/ struct PyMethodDef PyDEVMODEW::methods[] = { {"Clear", PyDEVMODEW::Clear, 1}, // @pymeth Clear|Resets all members of the structure @@ -511,7 +463,7 @@ struct PyMemberDef PyDEVMODEW::members[] = { #endif // !MS_WINCE {NULL}}; -// @prop |DeviceName|String of at most 32 chars +// @prop string|DeviceName|String of at most 32 chars PyObject *PyDEVMODEW::get_DeviceName(PyObject *self, void *unused) { PDEVMODEW pdevmode = ((PyDEVMODEW *)self)->pdevmode; diff --git a/win32/src/PyHANDLE.cpp b/win32/src/PyHANDLE.cpp index 98aa539a2a..dd2290aa45 100644 --- a/win32/src/PyHANDLE.cpp +++ b/win32/src/PyHANDLE.cpp @@ -114,9 +114,6 @@ static PyNumberMethods PyHANDLE_NumberMethods = { PyHANDLE::binaryFailureFunc, /* nb_add */ PyHANDLE::binaryFailureFunc, /* nb_subtract */ PyHANDLE::binaryFailureFunc, /* nb_multiply */ -#if (PY_VERSION_HEX < 0x03000000) - PyHANDLE::binaryFailureFunc, /* nb_divide - removed in Py3k */ -#endif PyHANDLE::binaryFailureFunc, /* nb_remainder */ PyHANDLE::binaryFailureFunc, /* nb_divmod */ PyHANDLE::ternaryFailureFunc, /* nb_power */ @@ -131,29 +128,16 @@ static PyNumberMethods PyHANDLE_NumberMethods = { PyHANDLE::binaryFailureFunc, /* nb_and */ PyHANDLE::binaryFailureFunc, /* nb_xor */ PyHANDLE::binaryFailureFunc, /* nb_or */ -#if (PY_VERSION_HEX < 0x03000000) - 0, /* nb_coerce (allowed to be zero) - removed in 3.0 */ -#endif PyHANDLE::intFunc, /* nb_int */ PyHANDLE::longFunc, /* nb_long */ PyHANDLE::unaryFailureFunc, /* nb_float */ // These removed in 3.0 -#if (PY_VERSION_HEX < 0x03000000) - PyHANDLE::unaryFailureFunc, /* nb_oct */ - PyHANDLE::unaryFailureFunc, /* nb_hex */ -#endif }; // @pymeth __int__|Used when an integer representation of the handle object is required. PYWINTYPES_EXPORT PyTypeObject PyHANDLEType = { PYWIN_OBJECT_HEAD "PyHANDLE", sizeof(PyHANDLE), 0, PyHANDLE::deallocFunc, /* tp_dealloc */ -#if (PY_VERSION_HEX < 0x03000000) - // tp_print is 2.x only. - // @pymeth __print__|Used when the object is printed. - PyHANDLE::printFunc, /* tp_print */ -#else 0, -#endif 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ diff --git a/win32/src/PyIID.cpp b/win32/src/PyIID.cpp index da601cb501..5f0042254d 100644 --- a/win32/src/PyIID.cpp +++ b/win32/src/PyIID.cpp @@ -109,33 +109,6 @@ PyObject *PyWinCoreString_FromIID(const IID &riid) return PyWinCoreString_FromString(oleRes); } -#if (PY_VERSION_HEX < 0x03000000) -static Py_ssize_t getreadbuf(PyObject *self, Py_ssize_t index, void **ptr) -{ - if (index != 0) { - PyErr_SetString(PyExc_SystemError, "accessing non-existent IID segment"); - return -1; - } - PyIID *pyiid = (PyIID *)self; - *ptr = &pyiid->m_iid; - return sizeof(IID); -} - -static Py_ssize_t getsegcount(PyObject *self, Py_ssize_t *lenp) -{ - if (lenp) - *lenp = sizeof(IID); - return 1; -} - -static PyBufferProcs PyIID_as_buffer = { - getreadbuf, - 0, - getsegcount, - 0, -}; - -#else // Revised buffer interface for Py3k static int getbufferinfo(PyObject *self, Py_buffer *view, int flags) { PyIID *pyiid = (PyIID *)self; @@ -146,7 +119,6 @@ static PyBufferProcs PyIID_as_buffer = { getbufferinfo, NULL // Don't need to release any memory from Py_buffer struct }; -#endif // @object PyIID|A Python object, representing an IID/CLSID. // All pythoncom functions that return a CLSID/IID will return one of these diff --git a/win32/src/PyLARGE_INTEGER.cpp b/win32/src/PyLARGE_INTEGER.cpp index 2e7aba4a65..5a761a1c11 100644 --- a/win32/src/PyLARGE_INTEGER.cpp +++ b/win32/src/PyLARGE_INTEGER.cpp @@ -20,18 +20,7 @@ BOOL PyWinObject_AsLARGE_INTEGER(PyObject *ob, LARGE_INTEGER *pResult) { -#if (PY_VERSION_HEX < 0x03000000) if (PyLong_Check(ob)) { - // 32 bit integer value. - int x = PyLong_AS_LONG(ob); - if (x == (int)-1 && PyErr_Occurred()) - return FALSE; - LISet32(*pResult, x); - return TRUE; - } - else -#endif - if (PyLong_Check(ob)) { pResult->QuadPart = PyLong_AsLongLong(ob); return !(pResult->QuadPart == -1 && PyErr_Occurred()); } @@ -52,19 +41,6 @@ BOOL PyWinObject_AsLARGE_INTEGER(PyObject *ob, LARGE_INTEGER *pResult) BOOL PyWinObject_AsULARGE_INTEGER(PyObject *ob, ULARGE_INTEGER *pResult) { -#if (PY_VERSION_HEX < 0x03000000) - // py2k - ints and longs are different, and we assume 'int' is 32bits. - if (PyLong_Check(ob)) { - // 32 bit integer value. - int x = PyLong_AS_LONG(ob); - if (x == (int)-1 && PyErr_Occurred()) - return FALSE; - // ### what to do with "negative" integers? Nothing - they - // get treated as unsigned! - ULISet32(*pResult, x); - return TRUE; - } -#endif // py2k if (PyLong_Check(ob)) { pResult->QuadPart = PyLong_AsUnsignedLongLong(ob); return !(pResult->QuadPart == (ULONGLONG)-1 && PyErr_Occurred()); diff --git a/win32/src/PySECURITY_DESCRIPTOR.cpp b/win32/src/PySECURITY_DESCRIPTOR.cpp index ba8937ff4e..9c13e4d6bb 100644 --- a/win32/src/PySECURITY_DESCRIPTOR.cpp +++ b/win32/src/PySECURITY_DESCRIPTOR.cpp @@ -713,33 +713,6 @@ struct PyMethodDef PySECURITY_DESCRIPTOR::methods[] = { {NULL}}; // Buffer interface in Python 3.0 has changed -#if (PY_VERSION_HEX < 0x03000000) -/*static*/ Py_ssize_t PySECURITY_DESCRIPTOR::getreadbuf(PyObject *self, Py_ssize_t index, void **ptr) -{ - if (index != 0) { - PyErr_SetString(PyExc_SystemError, "accessing non-existent SID segment"); - return -1; - } - PySECURITY_DESCRIPTOR *pysd = (PySECURITY_DESCRIPTOR *)self; - *ptr = pysd->m_psd; - return GetSecurityDescriptorLength(pysd->m_psd); -} - -/*static*/ Py_ssize_t PySECURITY_DESCRIPTOR::getsegcount(PyObject *self, Py_ssize_t *lenp) -{ - if (lenp) - *lenp = GetSecurityDescriptorLength(((PySECURITY_DESCRIPTOR *)self)->m_psd); - return 1; -} - -static PyBufferProcs PySECURITY_DESCRIPTOR_as_buffer = { - PySECURITY_DESCRIPTOR::getreadbuf, - 0, - PySECURITY_DESCRIPTOR::getsegcount, - 0, -}; - -#else // New buffer interface for Python 3.0 /*static*/ int PySECURITY_DESCRIPTOR::getbufferinfo(PyObject *self, Py_buffer *view, int flags) { PySECURITY_DESCRIPTOR *pysd = (PySECURITY_DESCRIPTOR *)self; @@ -750,7 +723,6 @@ static PyBufferProcs PySECURITY_DESCRIPTOR_as_buffer = { PySECURITY_DESCRIPTOR::getbufferinfo, NULL // Don't need to release any memory from Py_buffer struct }; -#endif // PY_VERSION_HEX < 0x03000000 PYWINTYPES_EXPORT PyTypeObject PySECURITY_DESCRIPTORType = { PYWIN_OBJECT_HEAD "PySECURITY_DESCRIPTOR", sizeof(PySECURITY_DESCRIPTOR), 0, diff --git a/win32/src/PySecurityObjects.h b/win32/src/PySecurityObjects.h index c457cab212..618f94ed71 100644 --- a/win32/src/PySecurityObjects.h +++ b/win32/src/PySecurityObjects.h @@ -61,12 +61,7 @@ class PYWINTYPES_EXPORT PySECURITY_DESCRIPTOR : public PyObject { int compare(PyObject *ob); static void deallocFunc(PyObject *ob); -#if (PY_VERSION_HEX < 0x03000000) - static Py_ssize_t getreadbuf(PyObject *self, Py_ssize_t index, void **ptr); - static Py_ssize_t getsegcount(PyObject *self, Py_ssize_t *lenp); -#else static int getbufferinfo(PyObject *self, Py_buffer *view, int flags); -#endif static PyObject *Initialize(PyObject *self, PyObject *args); static PyObject *GetSecurityDescriptorOwner(PyObject *self, PyObject *args); @@ -104,12 +99,7 @@ class PYWINTYPES_EXPORT PySID : public PyObject { static PyObject *strFunc(PyObject *ob); // Buffer interface changed in 3.0 -#if (PY_VERSION_HEX < 0x03000000) - static Py_ssize_t getreadbuf(PyObject *self, Py_ssize_t index, void **ptr); - static Py_ssize_t getsegcount(PyObject *self, Py_ssize_t *lenp); -#else static int getbufferinfo(PyObject *self, Py_buffer *view, int flags); -#endif static PyObject *Initialize(PyObject *self, PyObject *args); static PyObject *IsValid(PyObject *self, PyObject *args); diff --git a/win32/src/PyWinTypesmodule.cpp b/win32/src/PyWinTypesmodule.cpp index e755e15e80..86be7a86b3 100644 --- a/win32/src/PyWinTypesmodule.cpp +++ b/win32/src/PyWinTypesmodule.cpp @@ -334,7 +334,7 @@ PyObject *PyWin_SetBasicCOMError(HRESULT hr) return NULL; } -// @pymethod |pywintypes|Unicode|Creates a new Unicode object +// @pymethod string|pywintypes|Unicode|Creates a new Unicode object PYWINTYPES_EXPORT PyObject *PyWin_NewUnicode(PyObject *self, PyObject *args) { char *string; @@ -344,7 +344,7 @@ PYWINTYPES_EXPORT PyObject *PyWin_NewUnicode(PyObject *self, PyObject *args) return PyUnicode_DecodeMBCS(string, slen, NULL); } -// @pymethod |pywintypes|UnicodeFromRaw|Creates a new Unicode object from raw binary data +// @pymethod string|pywintypes|UnicodeFromRaw|Creates a new Unicode object from raw binary data static PyObject *PyWin_NewUnicodeFromRaw(PyObject *self, PyObject *args) { PyObject *ob; @@ -633,21 +633,11 @@ BOOL PyWinObject_AsPARAM(PyObject *ob, WPARAM *pparam) *pparam = NULL; return TRUE; } -// XXX - why this UNICODE block? Can't we just do both anyway? Maybe -// just via the buffer interface? -#ifdef UNICODE -#define TCHAR_DESC "Unicode" + if (PyUnicode_Check(ob)) { *pparam = (WPARAM)PyUnicode_AS_UNICODE(ob); return TRUE; } -#else -#define TCHAR_DESC "String" - if (PyBytes_Check(ob)) { - *pparam = (WPARAM)PyBytes_AS_STRING(ob); - return TRUE; - } -#endif PyWinBufferView pybuf(ob); if (pybuf.ok()) { // note: this might be unsafe, as we give away the buffer pointer to a @@ -660,7 +650,7 @@ BOOL PyWinObject_AsPARAM(PyObject *ob, WPARAM *pparam) if (PyWinLong_AsVoidPtr(ob, (void **)pparam)) return TRUE; - PyErr_Format(PyExc_TypeError, "WPARAM must be a " TCHAR_DESC ", int, or buffer object (got %s)", + PyErr_Format(PyExc_TypeError, "WPARAM must be a unicode string, int, or buffer object (got %s)", ob->ob_type->tp_name); return FALSE; } @@ -798,22 +788,18 @@ static struct PyMethodDef pywintypes_functions[] = { {"DosDateTimeToTime", PyWin_DosDateTimeToTime, 1}, // @pymeth DosDateTimeToTime|Converts an MS-DOS Date/Time to a standard Time object #endif - {"Unicode", PyWin_NewUnicode, 1}, // @pymeth Unicode|Creates a new object + {"Unicode", PyWin_NewUnicode, 1}, // @pymeth Unicode|Creates a new string object {"UnicodeFromRaw", PyWin_NewUnicodeFromRaw, - 1}, // @pymeth UnicodeFromRaw|Creates a new object from raw binary data -#ifndef MS_WINCE + 1}, // @pymeth UnicodeFromRaw|Creates a new string object from raw binary data {"IsTextUnicode", PyWin_IsTextUnicode, 1}, // @pymeth IsTextUnicode|Determines whether a buffer probably contains a form of Unicode text. -#endif {"OVERLAPPED", PyWinMethod_NewOVERLAPPED, 1}, // @pymeth OVERLAPPED|Creates a new object #ifndef NO_PYWINTYPES_IID {"IID", PyWinMethod_NewIID, 1}, // @pymeth IID|Makes an object from a string. #endif {"Time", PyWinMethod_NewTime, 1}, // @pymeth Time|Makes a object from the argument. {"TimeStamp", PyWinMethod_NewTimeStamp, 1}, // @pymeth Time|Makes a object from the argument. -#ifndef MS_WINCE {"CreateGuid", PyWin_CreateGuid, 1}, // @pymeth CreateGuid|Creates a new, unique GUIID. -#endif // MS_WINCE #ifndef NO_PYWINTYPES_SECURITY {"ACL", PyWinMethod_NewACL, 1}, // @pymeth ACL|Creates a new object. {"SID", PyWinMethod_NewSID, 1}, // @pymeth SID|Creates a new object. @@ -851,11 +837,7 @@ int PyWinGlobals_Ensure() PyDict_SetItemString(d, "__name__", name); Py_DECREF(name); PyObject *bimod = PyImport_ImportModule( -#if PY_VERSION_HEX >= 0x03000000 "builtins"); -#else - "__builtin__"); -#endif if ((bimod == NULL) || PyDict_SetItemString(d, "__builtins__", bimod) == -1) { Py_XDECREF(bimod); return -1; @@ -1023,11 +1005,7 @@ PYWIN_MODULE_INIT_FUNC(pywintypes) ADD_TYPE(OVERLAPPEDType); ADD_TYPE(DEVMODEAType); ADD_TYPE(DEVMODEWType); -#ifdef UNICODE if (PyDict_SetItemString(dict, "DEVMODEType", (PyObject *)&PyDEVMODEWType) == -1) -#else - if (PyDict_SetItemString(dict, "DEVMODEType", (PyObject *)&PyDEVMODEAType) == -1) -#endif PYWIN_MODULE_INIT_RETURN_ERROR; ADD_TYPE(WAVEFORMATEXType); diff --git a/win32/src/PythonService.cpp b/win32/src/PythonService.cpp index 42d7061aa4..254077e0e4 100644 --- a/win32/src/PythonService.cpp +++ b/win32/src/PythonService.cpp @@ -245,7 +245,7 @@ static PyObject *PyLogMsg(PyObject *self, PyObject *args) static PyObject *PyLogInfoMsg(PyObject *self, PyObject *args) { PyObject *obMsg; - // @pyparm |msg||The message to write. + // @pyparm string|msg||The message to write. if (!PyArg_ParseTuple(args, "O:LogInfoMsg", &obMsg)) return NULL; return DoLogMessage(EVENTLOG_INFORMATION_TYPE, obMsg); @@ -255,7 +255,7 @@ static PyObject *PyLogInfoMsg(PyObject *self, PyObject *args) static PyObject *PyLogWarningMsg(PyObject *self, PyObject *args) { PyObject *obMsg; - // @pyparm |msg||The message to write. + // @pyparm string|msg||The message to write. if (!PyArg_ParseTuple(args, "O:LogWarningMsg", &obMsg)) return NULL; return DoLogMessage(EVENTLOG_WARNING_TYPE, obMsg); @@ -264,7 +264,7 @@ static PyObject *PyLogWarningMsg(PyObject *self, PyObject *args) // @pymethod |servicemanager|LogErrorMsg|Logs a generic error message to the event log static PyObject *PyLogErrorMsg(PyObject *self, PyObject *args) { - // @pyparm |msg||The message to write. + // @pyparm string|msg||The message to write. PyObject *obMsg; if (!PyArg_ParseTuple(args, "O:LogErrorMsg", &obMsg)) return NULL; @@ -306,7 +306,7 @@ static PyObject *PyRegisterServiceCtrlHandler(PyObject *self, PyObject *args) { PyObject *nameOb, *obCallback; BOOL bUseEx = FALSE; - // @pyparm |serviceName||The name of the service. This is provided in args[0] of the service class + // @pyparm string|serviceName||The name of the service. This is provided in args[0] of the service class // __init__ method. // @pyparm object|callback||The Python function that performs as the control function. This will be called with an // integer status argument. @@ -439,8 +439,8 @@ static PyObject *PyStartServiceCtrlDispatcher(PyObject *self) static PyObject *PyServiceInitialize(PyObject *self, PyObject *args) { PyObject *nameOb = Py_None, *fileOb = Py_None; - // @pyparm |eventSourceName|None|The event source name - // @pyparm |eventSourceFile|None|The name of the file + // @pyparm string|eventSourceName|None|The event source name + // @pyparm string|eventSourceFile|None|The name of the file // (generally a DLL) with the event source messages. if (!PyArg_ParseTuple(args, "|OO", &nameOb, &fileOb)) return NULL; @@ -487,7 +487,7 @@ static PyObject *PyPrepareToHostSingle(PyObject *self, PyObject *args) static PyObject *PyPrepareToHostMultiple(PyObject *self, PyObject *args) { PyObject *klass, *obSvcName; - // @pyparm string/unicode|service_name||The name of the service hosted by the class + // @pyparm string|service_name||The name of the service hosted by the class // @pyparm object|klass||The Python class to host. if (!PyArg_ParseTuple(args, "OO", &obSvcName, &klass)) return NULL; @@ -604,20 +604,7 @@ static void PyService_InitPython() // 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 = 0; - char **pyargv = (char **)malloc(sizeof(char *) * __argc); - if (pyargv) { - for (; pyargc < __argc; pyargc++) { - pyargv[pyargc] = NarrowString(__wargv[pyargc]); - if (!pyargv[pyargc]) { - break; - } - } - } -#else WCHAR **pyargv = CommandLineToArgvW(GetCommandLineW(), &pyargc); -#endif if (pyargv) Py_SetProgramName(pyargv[0]); @@ -637,15 +624,8 @@ static void PyService_InitPython() // though it never is when running as a real service? if (pyargv) PySys_SetArgv(pyargc, pyargv); -#if (PY_VERSION_HEX < 0x03000000) - initservicemanager(); - // free the argv we created above - for (int i = 0; i < pyargc; i++) free(pyargv[i]); - free(pyargv); -#else PyInit_servicemanager(); LocalFree(pyargv); -#endif } /************************************************************************* @@ -1083,11 +1063,7 @@ int PythonService_main(int argc, TCHAR **argv) int temp; LPTSTR *targv; -#ifdef UNICODE targv = CommandLineToArgvW(GetCommandLineW(), &temp); -#else - targv = argv; -#endif // Before we start, change directory to our executable's dir. This // is to prevent our cwd being SYSTEM32, which can have undesired // side effects (ie, it ends up on sys.path and, eg, 'import zlib' may diff --git a/win32/src/_win32sysloader.cpp b/win32/src/_win32sysloader.cpp index c0310a5ee0..cd4cdaacb0 100644 --- a/win32/src/_win32sysloader.cpp +++ b/win32/src/_win32sysloader.cpp @@ -77,18 +77,10 @@ static PyObject *PyLoadModule(PyObject *self, PyObject *args) static struct PyMethodDef functions[] = { {"GetModuleFilename", PyGetModuleFilename, 1}, {"LoadModule", PyLoadModule, 1}, {NULL}}; -extern "C" __declspec(dllexport) -#if (PY_VERSION_HEX < 0x03000000) - void init_win32sysloader(void) -{ - PyObject *module = Py_InitModule("_win32sysloader", functions); -} -#else - PyObject *PyInit__win32sysloader(void) +extern "C" __declspec(dllexport) PyObject *PyInit__win32sysloader(void) { static PyModuleDef _win32sysloader_def = {PyModuleDef_HEAD_INIT, "_win32sysloader", "Exists only to load Pywin32 system modules", -1, functions}; PyObject *module = PyModule_Create(&_win32sysloader_def); return module; } -#endif diff --git a/win32/src/odbc.cpp b/win32/src/odbc.cpp index e58e8f1544..656f512bc0 100644 --- a/win32/src/odbc.cpp +++ b/win32/src/odbc.cpp @@ -893,11 +893,7 @@ static int bindInput(cursorObject *cur, PyObject *vars, int columns) else if (PyWinTime_Check(item)) { rv = ibindDate(cur, iCol, item); } -#if (PY_VERSION_HEX < 0x03000000) - else if (PyBuffer_Check(item)) -#else else if (PyObject_CheckBuffer(item)) -#endif { rv = ibindRaw(cur, iCol, item); } diff --git a/win32/src/win32apimodule.cpp b/win32/src/win32apimodule.cpp index 0476ced500..916e8eab5a 100644 --- a/win32/src/win32apimodule.cpp +++ b/win32/src/win32apimodule.cpp @@ -277,8 +277,8 @@ static PyObject *PyCopyFile(PyObject *self, PyObject *args) PyObject *obSrc, *obDest; if (!PyArg_ParseTuple( args, "OO|i:CopyFile", - &obSrc, // @pyparm string|src||Name of an existing file. - &obDest, // @pyparm string/|dest||Name of file to copy to. + &obSrc, // @pyparm string|src||Name of an existing file. + &obDest, // @pyparm string|dest||Name of file to copy to. &failOnExist)) // @pyparm int|bFailOnExist|0|Indicates if the operation should fail if the file exists. return NULL; TCHAR *src, *dest; @@ -312,7 +312,7 @@ static PyObject *PyDebugBreak(PyObject *self, PyObject *args) static PyObject *PyDeleteFile(PyObject *self, PyObject *args) { PyObject *obPath; - // @pyparm string/|fileName||File to delete. + // @pyparm string|fileName||File to delete. if (!PyArg_ParseTuple(args, "O:DeleteFile", &obPath)) return NULL; TCHAR *szPath; @@ -401,7 +401,7 @@ static PyObject *PyGetEnvironmentVariable(PyObject *self, PyObject *args) return ret; } -// @pymethod |win32api|GetEnvironmentVariableW|Retrieves the unicode value of an environment variable. +// @pymethod string|win32api|GetEnvironmentVariableW|Retrieves the unicode value of an environment variable. // @rdesc Returns None if environment variable is not found // @pyseeapi GetEnvironmentVariableW static PyObject *PyGetEnvironmentVariableW(PyObject *self, PyObject *args) @@ -459,8 +459,8 @@ static PyObject *PySetEnvironmentVariable(PyObject *self, PyObject *args) TCHAR *key = NULL, *val = NULL; PyObject *obkey, *obval, *ret = NULL; if (!PyArg_ParseTuple(args, "OO:SetEnvironmentVariable", - &obkey, // @pyparm str/unicode|Name||Name of the environment variable - &obval)) // @pyparm str/unicode|Value||Value to be set, use None to remove variable + &obkey, // @pyparm string|Name||Name of the environment variable + &obval)) // @pyparm string|Value||Value to be set, use None to remove variable return NULL; // @pyseeapi SetEnvironmentVariable if (PyWinObject_AsTCHAR(obkey, &key, FALSE) && PyWinObject_AsTCHAR(obval, &val, TRUE)) { @@ -818,7 +818,7 @@ static PyObject *PyFormatMessageA(PyObject *self, PyObject *args) return rc; } -// @pymethod |win32api|FormatMessageW|Returns an error message from the system error file. +// @pymethod string|win32api|FormatMessageW|Returns an error message from the system error file. static PyObject *PyFormatMessageW(PyObject *self, PyObject *args) { int errCode = 0; @@ -845,13 +845,13 @@ static PyObject *PyFormatMessageW(PyObject *self, PyObject *args) // Full parameter list // @pyparmalt1 int|flags||Flags for the call. Note that FORMAT_MESSAGE_ALLOCATE_BUFFER and // FORMAT_MESSAGE_ARGUMENT_ARRAY will always be added. - // @pyparmalt1 int/|source||The source object. If flags contain FORMAT_MESSAGE_FROM_HMODULE it should + // @pyparmalt1 int/string|source||The source object. If flags contain FORMAT_MESSAGE_FROM_HMODULE it should // be an int or ; - // if flags contain FORMAT_MESSAGE_FROM_STRING it should be a unicode string; + // if flags contain FORMAT_MESSAGE_FROM_STRING it should be a string; // otherwise it is ignored. // @pyparmalt1 int|messageId||The message ID. // @pyparmalt1 int|languageID||The language ID. - // @pyparmalt1 [,...]/None|inserts||The string inserts to insert. + // @pyparmalt1 [string,...]/None|inserts||The string inserts to insert. DWORD flags, msgId, langId; PyObject *obSource; PyObject *obInserts, *Inserts_tuple = NULL; @@ -1314,7 +1314,7 @@ static PyObject *PyLoadCursor(PyObject *self, PyObject *args) return PyWinLong_FromHANDLE(ret); } -// @pymethod [string]|win32api|CommandLineToArgv|Parses a Unicode command line string and returns a list of command line arguments, in a way that is similar to sys.argv. +// @pymethod [string]|win32api|CommandLineToArgv|Parses a command line string and returns a list of command line arguments, in a way that is similar to sys.argv. static PyObject *PyCommandLineToArgv(PyObject *self, PyObject *args) { const Py_UNICODE *cmdLine; @@ -1444,29 +1444,16 @@ static PyObject *PyGetAsyncKeyState(PyObject *self, PyObject *args) static PyObject *PyGetFileAttributes(PyObject *self, PyObject *args) { PyObject *obPathName; - // @pyparm string|pathName||The name of the file whose attributes are to be returned. - // If this param is a unicode object, GetFileAttributesW is called. + // @pyparm string/bytes|pathName||The name of the file whose attributes are to be returned. + // This calls the Windows GetFileAttributesW function. if (!PyArg_ParseTuple(args, "O:GetFileAttributes", &obPathName)) return NULL; DWORD rc; -#ifdef UNICODE WCHAR *PathName; if (!PyWinObject_AsWCHAR(obPathName, &PathName, FALSE)) return NULL; rc = ::GetFileAttributesW(PathName); PyWinObject_FreeWCHAR(PathName); -#else - if (PyBytes_Check(obPathName)) { - PyW32_BEGIN_ALLOW_THREADS rc = ::GetFileAttributesA(PyBytes_AS_STRING(obPathName)); - PyW32_END_ALLOW_THREADS - } - else if (PyUnicode_Check(obPathName)) { - PyW32_BEGIN_ALLOW_THREADS rc = ::GetFileAttributesW(PyUnicode_AS_UNICODE(obPathName)); - PyW32_END_ALLOW_THREADS - } - else - return PyErr_Format(PyExc_TypeError, "pathName arg must be string or unicode"); -#endif if (rc == (DWORD)0xFFFFFFFF) return ReturnAPIError("GetFileAttributes"); return Py_BuildValue("i", rc); diff --git a/win32/src/win32clipboardmodule.cpp b/win32/src/win32clipboardmodule.cpp index 1ce038bb8b..f4d782dc0a 100644 --- a/win32/src/win32clipboardmodule.cpp +++ b/win32/src/win32clipboardmodule.cpp @@ -1,6 +1,4 @@ /****************************************************************************** - $Revision$ - A simple interface to win32 clipboard API Author: Roger Burnham, rburnham@cri-inc.com @@ -274,7 +272,7 @@ static PyObject *py_get_clipboard_data_handle(PyObject *self, PyObject *args) //***************************************************************************** // -// @pymethod string/unicode|win32clipboard|GetClipboardData|The GetClipboardData function +// @pymethod string|win32clipboard|GetClipboardData|The GetClipboardData function // retrieves data from the clipboard in a specified format. The clipboard // must have been opened previously. Note that not all data formats are supported, // and that the underlying handle can be retrieved with @@ -284,14 +282,9 @@ static PyObject *py_get_clipboard_data(PyObject *self, PyObject *args) { PyObject *ret; - // @pyparm int|format|CF_TEXT|Specifies a clipboard format. For a description of + // @pyparm int|format|CF_UNICODETEXT|Specifies a clipboard format. For a description of // the standard clipboard formats, see Standard Clipboard Formats. - // In Unicode builds (ie, python 3k), the default is CF_UNICODETEXT. -#ifdef UNICODE int format = CF_UNICODETEXT; -#else - int format = CF_TEXT; -#endif if (!PyArg_ParseTuple(args, "|i:GetClipboardData:", &format)) { return NULL; } @@ -439,9 +432,9 @@ static PyObject *py_get_clipboard_data(PyObject *self, PyObject *args) // described in the following table: // @flagh Format|Result type // @flag CF_HDROP|A tuple of Unicode filenames. - // @flag CF_UNICODETEXT|A unicode object. - // @flag CF_OEMTEXT|A string object. - // @flag CF_TEXT|A string object. + // @flag CF_UNICODETEXT|A string object. + // @flag CF_OEMTEXT|A bytes object. + // @flag CF_TEXT|A bytes object. // @flag CF_ENHMETAFILE|A string with binary data obtained from GetEnhMetaFileBits // @flag CF_METAFILEPICT|A string with binary data obtained from GetMetaFileBitsEx (currently broken) // @flag CF_BITMAP|An integer handle to the bitmap. @@ -903,7 +896,7 @@ static PyObject *py_set_clipboard_data(PyObject *self, PyObject *args) // // @pymethod int|win32clipboard|SetClipboardText|Convienience function to // call SetClipboardData with text. -// @comm You may pass a Unicode or string/bytes object to this function, +// @comm You may pass a string or bytes object to this function, // but depending on the value of the 'format' param, it may be converted // to the appropriate type for that param. // @comm Many applications will want to call this function twice, with the @@ -1145,13 +1138,7 @@ PYWIN_MODULE_INIT_FUNC(win32clipboard) PYWIN_MODULE_INIT_RETURN_ERROR; if (PyDict_SetItemString(dict, "error", PyWinExc_ApiError) == -1) PYWIN_MODULE_INIT_RETURN_ERROR; - if (PyDict_SetItemString(dict, "UNICODE", -#ifdef UNICODE - Py_True -#else - Py_False -#endif - ) == -1) + if (PyDict_SetItemString(dict, "UNICODE", Py_True) == -1) PYWIN_MODULE_INIT_RETURN_ERROR; PYWIN_MODULE_INIT_RETURN_SUCCESS; } diff --git a/win32/src/win32crypt/win32cryptmodule.cpp b/win32/src/win32crypt/win32cryptmodule.cpp index d5a00a843a..368bdc1243 100644 --- a/win32/src/win32crypt/win32cryptmodule.cpp +++ b/win32/src/win32crypt/win32cryptmodule.cpp @@ -2200,7 +2200,5 @@ PYWIN_MODULE_INIT_FUNC(win32crypt) dummy_tuple = PyTuple_New(0); -#if (PY_VERSION_HEX >= 0x03000000) return module; -#endif -} \ No newline at end of file +} diff --git a/win32/src/win32file.i b/win32/src/win32file.i index 7ce5886b46..9f98b17446 100644 --- a/win32/src/win32file.i +++ b/win32/src/win32file.i @@ -77,20 +77,6 @@ #include "datetime.h" // python's datetime header. -// older python version's don't get the PyCObject structure definition -// exposed, and we need it to cleanly zap our handles (see -// CloseEncryptedFileRaw below). -// Fortunately, the PyCObject structure has been identical from versions -// 2.3->2.6 - and 2.6 is where it is first made public. -#if (PY_VERSION_HEX < 0x02060000) -typedef struct { - PyObject_HEAD - void *cobject; - void *desc; - void (*destructor)(void *); -} PyCObject; - -#endif %} #define FILE_GENERIC_READ FILE_GENERIC_READ @@ -216,31 +202,31 @@ BOOLAPI CancelIo(PyHANDLE handle); // @pyswig |CopyFile|Copies a file BOOLAPI CopyFile( - TCHAR *from, // @pyparm |from||The name of the file to copy from - TCHAR *to, // @pyparm |to||The name of the file to copy to + TCHAR *from, // @pyparm string|from||The name of the file to copy from + TCHAR *to, // @pyparm string|to||The name of the file to copy to BOOL bFailIfExists); // @pyparm int|bFailIfExists||Indicates if the operation should fail if the file exists. -// @pyswig |CopyFileW|Copies a file (NT/2000 Unicode specific version) +// @pyswig |CopyFileW|Copies a file BOOLAPI CopyFileW( - WCHAR *from, // @pyparm |from||The name of the file to copy from - WCHAR *to, // @pyparm |to||The name of the file to copy to + WCHAR *from, // @pyparm string|from||The name of the file to copy from + WCHAR *to, // @pyparm string|to||The name of the file to copy to BOOL bFailIfExists); // @pyparm int|bFailIfExists||Indicates if the operation should fail if the file exists. // @pyswig |CreateDirectory|Creates a directory BOOLAPI CreateDirectory( - TCHAR *name, // @pyparm |name||The name of the directory to create + TCHAR *name, // @pyparm string|name||The name of the directory to create SECURITY_ATTRIBUTES *pSA); // @pyparm |sa||The security attributes, or None -// @pyswig |CreateDirectoryW|Creates a directory (NT/2000 Unicode specific version) +// @pyswig |CreateDirectoryW|Creates a directory BOOLAPI CreateDirectoryW( - WCHAR *name, // @pyparm |name||The name of the directory to create + WCHAR *name, // @pyparm string|name||The name of the directory to create SECURITY_ATTRIBUTES *pSA); // @pyparm |sa||The security attributes, or None #ifndef MS_WINCE // @pyswig |CreateDirectoryEx|Creates a directory BOOLAPI CreateDirectoryEx( - TCHAR *templateName, // @pyparm |templateName||Specifies the path of the directory to use as a template when creating the new directory. - TCHAR *newDirectory, // @pyparm |newDirectory||Specifies the name of the new directory + TCHAR *templateName, // @pyparm string|templateName||Specifies the path of the directory to use as a template when creating the new directory. + TCHAR *newDirectory, // @pyparm string|newDirectory||Specifies the name of the new directory SECURITY_ATTRIBUTES *pSA); // @pyparm |sa||The security attributes, or None #endif // MS_WINCE @@ -248,7 +234,7 @@ BOOLAPI CreateDirectoryEx( // @pyswig |CreateFile|Creates or opens the a file or other object and returns a handle that can be used to access the object. // @comm The following objects can be opened:filespipesmailslotscommunications resourcesdisk devices (Windows NT only)consolesdirectories (open only) PyHANDLE CreateFile( - TCHAR *lpFileName, // @pyparm |fileName||The name of the file + TCHAR *lpFileName, // @pyparm string|fileName||The name of the file DWORD dwDesiredAccess, // @pyparm int|desiredAccess||access (read-write) mode // Specifies the type of access to the object. An application can obtain read access, write access, read-write access, or device query access. This parameter can be any combination of the following values. // @flagh Value|Meaning @@ -350,26 +336,25 @@ BOOLAPI SetMailslotInfo( HANDLE Mailslot, // @pyparm |Mailslot||Handle to a mailslot DWORD ReadTimeout); // @pyparm int|ReadTimeout||Timeout in milliseconds, use -1 for no timeout -// @pyswig |DefineDosDevice|Lets an application define, redefine, or delete MS-DOS device names. +// @pyswig |DefineDosDevice|Lets an application define, redefine, or delete MS-DOS device names. BOOLAPI DefineDosDevice( - DWORD dwFlags, // @pyparm int|flags||flags specifying aspects of device definition - TCHAR *lpDeviceName, // @pyparm |deviceName||MS-DOS device name string - TCHAR *lpTargetPath // @pyparm |targetPath||MS-DOS or path string for 32-bit Windows. + DWORD dwFlags, // @pyparm int|flags||flags specifying aspects of device definition + TCHAR *lpDeviceName, // @pyparm string|deviceName||MS-DOS device name string + TCHAR *lpTargetPath // @pyparm string|targetPath||MS-DOS or path string for 32-bit Windows. ); -// @pyswig |DefineDosDeviceW|Lets an application define, redefine, or delete MS-DOS device names. (NT/2000 Unicode specific version) +// @pyswig |DefineDosDeviceW|Lets an application define, redefine, or delete MS-DOS device names. BOOLAPI DefineDosDeviceW( - DWORD dwFlags, // @pyparm int|flags||flags specifying aspects of device definition - WCHAR *lpDeviceName, // @pyparm |deviceName||MS-DOS device name string - WCHAR *lpTargetPath // @pyparm |targetPath||MS-DOS or path string for 32-bit Windows. + DWORD dwFlags, // @pyparm int|flags||flags specifying aspects of device definition + WCHAR *lpDeviceName, // @pyparm string|deviceName||MS-DOS device name string + WCHAR *lpTargetPath // @pyparm string|targetPath||MS-DOS or path string for 32-bit Windows. ); #endif // MS_WINCE // @pyswig |DeleteFile|Deletes a file. BOOLAPI DeleteFile(TCHAR *fileName); -// @pyparm |fileName||The filename to delete +// @pyparm string|fileName||The filename to delete %{ -#if (PY_VERSION_HEX >= 0x03000000) // theoretically this could be in pywintypes, but this is the only place // it is called... @@ -385,8 +370,6 @@ static PyObject *PyBuffer_FromReadWriteMemory(void *buf, Py_ssize_t size){ return NULL; return PyMemoryView_FromBuffer(&info); } -#endif - // @pyswig str/buffer|DeviceIoControl|Sends a control code to a device or file system driver @@ -495,11 +478,7 @@ PyObject *py_DeviceIoControl(PyObject *self, PyObject *args, PyObject *kwargs) if (bBuffer){ // Create a view of existing buffer with actual output size // Memoryview object in py3k supports slicing - #if (PY_VERSION_HEX >= 0x03000000) - PyObject *resized=PySequence_GetSlice(ret, 0, numRead); - #else - PyObject *resized=PyBuffer_FromReadWriteObject(ret, 0, numRead); - #endif + PyObject *resized=PySequence_GetSlice(ret, 0, numRead); Py_DECREF(ret); ret=resized; } @@ -530,7 +509,7 @@ BOOLAPI FindCloseChangeNotification( // @pyswig int|FindFirstChangeNotification|Creates a change notification handle and sets up initial change notification filter conditions. A wait on a notification handle succeeds when a change matching the filter conditions occurs in the specified directory or subtree. HANDLE FindFirstChangeNotification( - TCHAR *lpPathName, // @pyparm |pathName||Name of directory to watch + TCHAR *lpPathName, // @pyparm string|pathName||Name of directory to watch BOOL bWatchSubtree, // @pyparm int|bWatchSubtree||flag for monitoring directory or directory tree DWORD dwNotifyFilter // @pyparm int|notifyFilter||filter conditions to watch for. See for details. ); @@ -636,7 +615,7 @@ BOOLAPI FlushFileBuffers( #ifndef MS_WINCE // @pyswig int|GetBinaryType|Determines whether a file is executable, and if so, what type of executable file it is. That last property determines which subsystem an executable file runs under. BOOLAPI GetBinaryType( - TCHAR *lpApplicationName, // @pyparm |appName||Fully qualified path of file to test + TCHAR *lpApplicationName, // @pyparm string|appName||Fully qualified path of file to test unsigned long *OUTPUT // DWORD ); #define SCS_32BIT_BINARY SCS_32BIT_BINARY // A Win32-based application @@ -652,7 +631,7 @@ BOOLAPI GetBinaryType( #ifndef MS_WINCE // @pyswig (int, int, int, int)|GetDiskFreeSpace|Determines the free space on a device. BOOLAPI GetDiskFreeSpace( - TCHAR *lpRootPathName, // @pyparm |rootPathName||address of root path + TCHAR *lpRootPathName, // @pyparm string|rootPathName||address of root path unsigned long *OUTPUT, unsigned long *OUTPUT, unsigned long *OUTPUT, @@ -660,26 +639,26 @@ BOOLAPI GetDiskFreeSpace( // @rdesc The result is a tuple of integers representing (sectors per cluster, bytes per sector, number of free clusters, total number of clusters) ); -// GetDiskFreeSpaceEx +// GetDiskFreeSpaceEx // @pyswig long, long, long|GetDiskFreeSpaceEx|Determines the free space on a device. BOOLAPI GetDiskFreeSpaceEx( - TCHAR *lpRootPathName, // @pyparm |rootPathName||address of root path - ULARGE_INTEGER *OUTPUT, + TCHAR *lpRootPathName, // @pyparm string|rootPathName||address of root path + ULARGE_INTEGER *OUTPUT, ULARGE_INTEGER *OUTPUT, - ULARGE_INTEGER *OUTPUT + ULARGE_INTEGER *OUTPUT // @rdesc The result is a tuple of long integers: // @tupleitem 0|long integer|freeBytes|The total number of free bytes on the disk that are available to the user associated with the calling thread. // @tupleitem 1|long integer|totalBytes|The total number of bytes on the disk that are available to the user associated with the calling thread. -// Windows 2000: If per-user quotas are in use, this value may be less than the total number of bytes on the disk. -// @tupleitem 2|long integer|totalFreeBytes|The total number of free bytes on the disk. +// If per-user quotas are in use, this value may be less than the total number of bytes on the disk. +// @tupleitem 2|long integer|totalFreeBytes|The total number of free bytes on the disk. ); -// @pyswig int|GetDriveType|Determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive. +// @pyswig int|GetDriveType|Determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive. long GetDriveType( TCHAR *rootPathName // @pyparm string|rootPathName|| // @rdesc The result is one of the DRIVE_* constants. ); -// @pyswig int|GetDriveTypeW|Determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive. (NT/2000 Unicode specific version). +// @pyswig int|GetDriveTypeW|Determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive. long GetDriveTypeW( WCHAR *rootPathName // @pyparm string|rootPathName|| // @rdesc The result is one of the DRIVE_* constants. @@ -697,21 +676,12 @@ long GetDriveTypeW( // @pyswig int|GetFileAttributes|Determines a files attributes. -// @comm The win32file module exposes and -// separately - both functions will accept -// either strings or Unicode objects but will always call the named function. -// This is different than , which only exposes -// one Python function and automatically calls the appropriate win32 function -// based on the type of the filename param. DWORD GetFileAttributes( - TCHAR *fileName); // @pyparm |fileName||Name of the file to retrieve attributes for. + TCHAR *fileName); // @pyparm string|fileName||Name of the file to retrieve attributes for. -// @pyswig int|GetFileAttributesW|Determines a files attributes (NT/2000 Unicode specific version). -// @comm Note that will automatically call -// GetFileAttributesW when passed a unicode filename param. See -// and for more. +// @pyswig int|GetFileAttributesW|Determines a files attributes DWORD GetFileAttributesW( - WCHAR *fileName); // @pyparm |fileName||Name of the file to retrieve attributes for. + WCHAR *fileName); // @pyparm string|fileName||Name of the file to retrieve attributes for. // @pyswig (, , )|GetFileTime|Returns a file's creation, last access, and modification times. // @comm Times are returned in UTC time. @@ -1326,11 +1296,11 @@ BOOLAPI GetOverlappedResult( #ifndef MS_WINCE // @pyswig |LockFile|Locks a specified file for exclusive access by the calling process. BOOLAPI LockFile( - PyHANDLE hFile, // @pyparm |hFile||handle of file to lock - DWORD dwFileOffsetLow, // @pyparm int|offsetLow||low-order word of lock region offset - DWORD dwFileOffsetHigh, // @pyparm int|offsetHigh||high-order word of lock region offset - DWORD nNumberOfBytesToLockLow, // @pyparm int|nNumberOfBytesToLockLow||low-order word of length to lock - DWORD nNumberOfBytesToLockHigh // @pyparm int|nNumberOfBytesToLockHigh||high-order word of length to lock + PyHANDLE hFile, // @pyparm |hFile||handle of file to lock + DWORD dwFileOffsetLow, // @pyparm int|offsetLow||low-order word of lock region offset + DWORD dwFileOffsetHigh, // @pyparm int|offsetHigh||high-order word of lock region offset + DWORD nNumberOfBytesToLockLow, // @pyparm int|nNumberOfBytesToLockLow||low-order word of length to lock + DWORD nNumberOfBytesToLockHigh // @pyparm int|nNumberOfBytesToLockHigh||high-order word of length to lock ); %native(LockFileEx) MyLockFileEx; @@ -1338,28 +1308,28 @@ BOOLAPI LockFile( #endif // MS_WINCE -// @pyswig |MoveFile|Renames an existing file or a directory (including all its children). +// @pyswig |MoveFile|Renames an existing file or a directory (including all its children). BOOLAPI MoveFile( - TCHAR *lpExistingFileName, // @pyparm |existingFileName||Name of the existing file - TCHAR *lpNewFileName // @pyparm |newFileName||New name for the file + TCHAR *lpExistingFileName, // @pyparm string|existingFileName||Name of the existing file + TCHAR *lpNewFileName // @pyparm string|newFileName||New name for the file ); -// @pyswig |MoveFileW|Renames an existing file or a directory (including all its children). (NT/2000 Unicode specific version). +// @pyswig |MoveFileW|Renames an existing file or a directory (including all its children). BOOLAPI MoveFileW( - WCHAR *lpExistingFileName, // @pyparm |existingFileName||Name of the existing file - WCHAR *lpNewFileName // @pyparm |newFileName||New name for the file + WCHAR *lpExistingFileName, // @pyparm string|existingFileName||Name of the existing file + WCHAR *lpNewFileName // @pyparm string|newFileName||New name for the file ); #ifndef MS_WINCE -// @pyswig |MoveFileEx|Renames an existing file or a directory (including all its children). +// @pyswig |MoveFileEx|Renames an existing file or a directory (including all its children). BOOLAPI MoveFileEx( - TCHAR *lpExistingFileName, // @pyparm |existingFileName||Name of the existing file - TCHAR *INPUT_NULLOK, // @pyparm |newFileName||New name for the file, can be None for delayed delete operation + TCHAR *lpExistingFileName, // @pyparm string|existingFileName||Name of the existing file + TCHAR *INPUT_NULLOK, // @pyparm string|newFileName||New name for the file, can be None for delayed delete operation DWORD dwFlags // @pyparm int|flags||flag to determine how to move file (win32file.MOVEFILE_*) ); -// @pyswig |MoveFileExW|Renames an existing file or a directory (including all its children). (NT/2000 Unicode specific version). +// @pyswig |MoveFileExW|Renames an existing file or a directory (including all its children). BOOLAPI MoveFileExW( - WCHAR *lpExistingFileName, // @pyparm |existingFileName||Name of the existing file - WCHAR *INPUT_NULLOK, // @pyparm |newFileName||New name for the file, can be None for delayed delete operation + WCHAR *lpExistingFileName, // @pyparm string|existingFileName||Name of the existing file + WCHAR *INPUT_NULLOK, // @pyparm string|newFileName||New name for the file, can be None for delayed delete operation DWORD dwFlags // @pyparm int|flags||flag to determine how to move file (win32file.MOVEFILE_*) ); #define MOVEFILE_COPY_ALLOWED MOVEFILE_COPY_ALLOWED // If the file is to be moved to a different volume, the function simulates the move by using the CopyFile and DeleteFile functions. Cannot be combined with the MOVEFILE_DELAY_UNTIL_REBOOT flag. @@ -1577,7 +1547,7 @@ PyObject *PyFILE_NOTIFY_INFORMATION(PyObject *self, PyObject *args) #ifndef MS_WINCE // @pyswig |SetCurrentDirectory|Sets the current directory. %name(SetCurrentDirectory) BOOLAPI SetCurrentDirectoryW( - WCHAR *lpPathName // @pyparm str/|lpPathName||Name of the path to set current. + WCHAR *lpPathName // @pyparm str/string|lpPathName||Name of the path to set current. ); #endif // MS_WINCE @@ -1596,7 +1566,7 @@ void SetFileApisToOEM(void); // @pyswig |SetFileAttributes|Changes a file's attributes. BOOLAPI SetFileAttributes( - TCHAR *lpFileName, // @pyparm |filename||filename + TCHAR *lpFileName, // @pyparm string|filename||filename DWORD dwFileAttributes // @pyparm int|newAttributes||attributes to set ); @@ -1644,8 +1614,8 @@ PyObject *MySetFilePointer(PyObject *self, PyObject *args) #ifndef MS_WINCE // @pyswig |SetVolumeLabel|Sets a volume label for a disk drive. BOOLAPI SetVolumeLabel( - TCHAR *lpRootPathName, // @pyparm |rootPathName||address of name of root directory for volume - TCHAR *lpVolumeName // @pyparm |volumeName||name for the volume + TCHAR *lpRootPathName, // @pyparm string|rootPathName||address of name of root directory for volume + TCHAR *lpVolumeName // @pyparm string|volumeName||name for the volume ); // @pyswig |UnlockFile|Unlocks a region of a file locked by or @@ -1861,7 +1831,7 @@ static PyObject *py_ConnectEx( PyObject *self, PyObject *args, PyObject *kwargs "getaddrinfo() argument 1 must be string or None"); return NULL; } - + if (pobj == Py_None) { pptr = NULL; } else if (PyUnicode_Check(pobj)) { @@ -3050,7 +3020,7 @@ typedef BOOL (WINAPI *SfcIsFileProtectedfunc)(HANDLE,LPCWSTR); static SfcIsFileProtectedfunc pfnSfcIsFileProtected = NULL; -// @pyswig |SetVolumeMountPoint|Mounts the specified volume at the specified volume mount point. +// @pyswig string|SetVolumeMountPoint|Mounts the specified volume at the specified volume mount point. // @comm Accepts keyword args. static PyObject* py_SetVolumeMountPoint(PyObject *self, PyObject *args, PyObject *kwargs) @@ -3068,8 +3038,8 @@ py_SetVolumeMountPoint(PyObject *self, PyObject *args, PyObject *kwargs) WCHAR volume_name[50]; static char *keywords[]={"VolumeMountPoint", "VolumeName", NULL}; if (!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:SetVolumeMountPoint",keywords, - &mount_point_obj, // @pyparm |VolumeMountPoint||The mount point - must be an existing empty directory on an NTFS volume - &volume_obj)) // @pyparm |VolumeName||The volume to mount there + &mount_point_obj, // @pyparm string|VolumeMountPoint||The mount point - must be an existing empty directory on an NTFS volume + &volume_obj)) // @pyparm string|VolumeName||The volume to mount there return NULL; if (PyWinObject_AsWCHAR(mount_point_obj, &mount_point, false) @@ -3102,7 +3072,7 @@ py_DeleteVolumeMountPoint(PyObject *self, PyObject *args, PyObject *kwargs) WCHAR *mount_point = NULL; static char *keywords[]={"VolumeMountPoint", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:DeleteVolumeMountPoint", keywords, - &mount_point_obj)) // @pyparm |VolumeMountPoint||The mount point to delete - must have a trailing backslash. + &mount_point_obj)) // @pyparm string|VolumeMountPoint||The mount point to delete - must have a trailing backslash. return NULL; if (!PyWinObject_AsWCHAR(mount_point_obj, &mount_point, FALSE)) return NULL; @@ -3118,7 +3088,7 @@ py_DeleteVolumeMountPoint(PyObject *self, PyObject *args, PyObject *kwargs) } PyCFunction pfnpy_DeleteVolumeMountPoint=(PyCFunction)py_DeleteVolumeMountPoint; -// @pyswig |GetVolumeNameForVolumeMountPoint|Returns unique volume name. +// @pyswig string|GetVolumeNameForVolumeMountPoint|Returns unique volume name. // @comm Requires Win2K or later. // @comm Accepts keyword args. static PyObject *py_GetVolumeNameForVolumeMountPoint(PyObject *self, PyObject *args, PyObject *kwargs) @@ -3132,7 +3102,7 @@ static PyObject *py_GetVolumeNameForVolumeMountPoint(PyObject *self, PyObject *a static char *keywords[]={"VolumeMountPoint", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GetVolumeNameForVolumeMountPoint", keywords, - &obmount_point)) // @pyparm |VolumeMountPoint||Volume mount point or root drive - trailing backslash required + &obmount_point)) // @pyparm string|VolumeMountPoint||Volume mount point or root drive - trailing backslash required return NULL; if (!PyWinObject_AsWCHAR(obmount_point, &mount_point, false)) return NULL; @@ -3145,7 +3115,7 @@ static PyObject *py_GetVolumeNameForVolumeMountPoint(PyObject *self, PyObject *a } PyCFunction pfnpy_GetVolumeNameForVolumeMountPoint=(PyCFunction)py_GetVolumeNameForVolumeMountPoint; -// @pyswig |GetVolumePathName|Returns volume mount point for a path +// @pyswig string|GetVolumePathName|Returns volume mount point for a path // @comm Api gives no indication of how much memory is needed, so function assumes returned path // will not be longer that length of input path + 1. // Use GetFullPathName first for relative paths, or GetLongPathName for 8.3 paths. @@ -3160,7 +3130,7 @@ static PyObject *py_GetVolumePathName(PyObject *self, PyObject *args, PyObject * CHECK_PFN(GetVolumePathName); static char *keywords[]={"FileName","BufferLength", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|l:GetVolumePathName", keywords, - &obpath, // @pyparm |FileName||File/dir for which to return volume mount point + &obpath, // @pyparm string|FileName||File/dir for which to return volume mount point &bufsize)) // @pyparm int|BufferLength|0|Optional parm to allocate extra space for returned string return NULL; if (!PyWinObject_AsWCHAR(obpath, &path, FALSE, &pathlen)) @@ -3187,7 +3157,7 @@ static PyObject *py_GetVolumePathName(PyObject *self, PyObject *args, PyObject * } PyCFunction pfnpy_GetVolumePathName=(PyCFunction)py_GetVolumePathName; -// @pyswig [,...]|GetVolumePathNamesForVolumeName|Returns mounted paths for a volume +// @pyswig [string,...]|GetVolumePathNamesForVolumeName|Returns mounted paths for a volume // @comm Requires WinXP or later // @comm Accepts keyword args static PyObject *py_GetVolumePathNamesForVolumeName(PyObject *self, PyObject *args, PyObject *kwargs) @@ -3199,7 +3169,7 @@ static PyObject *py_GetVolumePathNamesForVolumeName(PyObject *self, PyObject *ar static char *keywords[]={"VolumeName", NULL}; CHECK_PFN(GetVolumePathNamesForVolumeName); if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GetVolumePathNamesForVolumeName", keywords, - &obvolume)) // @pyparm |VolumeName||Name of a volume as returned by + &obvolume)) // @pyparm string|VolumeName||Name of a volume as returned by return NULL; if (!PyWinObject_AsWCHAR(obvolume, &volume, FALSE)) return NULL; @@ -3254,8 +3224,8 @@ py_CreateHardLink(PyObject *self, PyObject *args, PyObject *kwargs) static char *keywords[]={"FileName","ExistingFileName","SecurityAttributes","Transaction", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|OO:CreateHardLink", keywords, - &new_file_obj, // @pyparm |FileName||The name of the new directory entry to be created. - &existing_file_obj, // @pyparm |ExistingFileName||The name of the existing file to which the new link will point. + &new_file_obj, // @pyparm string|FileName||The name of the new directory entry to be created. + &existing_file_obj, // @pyparm string|ExistingFileName||The name of the existing file to which the new link will point. &sa_obj, // @pyparm |SecurityAttributes|None|Optional SECURITY_ATTRIBUTES object. MSDN describes this parameter as reserved, so use only None &trans_obj)) // @pyparm |Transaction|None|Handle to a transaction, as returned by return NULL; @@ -3303,8 +3273,8 @@ static PyObject *py_CreateSymbolicLink(PyObject *self, PyObject *args, PyObject static char *keywords[]={"SymlinkFileName","TargetFileName","Flags","Transaction", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|kO:CreateSymbolicLink", keywords, - &oblinkname, // @pyparm |SymlinkFileName||Path of the symbolic link to be created - &obtargetname, // @pyparm |TargetFileName||The name of file to which link will point + &oblinkname, // @pyparm string|SymlinkFileName||Path of the symbolic link to be created + &obtargetname, // @pyparm string|TargetFileName||The name of file to which link will point &flags, // @pyparm int|Flags|0|SYMBOLIC_LINK_FLAG_DIRECTORY and SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE are the only defined flags &obtrans)) // @pyparm |Transaction|None|Handle to a transaction, as returned by return NULL; @@ -3341,7 +3311,7 @@ static PyObject* py_EncryptFile(PyObject *self, PyObject *args) { CHECK_PFN(EncryptFile); - // @pyparm string/unicode|filename||File to encrypt + // @pyparm string|filename||File to encrypt PyObject *ret=NULL, *obfname=NULL; WCHAR *fname = NULL; @@ -3363,7 +3333,7 @@ static PyObject* py_DecryptFile(PyObject *self, PyObject *args) { CHECK_PFN(DecryptFile); - // @pyparm string/unicode|filename||File to decrypt + // @pyparm string|filename||File to decrypt PyObject *ret=NULL, *obfname=NULL; WCHAR *fname = NULL; DWORD reserved=0; @@ -3386,7 +3356,7 @@ static PyObject* py_EncryptionDisable(PyObject *self, PyObject *args) { CHECK_PFN(EncryptionDisable); - // @pyparm string/unicode|DirName||Directory to enable or disable + // @pyparm string|DirName||Directory to enable or disable // @pyparm boolean|Disable||Set to False to enable encryption PyObject *ret=NULL, *obfname=NULL; WCHAR *fname = NULL; @@ -3415,7 +3385,7 @@ static PyObject* py_FileEncryptionStatus(PyObject *self, PyObject *args) { CHECK_PFN(FileEncryptionStatus); - // @pyparm string/unicode|FileName||file to query + // @pyparm string|FileName||file to query PyObject *ret=NULL, *obfname=NULL; WCHAR *fname = NULL; DWORD Status=0; @@ -3613,7 +3583,7 @@ BOOL PyWinObject_AsPENCRYPTION_CERTIFICATE_LIST(PyObject *obcert_list, PENCRYPTI BOOL PyWinObject_AsPENCRYPTION_CERTIFICATE_HASH_LIST(PyObject *obhash_list, PENCRYPTION_CERTIFICATE_HASH_LIST pechl) { - char *err_msg="ENCRYPTION_CERTIFICATE_HASH_LIST must be represented as a sequence of sequences of (PySID, string, unicode)"; + char *err_msg="ENCRYPTION_CERTIFICATE_HASH_LIST must be represented as a sequence of sequences of (PySID, bytes, string)"; BOOL bSuccess=TRUE; DWORD hash_cnt=0, hash_ind=0; PENCRYPTION_CERTIFICATE_HASH *ppech=NULL; @@ -3697,12 +3667,12 @@ BOOL PyWinObject_AsPENCRYPTION_CERTIFICATE_HASH_LIST(PyObject *obhash_list, PENC } -// @pyswig (,string,unicode)|QueryUsersOnEncryptedFile|Returns list of users for an encrypted file as tuples of (SID, certificate hash blob, display info) +// @pyswig (,bytes,string)|QueryUsersOnEncryptedFile|Returns list of users for an encrypted file as tuples of (SID, certificate hash blob, display info) static PyObject* py_QueryUsersOnEncryptedFile(PyObject *self, PyObject *args) { CHECK_PFN(QueryUsersOnEncryptedFile); - // @pyparm string/unicode|FileName||file to query + // @pyparm string|FileName||file to query PyObject *ret=NULL, *obfname=NULL, *ret_item=NULL; WCHAR *fname=NULL; DWORD err=0; @@ -3727,13 +3697,13 @@ py_QueryUsersOnEncryptedFile(PyObject *self, PyObject *args) return ret; } -// @pyswig (,string,unicode)|QueryRecoveryAgentsOnEncryptedFile|Lists recovery agents for file as a tuple of tuples. +// @pyswig (,bytes,string)|QueryRecoveryAgentsOnEncryptedFile|Lists recovery agents for file as a tuple of tuples. // @rdesc The result is a tuple of tuples - ((SID, certificate hash blob, display info),....) static PyObject* py_QueryRecoveryAgentsOnEncryptedFile(PyObject *self, PyObject *args) { CHECK_PFN(QueryRecoveryAgentsOnEncryptedFile); - // @pyparm string/unicode|FileName||file to query + // @pyparm string|FileName||file to query PyObject *ret=NULL, *obfname=NULL, *ret_item=NULL; WCHAR *fname=NULL; DWORD user_cnt=0, err=0; @@ -3763,8 +3733,8 @@ static PyObject* py_RemoveUsersFromEncryptedFile(PyObject *self, PyObject *args) { CHECK_PFN(RemoveUsersFromEncryptedFile); - // @pyparm string/unicode|FileName||File from which to remove users - // @pyparm ((,string,unicode),...)|pHashes||Sequence representing an ENCRYPTION_CERTIFICATE_HASH_LIST structure, as returned by QueryUsersOnEncryptedFile + // @pyparm string|FileName||File from which to remove users + // @pyparm ((,bytes,string),...)|pHashes||Sequence representing an ENCRYPTION_CERTIFICATE_HASH_LIST structure, as returned by QueryUsersOnEncryptedFile PyObject *ret=NULL, *obfname=NULL, *obechl=NULL; WCHAR *fname=NULL; DWORD err=0; @@ -3795,7 +3765,7 @@ static PyObject* py_AddUsersToEncryptedFile(PyObject *self, PyObject *args) { CHECK_PFN(AddUsersToEncryptedFile); - // @pyparm string/unicode|FileName||File that additional users will be allowed to decrypt + // @pyparm string|FileName||File that additional users will be allowed to decrypt // @pyparm ((,string,int),...)|pUsers||Sequence representing // ENCRYPTION_CERTIFICATE_LIST - elements are sequences consisting of // users' Sid, encoded EFS certficate (user must export a .cer to obtain @@ -3838,8 +3808,8 @@ static PyObject *py_DuplicateEncryptionInfoFile(PyObject *self, PyObject *args, static char *keywords[]={"SrcFileName","DstFileName","CreationDisposition","Attributes","SecurityAttributes", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOkk|O:DuplicateEncryptionInfoFile", keywords, - &obsrc, // @pyparm |SrcFileName||Encrypted file to read EFS metadata from - &obdst, // @pyparm |DstFileName||File to be encrypted using EFS data from source file + &obsrc, // @pyparm string|SrcFileName||Encrypted file to read EFS metadata from + &obdst, // @pyparm string|DstFileName||File to be encrypted using EFS data from source file &disp, // @pyparm int|CreationDisposition||Specifies whether an existing file should be overwritten (CREATE_NEW or CREATE_ALWAYS) &attr, // @pyparm int|Attributes||File attributes &obsa)) // @pyparm |SecurityAttributes|None|Specifies security for destination file @@ -4003,7 +3973,7 @@ py_SetFileShortName(PyObject *self, PyObject *args) BOOL bsuccess; if (!PyArg_ParseTuple(args, "OO:SetFileShortName", &obh, // @pyparm |hFile||Handle to a file or directory - &obshortname)) // @pyparm |ShortName||The 8.3 name to be applied to the file + &obshortname)) // @pyparm string|ShortName||The 8.3 name to be applied to the file return NULL; if (!PyWinObject_AsHANDLE(obh, &h)) return NULL; @@ -4091,8 +4061,8 @@ py_CopyFileEx(PyObject *self, PyObject *args, PyObject *kwargs) "Cancel","CopyFlags","Transaction", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|OOikO:CopyFileEx", keywords, - &obsrc, // @pyparm |ExistingFileName||File to be copied - &obdst, // @pyparm |NewFileName||Place to which it will be copied + &obsrc, // @pyparm string|ExistingFileName||File to be copied + &obdst, // @pyparm string|NewFileName||Place to which it will be copied &obcallback, // @pyparm |ProgressRoutine|None|A python function that receives progress updates, can be None &obdata, // @pyparm object|Data|None|An arbitrary object to be passed to the callback function &bcancel, // @pyparm boolean|Cancel|False|Pass True to cancel a restartable copy that was previously interrupted @@ -4162,8 +4132,8 @@ py_MoveFileWithProgress(PyObject *self, PyObject *args, PyObject *kwargs) static char *keywords[]={"ExistingFileName","NewFileName","ProgressRoutine","Data","Flags","Transaction", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|OOkO:MoveFileWithProgress", keywords, - &obsrc, // @pyparm |ExistingFileName||File or directory to be moved - &obdst, // @pyparm |NewFileName||Destination, can be None if flags contain MOVEFILE_DELAY_UNTIL_REBOOT + &obsrc, // @pyparm string|ExistingFileName||File or directory to be moved + &obdst, // @pyparm string|NewFileName||Destination, can be None if flags contain MOVEFILE_DELAY_UNTIL_REBOOT &obcallback, // @pyparm |ProgressRoutine|None|A python function that receives progress updates, can be None &obdata, // @pyparm object|Data|None|An arbitrary object to be passed to the callback function &flags, // @pyparm int|Flags|0|Combination of MOVEFILE_* flags @@ -4225,9 +4195,9 @@ py_ReplaceFile(PyObject *self, PyObject *args) BOOL bsuccess; DWORD flags=0; if (!PyArg_ParseTuple(args, "OO|OkOO:ReplaceFile", - &obdst, // @pyparm |ReplacedFileName||File to be replaced - &obsrc, // @pyparm |ReplacementFileName||File that will replace it - &obbackup, // @pyparm |BackupFileName|None|Place at which to create a backup of the replaced file, can be None + &obdst, // @pyparm string|ReplacedFileName||File to be replaced + &obsrc, // @pyparm string|ReplacementFileName||File that will replace it + &obbackup, // @pyparm string|BackupFileName|None|Place at which to create a backup of the replaced file, can be None &flags, // @pyparm int|ReplaceFlags|0|Combination of REPLACEFILE_* flags &obExclude, // @pyparm None|Exclude|None|Reserved, use None if passed in &obReserved)) // @pyparm None|Reserved|None|Reserved, use None if passed in @@ -4256,7 +4226,6 @@ py_ReplaceFile(PyObject *self, PyObject *args) return ret; } -#if PY_VERSION_HEX > 0x03010000 // Capsule API replaced PyCObject in 3.2. void encryptedfilecontextdestructor(PyObject *obctxt){ if (!PyCapsule_IsValid(obctxt, NULL)) @@ -4269,12 +4238,6 @@ void encryptedfilecontextdestructor(PyObject *obctxt){ if (pfnCloseEncryptedFileRaw) (*pfnCloseEncryptedFileRaw)(ctxt); } -#else -void encryptedfilecontextdestructor(void *ctxt){ - if (pfnCloseEncryptedFileRaw && ctxt) - (*pfnCloseEncryptedFileRaw)(ctxt); -} -#endif // @pyswig PyCObject|OpenEncryptedFileRaw|Initiates a backup or restore operation on an encrypted file @@ -4292,7 +4255,7 @@ py_OpenEncryptedFileRaw(PyObject *self, PyObject *args) WCHAR *fname=NULL; void *ctxt; if (!PyArg_ParseTuple(args, "Ok:OpenEncryptedFileRaw", - &obfname, // @pyparm |FileName||Name of file on which to operate + &obfname, // @pyparm string|FileName||Name of file on which to operate &flags)) // @pyparm int|Flags||CREATE_FOR_IMPORT, CREATE_FOR_DIR, OVERWRITE_HIDDEN, or 0 for export return NULL; if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) @@ -4303,11 +4266,7 @@ py_OpenEncryptedFileRaw(PyObject *self, PyObject *args) if (err!=ERROR_SUCCESS) PyWin_SetAPIError("OpenEncryptedFileRaw", err); else{ -#if PY_VERSION_HEX > 0x03010000 ret=PyCapsule_New(ctxt, NULL, encryptedfilecontextdestructor); -#else - ret=PyCObject_FromVoidPtr(ctxt, encryptedfilecontextdestructor); -#endif if (ret==NULL) (*pfnCloseEncryptedFileRaw)(ctxt); } @@ -4363,11 +4322,7 @@ py_ReadEncryptedFileRaw(PyObject *self, PyObject *args) &obcallback_data, // @pyparm object|CallbackContext||Arbitrary Python object to be passed to callback function &obctxt)) // @pyparm PyCObject|Context||Context object returned from return NULL; -#if PY_VERSION_HEX > 0x03010000 ctxt=PyCapsule_GetPointer(obctxt, NULL); -#else - ctxt=PyCObject_AsVoidPtr(obctxt); -#endif if (ctxt==NULL) return NULL; if (!PyCallable_Check(obcallback)){ @@ -4444,11 +4399,7 @@ py_WriteEncryptedFileRaw(PyObject *self, PyObject *args) &obcallback_data, // @pyparm object|CallbackContext||Arbitrary Python object to be passed to callback function &obctxt)) // @pyparm PyCObject|Context||Context object returned from return NULL; -#if PY_VERSION_HEX > 0x03010000 ctxt=PyCapsule_GetPointer(obctxt, NULL); -#else - ctxt=PyCObject_AsVoidPtr(obctxt); -#endif if (ctxt==NULL) return NULL; if (!PyCallable_Check(obcallback)){ @@ -4485,7 +4436,6 @@ py_CloseEncryptedFileRaw(PyObject *self, PyObject *args) // object destructs and we attempt to close it a second time, Vista x64 // crashes. // So must bypass the CObject API for this. -#if PY_VERSION_HEX > 0x03010000 if (!PyCapsule_IsValid(obctxt, NULL)) return PyErr_Format(PyExc_TypeError, "param must be handle to an encrypted file (got type %s)", obctxt->ob_type->tp_name); if (PyCapsule_GetDestructor(obctxt) != encryptedfilecontextdestructor) @@ -4499,19 +4449,6 @@ py_CloseEncryptedFileRaw(PyObject *self, PyObject *args) void *ctxt = PyCapsule_GetPointer(obctxt, NULL); (*pfnCloseEncryptedFileRaw)(ctxt); PyCapsule_SetContext(obctxt, INVALID_HANDLE_VALUE); -#else - if (!PyCObject_Check(obctxt)) - return PyErr_Format(PyExc_TypeError, "param must be handle to an encrypted file (got type %s)", obctxt->ob_type->tp_name); - PyCObject *pcobj = (PyCObject *)obctxt; - if (pcobj->destructor != encryptedfilecontextdestructor) - return PyErr_Format(PyExc_TypeError, "param must be handle to an encrypted file (got a CObject with invalid destructor)"); - if (!pcobj->cobject) - return PyErr_Format(PyExc_ValueError, "This handle has already been closed"); - // ok - close it, then nuke it. - // function has no return value, make sure to check for memory leaks! - (*pfnCloseEncryptedFileRaw)(pcobj->cobject); - pcobj->cobject = 0; -#endif Py_INCREF(Py_None); return Py_None; } @@ -4535,7 +4472,7 @@ static PyObject *py_CreateFileW(PyObject *self, PyObject *args, PyObject *kwargs static char *keywords[]={"FileName","DesiredAccess","ShareMode","SecurityAttributes","CreationDisposition", "FlagsAndAttributes","TemplateFile","Transaction","MiniVersion","ExtendedParameter", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OkkOkk|OOOO:CreateFileW", keywords, - &obfilename, // @pyparm |FileName||Name of file + &obfilename, // @pyparm string|FileName||Name of file &desiredaccess, // @pyparm int|DesiredAccess||Combination of access mode flags. See MSDN docs. &sharemode, // @pyparm int|ShareMode||Combination of FILE_SHARE_READ, FILE_SHARE_WRITE, FILE_SHARE_DELETE &obsa, // @pyparm |SecurityAttributes||Specifies security descriptor and handle inheritance, can be None @@ -4592,7 +4529,7 @@ static PyObject *py_CreateFileW(PyObject *self, PyObject *args, PyObject *kwargs } PyCFunction pfnpy_CreateFileW=(PyCFunction)py_CreateFileW; -// @pyswig |DeleteFileW|Deletes a file (Unicode version) +// @pyswig |DeleteFileW|Deletes a file // @pyseeapi DeleteFile // @pyseeapi DeleteFileTransacted // @comm If a transaction handle is passed in, DeleteFileTransacted will be called (requires Windows Vista). @@ -4605,7 +4542,7 @@ static PyObject *py_DeleteFileW(PyObject *self, PyObject *args, PyObject *kwargs static char *keywords[]={"FileName","Transaction", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:DeleteFileW", keywords, - &obfilename, // @pyparm |FileName||Name of file to be deleted + &obfilename, // @pyparm string|FileName||Name of file to be deleted &obhtransaction)) // @pyparm |Transaction|None|Transaction handle as returned by return NULL; if (!PyWinObject_AsHANDLE(obhtransaction, &htransaction)) @@ -4648,7 +4585,7 @@ static PyObject *PyObject_FromFILEX_INFO(GET_FILEEX_INFO_LEVELS level, void *p) PyWinObject_FromULARGE_INTEGER(fsize)); break; } - + default: PyErr_Format(PyExc_RuntimeError, "invalid level for FILEEX_INFO"); return NULL; @@ -4660,32 +4597,31 @@ static PyObject *PyObject_FromFILEX_INFO(GET_FILEEX_INFO_LEVELS level, void *p) // @pyswig tuple|GetFileAttributesEx|Retrieves attributes for a specified file or directory. // @pyseeapi GetFileAttributesEx // @pyseeapi GetFileAttributesTransacted -// @pyparm |FileName||File or directory for which to retrieve information -// In the ANSI version of this function, the name is limited to -// MAX_PATH characters. To extend this limit to nearly 32,000 wide characters, -// call the Unicode version of the function () and prepend -// r"\\?\" to the path. +// @pyparm string/bytes|FileName||File or directory for which to retrieve information +// In the usual case, the name is limited to MAX_PATH characters. To extend this +// limit to nearly 32,000 wide characters, call this and prepend r"\\?\" to the path. // @pyparm int|InfoLevelId|GetFileExInfoStandard|An integer that gives the set of attribute information to obtain. // See the Win32 SDK documentation for more information. // @pyparm |Transaction|None|Handle to a transaction (optional). See . // If this parameter is specified, GetFileAttributesTransacted will be called (requires Vista or later). // @rdesc The result is a tuple of: // @tupleitem 0|int|attributes|File Attributes. A combination of the win32com.FILE_ATTRIBUTE_* flags. -// @tupleitem 1||creationTime|Specifies when the file or directory was created. -// @tupleitem 2||lastAccessTime|For a file, specifies when the file was last read from -// or written to. For a directory, the structure specifies when the directory was created. For -// both files and directories, the specified date will be correct, but the time of day will +// @tupleitem 1||creationTime|Specifies when the file or directory was created. +// @tupleitem 2||lastAccessTime|For a file, specifies when the file was last read from +// or written to. For a directory, the structure specifies when the directory was created. For +// both files and directories, the specified date will be correct, but the time of day will // always be set to midnight. -// @tupleitem 3||lastWriteTime|For a file, the structure specifies when the file was last +// @tupleitem 3||lastWriteTime|For a file, the structure specifies when the file was last // written to. For a directory, the structure specifies when the directory was created. -// @tupleitem 4|int/long|fileSize|The size of the file. This member has no meaning for directories. -// @comm Not all file systems can record creation and last access time and not all file systems record -// them in the same manner. For example, on Windows NT FAT, create time has a resolution of -// 10 milliseconds, write time has a resolution of 2 seconds, and access time has a resolution -// of 1 day (really, the access date). On NTFS, access time has a resolution of 1 hour. -// Furthermore, FAT records times on disk in local time, while NTFS records times on disk in UTC, +// @tupleitem 4|int/long|fileSize|The size of the file. This member has no meaning for directories. +// @comm Not all file systems can record creation and last access time and not all file systems record +// them in the same manner. For example, on Windows NT FAT, create time has a resolution of +// 10 milliseconds, write time has a resolution of 2 seconds, and access time has a resolution +// of 1 day (really, the access date). On NTFS, access time has a resolution of 1 hour. +// Furthermore, FAT records times on disk in local time, while NTFS records times on disk in UTC, // so it is not affected by changes in time zone or daylight saving time. // @comm Accepts keyword arguments. +// @comm If bytes are passed for the filename, the ANSI Windows functions are called. static PyObject *py_GetFileAttributesEx(PyObject *self, PyObject *args, PyObject *kwargs, BOOL bUnicode) { BOOL ok; @@ -4702,7 +4638,7 @@ static PyObject *py_GetFileAttributesEx(PyObject *self, PyObject *args, PyObject if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|kO:GetFileAttributesEx", keywords, &obfname, &lvl, - &obtrans)) + &obtrans)) return NULL; if (!PyWinObject_AsHANDLE(obtrans, &htrans)) return NULL; @@ -4777,11 +4713,7 @@ static PyObject *py_GetFileAttributesExA(PyObject *self, PyObject *args, PyObjec return py_GetFileAttributesEx(self, args, kwargs, FALSE); } PyCFunction pfnpy_GetFileAttributesExW=(PyCFunction)py_GetFileAttributesExW; -#ifdef UNICODE PyCFunction pfnpy_GetFileAttributesEx=(PyCFunction)py_GetFileAttributesExW; -#else -PyCFunction pfnpy_GetFileAttributesEx=(PyCFunction)py_GetFileAttributesExA; -#endif // @pyswig |SetFileAttributesW|Sets a file's attributes // @pyseeapi SetFileAttributes @@ -4797,7 +4729,7 @@ static PyObject *py_SetFileAttributesW(PyObject *self, PyObject *args, PyObject static char *keywords[]={"FileName","FileAttributes","Transaction", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Ok|O:SetFileAttributesW", keywords, - &obfname, // @pyparm |FileName||File or directory whose attributes are to be changed + &obfname, // @pyparm string|FileName||File or directory whose attributes are to be changed &attrs, // @pyparm int|FileAttributes||Combination of FILE_ATTRIBUTE_* flags &obtrans)) // @pyparm |Transaction|None|Handle to the transaction. See . return NULL; @@ -4822,7 +4754,7 @@ static PyObject *py_SetFileAttributesW(PyObject *self, PyObject *args, PyObject } PyCFunction pfnpy_SetFileAttributesW=(PyCFunction)py_SetFileAttributesW; -// @pyswig |CreateDirectoryExW|Creates a directory (Unicode version) +// @pyswig |CreateDirectoryExW|Creates a directory // @pyseeapi CreateDirectoryEx // @pyseeapi CreateDirectoryTransacted // @comm If a transaction handle is passed, CreateDirectoryTransacted will be called (requires Vista or later). @@ -4836,8 +4768,8 @@ static PyObject *py_CreateDirectoryExW(PyObject *self, PyObject *args, PyObject static char *keywords[]={"TemplateDirectory","NewDirectory","SecurityAttributes","Transaction", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|OO:CreateDirectoryExW", keywords, - &obtemplatedir, // @pyparm |TemplateDirectory||Directory to use as a template, can be None - &obdirname, // @pyparm |NewDirectory||Name of directory to be created + &obtemplatedir, // @pyparm string|TemplateDirectory||Directory to use as a template, can be None + &obdirname, // @pyparm string|NewDirectory||Name of directory to be created &obsa, // @pyparm |SecurityAttributes|None|Security for new directory (optional) &obtrans)) // @pyparm |Transaction|None|Handle to a transaction (optional). See . return NULL; @@ -4872,7 +4804,7 @@ PyCFunction pfnpy_CreateDirectoryExW=(PyCFunction)py_CreateDirectoryExW; // @pyseeapi RemoveDirectory // @pyseeapi RemoveDirectoryTransacted // @comm If a transaction handle is passed in, RemoveDirectoryTransacted will be called (requires Vista or later) -// @comm Accepts keyword arguments. Implemented only as Unicode. +// @comm Accepts keyword arguments. static PyObject *py_RemoveDirectory(PyObject *self, PyObject *args, PyObject *kwargs) { WCHAR *dirname=NULL; @@ -4881,7 +4813,7 @@ static PyObject *py_RemoveDirectory(PyObject *self, PyObject *args, PyObject *kw static char *keywords[]={"PathName","Transaction", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:RemoveDirectory", keywords, - &obdirname, // @pyparm |PathName||Name of directory to be removed + &obdirname, // @pyparm string|PathName||Name of directory to be removed &obtrans)) // @pyparm |Transaction|None|Handle to a transaction (optional). See . return NULL; if (!PyWinObject_AsHANDLE(obtrans, &htrans)) @@ -5033,10 +4965,9 @@ static PyObject *py_FindFilesIterator(PyObject *self, PyObject *args, PyObject * } PyCFunction pfnpy_FindFilesIterator=(PyCFunction)py_FindFilesIterator; -// @pyswig [(long, ),...]|FindStreams|List the data streams for a file +// @pyswig [(long, string),...]|FindStreams|List the data streams for a file // @rdesc Returns a list of tuples containing each stream's size and name // @comm This uses the API functions FindFirstStreamW, FindNextStreamW and FindClose -// @comm Available on Windows Server 2003 and Vista // @comm If the Transaction arg is not None, FindFirstStreamTransacted will be called in place of FindFirstStreamW static PyObject *py_FindStreams(PyObject *self, PyObject *args, PyObject *kwargs) { @@ -5052,7 +4983,7 @@ static PyObject *py_FindStreams(PyObject *self, PyObject *args, PyObject *kwargs static char *keywords[]={"FileName","Transaction", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:FindStreams", keywords, - &obfname, // @pyparm |FileName||Name of file (or directory) to operate on + &obfname, // @pyparm string|FileName||Name of file (or directory) to operate on &obtrans)) // @pyparm |Transaction|None|Handle to a transaction, can be None return NULL; if (!PyWinObject_AsHANDLE(obtrans, &htrans)) @@ -5096,7 +5027,7 @@ static PyObject *py_FindStreams(PyObject *self, PyObject *args, PyObject *kwargs } PyCFunction pfnpy_FindStreams=(PyCFunction)py_FindStreams; -// @pyswig [,...]|FindFileNames|Enumerates hard links that point to specified file +// @pyswig [string,...]|FindFileNames|Enumerates hard links that point to specified file // @comm This uses the API functions FindFirstFileNameW, FindNextFileNameW and FindClose // @comm Available on Vista and later // @comm If Transaction is specified, a transacted search is performed using FindFirstFileNameTransacted @@ -5117,7 +5048,7 @@ static PyObject *py_FindFileNames(PyObject *self, PyObject *args, PyObject *kwar static char *keywords[]={"FileName","Transaction", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:FindFileNames", keywords, - &obfname, // @pyparm |FileName||Name of file for which to find links + &obfname, // @pyparm string|FileName||Name of file for which to find links &obtrans)) // @pyparm |Transaction|None|Handle to a transaction, can be None return NULL; if (!PyWinObject_AsHANDLE(obtrans, &htrans)) @@ -5206,9 +5137,8 @@ static PyObject *py_FindFileNames(PyObject *self, PyObject *args, PyObject *kwar } PyCFunction pfnpy_FindFileNames=(PyCFunction)py_FindFileNames; -// @pyswig |GetFinalPathNameByHandle|Returns the file name for an open file handle +// @pyswig string|GetFinalPathNameByHandle|Returns the file name for an open file handle // @pyseeapi GetFinalPathNameByHandle -// @comm Exists on Windows Vista or later. // @comm Accepts keyword arguments. static PyObject *py_GetFinalPathNameByHandle(PyObject *self, PyObject *args, PyObject *kwargs) { @@ -5245,7 +5175,7 @@ static PyObject *py_GetFinalPathNameByHandle(PyObject *self, PyObject *args, PyO } PyCFunction pfnpy_GetFinalPathNameByHandle=(PyCFunction)py_GetFinalPathNameByHandle; -// @pyswig [,...]|SfcGetNextProtectedFile|Returns list of protected operating system files +// @pyswig [string,...]|SfcGetNextProtectedFile|Returns list of protected operating system files // @pyseeapi SfcGetNextProtectedFile static PyObject *py_SfcGetNextProtectedFile(PyObject *self, PyObject *args) { @@ -5288,7 +5218,7 @@ static PyObject *py_SfcIsFileProtected(PyObject *self, PyObject *args) BOOL ret; if (!PyArg_ParseTuple(args, "O:SfcIsFileProtected", - &obfname)) // @pyparm |ProtFileName||Name of file to be checked + &obfname)) // @pyparm string|ProtFileName||Name of file to be checked return NULL; if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) return NULL; @@ -5303,7 +5233,7 @@ static PyObject *py_SfcIsFileProtected(PyObject *self, PyObject *args) return PyBool_FromLong(ret); } -// @pyswig |GetLongPathName|Retrieves the long path for a short path (8.3 filename) +// @pyswig string|GetLongPathName|Retrieves the long path for a short path (8.3 filename) // @comm Accepts keyword args static PyObject *py_GetLongPathName(PyObject *self, PyObject *args, PyObject *kwargs) { @@ -5318,7 +5248,7 @@ static PyObject *py_GetLongPathName(PyObject *self, PyObject *args, PyObject *kw #endif if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:GetLongPathName", keywords, - &obfname, // @pyparm |ShortPath||8.3 path to be expanded + &obfname, // @pyparm string|ShortPath||8.3 path to be expanded &obtrans)) // @pyparm |Transaction|None|Handle to a transaction. If specified, GetLongPathNameTransacted will be called. return NULL; if (!PyWinObject_AsHANDLE(obtrans, &htrans)) @@ -5369,10 +5299,10 @@ static PyObject *py_GetLongPathName(PyObject *self, PyObject *args, PyObject *kw } PyCFunction pfnpy_GetLongPathName=(PyCFunction)py_GetLongPathName; -// @pyswig str/unicode|GetFullPathName|Returns full path for path passed in -// @comm This function takes either a plain string or a unicode string, and returns the same type +// @pyswig string|GetFullPathName|Returns full path for path passed in +// @comm This function takes either a bytes a unicode string, and returns the same type // If unicode is passed in, GetFullPathNameW is called, which supports filenames longer than MAX_PATH -// @comm If Transaction parameter is specified, GetFullPathNameTransacted is called (requires Vista or later) +// @comm If Transaction parameter is specified, GetFullPathNameTransacted is called static PyObject *py_GetFullPathName(PyObject *self, PyObject *args, PyObject *kwargs) { HANDLE htrans; @@ -5384,7 +5314,7 @@ static PyObject *py_GetFullPathName(PyObject *self, PyObject *args, PyObject *kw #endif if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:GetFullPathName", keywords, - &obpathin, // @pyparm str/unicode|FileName||Path on which to operate + &obpathin, // @pyparm bytes/unicode|FileName||Path on which to operate &obtrans)) // @pyparm |Transaction|None|Handle to a transaction as returned by return NULL; if (!PyWinObject_AsHANDLE(obtrans, &htrans)) @@ -5517,8 +5447,6 @@ static PyObject *py_GetFileInformationByHandleEx(PyObject *self, PyObject *args, { // According to MSDN, this function is in kernel32.lib in Vista or later, but I can't get it to link // with either Vista or Windows 7 sdks. - // On XP, you can use it with the downloadable fileextd.lib add-on, but it's a static library - // and would never call the function exported from kernel32.dll. CHECK_PFN(GetFileInformationByHandleEx); static char *keywords[] = {"File", "FileInformationClass", NULL}; HANDLE handle; diff --git a/win32/src/win32gui.i b/win32/src/win32gui.i index 7067ea5566..2114b3563f 100644 --- a/win32/src/win32gui.i +++ b/win32/src/win32gui.i @@ -12,8 +12,6 @@ %endif %{ -// #define UNICODE -// #define _UNICODE // for CRT string functions #define _WIN32_IE 0x0501 // to enable balloon notifications in Shell_NotifyIcon #define _WIN32_WINNT 0x0501 #ifdef WINXPGUI @@ -272,13 +270,7 @@ PyDict_SetItemString(d, "g_HWNDMap", g_HWNDMap); PyDict_SetItemString(d, "g_DLGMap", g_DLGMap); #endif -PyDict_SetItemString(d, "UNICODE", -#ifdef UNICODE - Py_True -#else - Py_False -#endif - ); +PyDict_SetItemString(d, "UNICODE", Py_True); // hack borrowed from win32security since version of SWIG we use doesn't do keyword arguments #ifdef WINXPGUI @@ -933,8 +925,8 @@ PyTypeObject PyWNDCLASSType = // @prop integer|hbrBackground| // These 3 handled manually in PyWNDCLASS::getattro/setattro. The pymeth below is used as an // end tag, so these props will be lost if below it - // @prop string/|lpszMenuName| - // @prop string/|lpszClassName| + // @prop string|lpszMenuName| + // @prop string|lpszClassName| // @prop function|lpfnWndProc| }; @@ -1011,7 +1003,6 @@ PyObject *PyWNDCLASS::getattro(PyObject *self, PyObject *obname) int SetTCHAR(PyObject *v, PyObject **m, LPCTSTR *ret) { -#ifdef UNICODE if (!PyUnicode_Check(v)) { PyErr_SetString(PyExc_TypeError, "Object must be a Unicode"); return -1; @@ -1021,17 +1012,6 @@ int SetTCHAR(PyObject *v, PyObject **m, LPCTSTR *ret) Py_INCREF(v); *ret = PyUnicode_AsUnicode(v); return 0; -#else - if (!PyBytes_Check(v)) { - PyErr_SetString(PyExc_TypeError, "Object must be a string"); - return -1; - } - Py_XDECREF(*m); - *m = v; - Py_INCREF(v); - *ret = PyBytes_AsString(v); - return 0; -#endif } int PyWNDCLASS::setattro(PyObject *self, PyObject *obname, PyObject *v) @@ -1419,7 +1399,7 @@ static PyObject *PyEnumFontFamilies(PyObject *self, PyObject *args) PyObject *obExtra = Py_None; HDC hdc; // @pyparm |hdc||Handle to a device context for which to enumerate available fonts - // @pyparm string/|Family||Family of fonts to enumerate. If none, first member of each font family will be returned. + // @pyparm string|Family||Family of fonts to enumerate. If none, first member of each font family will be returned. // @pyparm function|EnumFontFamProc||The Python function called with each font family. This function is called with 4 arguments. // @pyparm object|Param||An arbitrary object to be passed to the callback function // @comm The parameters that the callback function will receive are as follows: @@ -1616,7 +1596,6 @@ static PyObject *PyGetMemory(PyObject *self, PyObject *args) %{ // @pyswig string|PyGetString|Returns a string from an address. -// @rdesc If win32gui.UNICODE is True, this will return a unicode object. static PyObject *PyGetString(PyObject *self, PyObject *args) { TCHAR *addr = 0; @@ -2041,7 +2020,7 @@ BOOLAPI ReplyMessage(int lResult); // @pyparm int|result||Specifies the result o #endif /* not MS_WINCE */ // @pyswig int|RegisterWindowMessage|Defines a new window message that is guaranteed to be unique throughout the system. The message value can be used when sending or posting messages. -// @pyparm string/unicode|name||The string +// @pyparm unicode|name||The string UINT RegisterWindowMessage(TCHAR *lpString); // @pyswig int|DefWindowProc| @@ -2424,7 +2403,7 @@ static PyObject *PyGetDlgItemText(PyObject *self, PyObject *args) BOOLAPI SetDlgItemText( HWND hDlg, // @pyparm |hDlg||Handle to a dialog window int nIDDlgItem, // @pyparm int|IDDlgItem||The Id of a control within the dialog - TCHAR *text); // @pyparm str/unicode|String||The text to put in the control + TCHAR *text); // @pyparm string|text||The text to put in the control // @pyswig HWND|GetNextDlgTabItem|Retrieves a handle to the first control that has the WS_TABSTOP style that precedes (or follows) the specified control. HWND GetNextDlgTabItem( @@ -2458,9 +2437,6 @@ static PyObject *PyGetWindowText(PyObject *self, PyObject *args) Py_BEGIN_ALLOW_THREADS len = GetWindowText(hwnd, buffer, sizeof(buffer)/sizeof(TCHAR)); Py_END_ALLOW_THREADS - // @comm Note that previous versions of PyWin32 returned a (empty) Unicode - // object when the string was empty, or an MBCS encoded string value - // otherwise. A String is now returned in all cases. return PyWinObject_FromTCHAR(buffer, len); } %} @@ -2961,8 +2937,8 @@ BOOLAPI ImageList_SetOverlayImage( // @pyswig int|MessageBox|Displays a message box // @pyparm int|parent||The parent window -// @pyparm string/|text||The text for the message box -// @pyparm string/|caption||The caption for the message box +// @pyparm string|text||The text for the message box +// @pyparm string|caption||The caption for the message box // @pyparm int|flags|| int MessageBox(HWND parent, TCHAR *text, TCHAR *caption, DWORD flags); @@ -3735,15 +3711,13 @@ DWORD CommDlgExtendedError(void); $target = ( OPENFILENAME *)PyBytes_AS_STRING($source); } -#ifndef MS_WINCE // @pyswig int|ExtractIcon| // @pyparm int|hinstance|| -// @pyparm string/|moduleName|| +// @pyparm string|moduleName|| // @pyparm int|index|| // @comm You must destroy the icon handle returned by calling the function. // @rdesc The result is a HICON. HICON ExtractIcon(HINSTANCE hinst, TCHAR *modName, UINT index); -#endif /* not MS_WINCE */ // @pyswig int|ExtractIconEx| // @pyparm string|moduleName|| @@ -3989,7 +3963,7 @@ static PyObject *PySetTextAlign(PyObject *self, PyObject *args) return PyLong_FromLong(prevalign); } -// @pyswig |GetTextFace|Retrieves the name of the font currently selected in a DC +// @pyswig string|GetTextFace|Retrieves the name of the font currently selected in a DC // @comm Calls unicode api function (GetTextFaceW) static PyObject *PyGetTextFace(PyObject *self, PyObject *args) { @@ -6332,9 +6306,9 @@ PyObject *PyReturn_OPENFILENAMEW_Output(OPENFILENAMEW *pofn) %native (GetOpenFileNameW) pfnPyGetOpenFileNameW; %{ -// @pyswig (,,int)|GetSaveFileNameW|Creates a dialog for user to specify location to save a file or files +// @pyswig (string, string,int)|GetSaveFileNameW|Creates a dialog for user to specify location to save a file or files // @comm Accepts keyword arguments, all arguments optional -// @rdesc Returns a tuple of 3 values (, , int): +// @rdesc Returns a tuple of 3 values (string, string, int): // First is the selected file(s). If multiple files are selected, returned string will be the directory followed by files names // separated by nulls, otherwise it will be the full path. In other words, if you use the OFN_ALLOWMULTISELECT flag // you should split this value on \0 characters and if the length of the result list is 1, it will be @@ -6346,16 +6320,16 @@ PyObject *PyReturn_OPENFILENAMEW_Output(OPENFILENAMEW *pofn) // win32gui.error is raised. If the user pressed cancel, the error number (ie, the winerror attribute of the exception) will be zero. // @pyparm |hwndOwner|None|Handle to window that owns dialog // @pyparm |hInstance|None|Handle to module that contains dialog template -// @pyparm |Filter|None|Contains pairs of descriptions and filespecs separated by NULLS, with a final trailing NULL. +// @pyparm string|Filter|None|Contains pairs of descriptions and filespecs separated by NULLS, with a final trailing NULL. // Example: 'Python Scripts\0*.py;*.pyw;*.pys\0Text files\0*.txt\0' -// @pyparm |CustomFilter|None|Description to be used for filter that user selected or typed, can also contain a filespec as above +// @pyparm string|CustomFilter|None|Description to be used for filter that user selected or typed, can also contain a filespec as above // @pyparm int|FilterIndex|0|Specifies which of the filters is initially selected, use 0 for CustomFilter -// @pyparm |File|None|The file name initially displayed +// @pyparm string|File|None|The file name initially displayed // @pyparm int|MaxFile|1024|Number of characters to allocate for selected filename(s), override if large number of files expected -// @pyparm |InitialDir|None|The starting directory -// @pyparm |Title|None|The title of the dialog box +// @pyparm string|InitialDir|None|The starting directory +// @pyparm string|Title|None|The title of the dialog box // @pyparm int|Flags|0|Combination of win32con.OFN_* constants -// @pyparm |DefExt|None|The default extension to use +// @pyparm string|DefExt|None|The default extension to use // @pyparm |TemplateName|None|Name or resource id of dialog box template static PyObject *PyGetSaveFileNameW(PyObject *self, PyObject *args, PyObject *kwargs) { @@ -6378,7 +6352,7 @@ static PyObject *PyGetSaveFileNameW(PyObject *self, PyObject *args, PyObject *kw return ret; } -// @pyswig (,, int)|GetOpenFileNameW|Creates a dialog to allow user to select file(s) to open +// @pyswig (string,string, int)|GetOpenFileNameW|Creates a dialog to allow user to select file(s) to open // @comm Accepts keyword arguments, all arguments optional // Input parameters and return values are identical to static PyObject *PyGetOpenFileNameW(PyObject *self, PyObject *args, PyObject *kwargs) @@ -6421,16 +6395,16 @@ BOOL PyParse_OPENFILENAMEW_Args(PyObject *args, PyObject *kwargs, OPENFILENAMEW if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOOOlOlOOlOO:OPENFILENAME", keywords, &obOwner, // @pyparm |hwndOwner|None|Handle to window that owns dialog &obhInstance, // @pyparm |hInstance|None|Handle to module that contains dialog template - &obFilter, // @pyparm |Filter|None|Contains pairs of descriptions and filespecs separated by NULLS, with a final trailing NULL. + &obFilter, // @pyparm string|Filter|None|Contains pairs of descriptions and filespecs separated by NULLS, with a final trailing NULL. // Example: 'Python Scripts\0*.py;*.pyw;*.pys\0Text files\0*.txt\0' - &obCustomFilter, // @pyparm |CustomFilter|None|Description to be used for filter that user selected or typed, can also contain a filespec as above + &obCustomFilter, // @pyparm string|CustomFilter|None|Description to be used for filter that user selected or typed, can also contain a filespec as above &pofn->nFilterIndex, // @pyparm int|FilterIndex|0|Specifies which of the filters is initially selected, use 0 for CustomFilter - &obFile, // @pyparm |File|None|The file name initially displayed + &obFile, // @pyparm string|File|None|The file name initially displayed &pofn->nMaxFile, // @pyparm int|MaxFile|1024|Number of characters to allocate for selected filename, override if large number of files expected - &obInitialDir, // @pyparm |InitialDir|None|The starting directory - &obTitle, // @pyparm |Title|None|The title of the dialog box + &obInitialDir, // @pyparm string|InitialDir|None|The starting directory + &obTitle, // @pyparm string|Title|None|The title of the dialog box &pofn->Flags, // @pyparm int|Flags|0|Combination of win32con.OFN_* constants - &obDefExt, // @pyparm |DefExt|None|The default extension to use + &obDefExt, // @pyparm string|DefExt|None|The default extension to use &obTemplateName)) // @pyparm |TemplateName|None|Name or resource id of dialog box template goto done; @@ -7470,7 +7444,7 @@ PyObject *PyDrawTextW(PyObject *self, PyObject *args, PyObject *kwargs) if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOiOI:DrawTextW", keywords, &obhdc, // @pyparm |hDC||Handle to a device context - &obtxt, // @pyparm |String||Text to be drawn + &obtxt, // @pyparm string|String||Text to be drawn &len, // @pyparm int|Count||Number of characters to draw, use -1 for entire null terminated string &obrc, // @pyparm |Rect||Rectangle in which to draw text &fmt)) // @pyparm int|Format||Formatting flags, combination of win32con.DT_* values diff --git a/win32/src/win32inet.i b/win32/src/win32inet.i index 54e0240874..a83eb5ebed 100644 --- a/win32/src/win32inet.i +++ b/win32/src/win32inet.i @@ -2,8 +2,6 @@ // @doc %module win32inet // An interface to the Windows internet (wininet) API %{ -// #define UNICODE -// #define _UNICODE #include "Windows.h" #include "WinInet.h" #undef BOOLAPI // wininet.h defines this! @@ -166,11 +164,10 @@ PyObject *PyWinObject_FromStatusInformation(DWORD status, void *buf, DWORD bufsi INTERNET_ASYNC_RESULT *ias=(INTERNET_ASYNC_RESULT *)buf; return Py_BuildValue("{s:N, s:k}", "Result", PyWinLong_FromHANDLE((HANDLE)ias->dwResult), - "Error", ias->dwError); + "Error", ias->dwError); } case INTERNET_STATUS_RESOLVING_NAME: - return PyWinObject_FromTCHAR((TCHAR *)buf); - // This always returns a character string, even when compiled with UNICODE defined + return PyWinObject_FromWCHAR((TCHAR *)buf); case INTERNET_STATUS_NAME_RESOLVED: // ??? MSDN claims the 2 below return pointer to SOCKADDR struct, // but it appears to be a plain string ??? @@ -529,7 +526,7 @@ PyCFunction pfnPyInternetConnect = (PyCFunction)PyInternetConnect; %} %native (InternetConnect) pfnPyInternetConnect; -// @pyswig |InternetOpen|Initializes an application's use of the Microsoft� Win32� Internet functions. +// @pyswig |InternetOpen|Initializes an application's use of the Microsoft� Win32� Internet functions. PyHINTERNET InternetOpen( TCHAR *lpszAgent, // @pyparm string|agent||A string that contains the name of the application // or entity calling the Internet functions. This name is used as the user @@ -630,7 +627,7 @@ PyObject *PyInternetCanonicalizeUrl(PyObject *self, PyObject *args) // canonicalization. This can be one of the following values: // @flag ICU_BROWSER_MODE|Does not encode or decode characters after "#" or "?", and does not remove trailing white space after "?". If this value is not specified, the entire URL is encoded and trailing white space is removed. // @flag ICU_DECODE|Converts all %XX sequences to characters, including escape sequences, before the URL is parsed. - // @flag ICU_ENCODE_PERCENT|Encodes any percent signs encountered. By default, percent signs are not encoded. This value is available in Microsoft� Internet Explorer 5 and later versions of the Win32� Internet functions. + // @flag ICU_ENCODE_PERCENT|Encodes any percent signs encountered. By default, percent signs are not encoded. This value is available in Microsoft� Internet Explorer 5 and later versions of the Win32� Internet functions. // @flag ICU_ENCODE_SPACES_ONLY|Encodes spaces only. // @flag ICU_NO_ENCODE|Does not convert unsafe characters to escape sequences. // @flag ICU_NO_META|Does not remove meta sequences (such as "." and "..") from the URL. @@ -671,7 +668,7 @@ done: %native (InternetCanonicalizeUrl) PyInternetCanonicalizeUrl; %{ -// @pyswig int, string|InternetGetLastResponseInfo|Retrieves the last Win32� Internet function error description or server response on the thread calling this function. +// @pyswig int, string|InternetGetLastResponseInfo|Retrieves the last Win32� Internet function error description or server response on the thread calling this function. PyObject *PyInternetGetLastResponseInfo(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, ":InternetGetLastResponseInfo")) @@ -1717,19 +1714,14 @@ PyObject *PyCreateUrlCacheEntry(PyObject *self, PyObject *args, PyObject *kwargs PyObject *PyCommitUrlCacheEntry(PyObject *self, PyObject *args, PyObject *kwargs) { TCHAR *UrlName=NULL, *LocalFileName=NULL, *OriginalUrl=NULL; - // ??? Header info is defined as LPWSTR in UNICODE mode, but LPBYTE in ansi mode ??? -#ifdef UNICODE WCHAR *HeaderInfo=NULL; -#else - LPBYTE HeaderInfo=NULL; -#endif PyObject *obUrlName, *obLocalFileName, *obHeaderInfo=Py_None, *obOriginalUrl=Py_None; FILETIME ExpireTime={0,0}, LastModifiedTime={0,0}; PyObject *obExpireTime=Py_None, *obLastModifiedTime=Py_None; DWORD CacheEntryType=NORMAL_CACHE_ENTRY, HeaderSize=0; TCHAR *FileExtension=NULL; // reserved PyObject *ret=NULL; - + static char *keywords[]={"UrlName","LocalFileName","ExpireTime","LastModifiedTime", "CacheEntryType","HeaderInfo","OriginalUrl", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|OOkOO:CommitUrlCacheEntry", keywords, diff --git a/win32/src/win32net/win32netmodule.cpp b/win32/src/win32net/win32netmodule.cpp index 45f0120c4d..1698bfb6fa 100644 --- a/win32/src/win32net/win32netmodule.cpp +++ b/win32/src/win32net/win32netmodule.cpp @@ -25,10 +25,6 @@ conversion is required. ******************************************************************/ // @doc -#ifndef UNICODE -#error This project requires a Unicode build. -#endif - #include "PyWinTypes.h" #include "lm.h" #include "lmuseflg.h" diff --git a/win32/src/win32pdhmodule.cpp b/win32/src/win32pdhmodule.cpp index 20764738a0..5bb417f15d 100644 --- a/win32/src/win32pdhmodule.cpp +++ b/win32/src/win32pdhmodule.cpp @@ -184,14 +184,6 @@ class TmpTCHAR { static PyObject *win32pdh_counter_error; -// Select whether to load ansi or unicode API functions -// Module is now always built as unicode, this can go away. -#ifdef UNICODE -#define A_OR_W "W" -#else -#define A_OR_W "A" -#endif - BOOL LoadPointers() { HMODULE handle = LoadLibrary(_T("pdh.dll")); @@ -199,29 +191,29 @@ BOOL LoadPointers() // PyErr_SetString(PyExc_RuntimeError, "The PDH DLL could not be located"); return FALSE; } - pPdhEnumObjects = (FuncPdhEnumObjects)GetProcAddress(handle, "PdhEnumObjects" A_OR_W); - pPdhEnumObjectItems = (FuncPdhEnumObjectItems)GetProcAddress(handle, "PdhEnumObjectItems" A_OR_W); + pPdhEnumObjects = (FuncPdhEnumObjects)GetProcAddress(handle, "PdhEnumObjectsW"); + pPdhEnumObjectItems = (FuncPdhEnumObjectItems)GetProcAddress(handle, "PdhEnumObjectItemsW"); pPdhCloseQuery = (FuncPdhCloseQuery)GetProcAddress(handle, "PdhCloseQuery"); pPdhRemoveCounter = (FuncPdhRemoveCounter)GetProcAddress(handle, "PdhRemoveCounter"); - pPdhOpenQuery = (FuncPdhOpenQuery)GetProcAddress(handle, "PdhOpenQuery" A_OR_W); - pPdhAddCounter = (FuncPdhAddCounter)GetProcAddress(handle, "PdhAddCounter" A_OR_W); - pPdhAddEnglishCounter = (FuncPdhAddCounter)GetProcAddress(handle, "PdhAddEnglishCounter" A_OR_W); - pPdhMakeCounterPath = (FuncPdhMakeCounterPath)GetProcAddress(handle, "PdhMakeCounterPath" A_OR_W); - pPdhGetCounterInfo = (FuncPdhGetCounterInfo)GetProcAddress(handle, "PdhGetCounterInfo" A_OR_W); + pPdhOpenQuery = (FuncPdhOpenQuery)GetProcAddress(handle, "PdhOpenQueryW"); + pPdhAddCounter = (FuncPdhAddCounter)GetProcAddress(handle, "PdhAddCounterW"); + pPdhAddEnglishCounter = (FuncPdhAddCounter)GetProcAddress(handle, "PdhAddEnglishCounterW"); + pPdhMakeCounterPath = (FuncPdhMakeCounterPath)GetProcAddress(handle, "PdhMakeCounterPathW"); + pPdhGetCounterInfo = (FuncPdhGetCounterInfo)GetProcAddress(handle, "PdhGetCounterInfoW"); pPdhGetFormattedCounterValue = (FuncPdhGetFormattedCounterValue)GetProcAddress(handle, "PdhGetFormattedCounterValue"); pPdhGetFormattedCounterArray = - (FuncPdhGetFormattedCounterArray)GetProcAddress(handle, "PdhGetFormattedCounterArray" A_OR_W); + (FuncPdhGetFormattedCounterArray)GetProcAddress(handle, "PdhGetFormattedCounterArrayW"); pPdhCollectQueryData = (FuncPdhCollectQueryData)GetProcAddress(handle, "PdhCollectQueryData"); - pPdhValidatePath = (FuncPdhValidatePath)GetProcAddress(handle, "PdhValidatePath" A_OR_W); - pPdhExpandCounterPath = (FuncPdhExpandCounterPath)GetProcAddress(handle, "PdhExpandCounterPath" A_OR_W); - pPdhParseCounterPath = (FuncPdhParseCounterPath)GetProcAddress(handle, "PdhParseCounterPath" A_OR_W); + pPdhValidatePath = (FuncPdhValidatePath)GetProcAddress(handle, "PdhValidatePathW"); + pPdhExpandCounterPath = (FuncPdhExpandCounterPath)GetProcAddress(handle, "PdhExpandCounterPathW"); + pPdhParseCounterPath = (FuncPdhParseCounterPath)GetProcAddress(handle, "PdhParseCounterPathW"); pPdhSetCounterScaleFactor = (FuncPdhSetCounterScaleFactor)GetProcAddress(handle, "PdhSetCounterScaleFactor"); - pPdhParseInstanceName = (FuncPdhParseInstanceName)GetProcAddress(handle, "PdhParseInstanceName" A_OR_W); - pPdhBrowseCounters = (FuncPdhBrowseCounters)GetProcAddress(handle, "PdhBrowseCounters" A_OR_W); - pPdhConnectMachine = (FuncPdhConnectMachine)GetProcAddress(handle, "PdhConnectMachine" A_OR_W); - pPdhLookupPerfNameByIndex = (FuncPdhLookupPerfNameByIndex)GetProcAddress(handle, "PdhLookupPerfNameByIndex" A_OR_W); - pPdhLookupPerfIndexByName = (FuncPdhLookupPerfIndexByName)GetProcAddress(handle, "PdhLookupPerfIndexByName" A_OR_W); + pPdhParseInstanceName = (FuncPdhParseInstanceName)GetProcAddress(handle, "PdhParseInstanceNameW"); + pPdhBrowseCounters = (FuncPdhBrowseCounters)GetProcAddress(handle, "PdhBrowseCountersW"); + pPdhConnectMachine = (FuncPdhConnectMachine)GetProcAddress(handle, "PdhConnectMachineW"); + pPdhLookupPerfNameByIndex = (FuncPdhLookupPerfNameByIndex)GetProcAddress(handle, "PdhLookupPerfNameByIndexW"); + pPdhLookupPerfIndexByName = (FuncPdhLookupPerfIndexByName)GetProcAddress(handle, "PdhLookupPerfIndexByNameW"); // Pdh error codes are in 2 different ranges PyWin_RegisterErrorMessageModule(PDH_CSTATUS_NO_MACHINE, PDH_CANNOT_SET_DEFAULT_REALTIME_DATASOURCE, handle); diff --git a/win32/src/win32pipe.i b/win32/src/win32pipe.i index e0d54ebb8c..d979dc3c64 100644 --- a/win32/src/win32pipe.i +++ b/win32/src/win32pipe.i @@ -37,17 +37,10 @@ static GetNamedPipeClientProcessIdfunc pfnGetNamedPipeServerSessionId = NULL; %} %{ -#if (PY_VERSION_HEX < 0x03000000) -extern PyObject *PyPopen(PyObject *self, PyObject *args); -extern PyObject *PyPopen2(PyObject *self, PyObject *args); -extern PyObject *PyPopen3(PyObject *self, PyObject *args); -extern PyObject *PyPopen4(PyObject *self, PyObject *args); -#else PyObject *PyPopen(PyObject *self, PyObject *args) {PyErr_SetString(PyExc_NotImplementedError, "not available in py3k"); return NULL;}; PyObject *PyPopen2(PyObject *self, PyObject *args) {PyErr_SetString(PyExc_NotImplementedError, "not available in py3k"); return NULL;}; PyObject *PyPopen3(PyObject *self, PyObject *args) {PyErr_SetString(PyExc_NotImplementedError, "not available in py3k"); return NULL;}; PyObject *PyPopen4(PyObject *self, PyObject *args) {PyErr_SetString(PyExc_NotImplementedError, "not available in py3k"); return NULL;}; -#endif // PY_VERSION_HEX %} // @pymeth popen|Version of popen that works in a GUI diff --git a/win32/src/win32popen.cpp b/win32/src/win32popen.cpp deleted file mode 100644 index 936aa5c39f..0000000000 --- a/win32/src/win32popen.cpp +++ /dev/null @@ -1,566 +0,0 @@ -// @doc - -#include "Python.h" - -// Not used in py3k -#if (PY_VERSION_HEX < 0x03000000) - -#include "malloc.h" -#include "io.h" -#include "fcntl.h" -#include "PyWinTypes.h" - -#define DllExport _declspec(dllexport) - -// These tell _PyPopen() wether to return 1, 2, or 3 file objects. -#define POPEN_1 1 -#define POPEN_2 2 -#define POPEN_3 3 -#define POPEN_4 4 - -static PyObject *_PyPopen(char *, int, int); - -static int _PyPclose(FILE *file); - -/* - * Internal dictionary mapping popen* file pointers to process handles, - * for use when retrieving the process exit code. See _PyPclose() below - * for more information on this dictionary's use. - */ -static PyObject *_PyPopenProcs = NULL; - -// @pymethod pipe|win32pipe|popen|Popen that works from a GUI. -// @rdesc The result of this function is a pipe (file) connected to the -// processes stdin or stdout, depending on the requested mode. -PyObject *PyPopen(PyObject *self, PyObject *args) -{ - char *cmdstring; - char *mode = "r"; - int bufsize = -1; - PyObject *f, *s; - int tm = 0; - - if (!PyArg_ParseTuple(args, "s|s:popen", - &cmdstring, // @pyparm string|cmdstring||The cmdstring to pass to the shell - &mode)) // @pyparm string|mode||Either 'r' or 'w' - return NULL; - - s = PyTuple_New(0); - - if (*mode == 'r') - tm = _O_RDONLY; - else if (*mode != 'w') { - PyErr_SetString(PyExc_ValueError, "mode must be 'r' or 'w'"); - return NULL; - } - else - tm = _O_WRONLY; - - if (*(mode + 1) == 't') - f = _PyPopen(cmdstring, tm | _O_TEXT, POPEN_1); - else if (*(mode + 1) == 'b') - f = _PyPopen(cmdstring, tm | _O_BINARY, POPEN_1); - else - f = _PyPopen(cmdstring, tm | _O_TEXT, POPEN_1); - - return f; -} - -// @pymethod (pipe, pipe)|win32pipe|popen2|Variation on -// @rdesc The result of this function is a pipe (file) connected to the -// processes stdin, and a pipe connected to the processes stdout. -PyObject *PyPopen2(PyObject *self, PyObject *args) -{ - char *cmdstring; - char *mode = "t"; - PyObject *f; - int tm = 0; - - if (!PyArg_ParseTuple(args, "s|s:popen2", - &cmdstring, // @pyparm string|cmdstring||The cmdstring to pass to the shell - &mode)) // @pyparm string|mode||Either 't' or 'b' - return NULL; - - if (*mode == 't') - tm = _O_TEXT; - else if (*mode != 'b') { - PyErr_SetString(PyExc_ValueError, "mode must be 't' or 'b'"); - return NULL; - } - else - tm = _O_BINARY; - - f = _PyPopen(cmdstring, tm, POPEN_2); - - return f; -} - -// @pymethod (pipe, pipe, pipe)|win32pipe|popen3|Variation on -// @rdesc The result of this function is 3 pipes - the processes stdin, stdout and stderr -PyObject *PyPopen3(PyObject *self, PyObject *args) -{ - char *cmdstring; - char *mode = "t"; - PyObject *f; - int tm = 0; - - if (!PyArg_ParseTuple(args, "s|s:Popen3", - &cmdstring, // @pyparm string|cmdstring||The cmdstring to pass to the shell - &mode)) // @pyparm string|mode||Either 't' or 'b' - return NULL; - - if (*mode == 't') - tm = _O_TEXT; - else if (*mode != 'b') { - PyErr_SetString(PyExc_ValueError, "mode must be 't' or 'b'"); - return NULL; - } - else - tm = _O_BINARY; - - f = _PyPopen(cmdstring, tm, POPEN_3); - - return f; -} - -// @pymethod (pipe, pipe)|win32pipe|popen4|Variation on -// @rdesc The result of this function is 2 pipes - the processes stdin, -// and stdout+stderr combined as a single pipe. -PyObject *PyPopen4(PyObject *self, PyObject *args) -{ - char *cmdstring; - char *mode = "t"; - PyObject *f; - int tm = 0; - - if (!PyArg_ParseTuple(args, "s|s:popen4", - &cmdstring, // @pyparm string|cmdstring||The cmdstring to pass to the shell - &mode)) // @pyparm string|mode||Either 't' or 'b' - return NULL; - - if (*mode == 't') - tm = _O_TEXT; - else if (*mode != 'b') { - PyErr_SetString(PyExc_ValueError, "mode must be 't' or 'b'"); - return NULL; - } - else - tm = _O_BINARY; - - f = _PyPopen(cmdstring, tm, POPEN_4); - - return f; -} - -static int _PyPopenCreateProcess(char *cmdstring, HANDLE hStdin, HANDLE hStdout, HANDLE hStderr, HANDLE *hProcess) -{ - PROCESS_INFORMATION piProcInfo; - STARTUPINFO siStartInfo; - char *s1, *s2, *s3 = " /c "; - DWORD i; - size_t x; - - if (i = GetEnvironmentVariable("COMSPEC", NULL, 0)) { - s1 = (char *)_alloca(i); - if (!(x = GetEnvironmentVariable("COMSPEC", s1, i))) - return FALSE; - x = i + strlen(s3) + strlen(cmdstring) + 1; - s2 = (char *)_alloca(x); - ZeroMemory(s2, x); - sprintf(s2, "%s%s%s", s1, s3, cmdstring); - } - // Could be an else here to try cmd.exe / command.com in the path - // Now we'll just error out.. - else - return FALSE; - - ZeroMemory(&siStartInfo, sizeof(STARTUPINFO)); - siStartInfo.cb = sizeof(STARTUPINFO); - siStartInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; - siStartInfo.hStdInput = hStdin; - siStartInfo.hStdOutput = hStdout; - siStartInfo.hStdError = hStderr; - siStartInfo.wShowWindow = SW_HIDE; - if (CreateProcess(NULL, s2, NULL, NULL, TRUE, 0, /* no new console so Ctrl+C kills child too */ - NULL, NULL, &siStartInfo, &piProcInfo)) { - // Close the handles now so anyone waiting is woken. - CloseHandle(piProcInfo.hThread); - - /* Return process handle */ - *hProcess = piProcInfo.hProcess; - return TRUE; - } - return FALSE; -} - -// The following code is based off of KB: Q190351 -static PyObject *_PyPopen(char *cmdstring, int mode, int n) -{ - HANDLE hChildStdinRd, hChildStdinWr, hChildStdoutRd, hChildStdoutWr, hChildStderrRd, hChildStderrWr, - hChildStdinWrDup, hChildStdoutRdDup, hChildStderrRdDup, hProcess; // hChildStdoutWrDup; - - SECURITY_ATTRIBUTES saAttr; - BOOL fSuccess; - int fd1, fd2, fd3; - FILE *f1, *f2, *f3; - long file_count; - PyObject *f; - - saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); - saAttr.bInheritHandle = TRUE; - saAttr.lpSecurityDescriptor = NULL; - - if (!CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0)) - return PyWin_SetAPIError("CreatePipe"); - - // Create new output read handle and the input write handle. Set - // the inheritance properties to FALSE. Otherwise, the child inherits - // the these handles; resulting in non-closeable handles to the pipes - // being created. - fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStdinWr, GetCurrentProcess(), &hChildStdinWrDup, 0, FALSE, - DUPLICATE_SAME_ACCESS); - if (!fSuccess) - return PyWin_SetAPIError("DuplicateHandle"); - - // Close the inheritable version of ChildStdin - // that we're using. - CloseHandle(hChildStdinWr); - - if (!CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0)) - return PyWin_SetAPIError("CreatePipe"); - - fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStdoutRd, GetCurrentProcess(), &hChildStdoutRdDup, 0, FALSE, - DUPLICATE_SAME_ACCESS); - if (!fSuccess) - return PyWin_SetAPIError("DuplicateHandle"); - - // Close the inheritable version of ChildStdout - // that we're using. - CloseHandle(hChildStdoutRd); - - if (n != POPEN_4) { - if (!CreatePipe(&hChildStderrRd, &hChildStderrWr, &saAttr, 0)) - return PyWin_SetAPIError("CreatePipe"); - fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStderrRd, GetCurrentProcess(), &hChildStderrRdDup, 0, - FALSE, DUPLICATE_SAME_ACCESS); - if (!fSuccess) - return PyWin_SetAPIError("DuplicateHandle"); - // Close the inheritable version of ChildStdErr that we're using. - CloseHandle(hChildStderrRd); - } - - switch (n) { - case POPEN_1: - switch (mode & (_O_RDONLY | _O_TEXT | _O_BINARY | _O_WRONLY)) { - case _O_WRONLY | _O_TEXT: - // Case for writing to child Stdin in text mode. - fd1 = _open_osfhandle((INT_PTR)hChildStdinWrDup, mode); - f1 = _fdopen(fd1, "w"); - f = PyFile_FromFile(f1, cmdstring, "w", _PyPclose); - PyFile_SetBufSize(f, 0); - // We don't care about these pipes anymore, so close them. - CloseHandle(hChildStdoutRdDup); - CloseHandle(hChildStderrRdDup); - break; - - case _O_RDONLY | _O_TEXT: - // Case for reading from child Stdout in text mode. - fd1 = _open_osfhandle((INT_PTR)hChildStdoutRdDup, mode); - f1 = _fdopen(fd1, "r"); - f = PyFile_FromFile(f1, cmdstring, "r", _PyPclose); - PyFile_SetBufSize(f, 0); - // We don't care about these pipes anymore, so close them. - CloseHandle(hChildStdinWrDup); - CloseHandle(hChildStderrRdDup); - break; - - case _O_RDONLY | _O_BINARY: - // Case for readinig from child Stdout in binary mode. - fd1 = _open_osfhandle((INT_PTR)hChildStdoutRdDup, mode); - f1 = _fdopen(fd1, "rb"); - f = PyFile_FromFile(f1, cmdstring, "rb", _PyPclose); - PyFile_SetBufSize(f, 0); - // We don't care about these pipes anymore, so close them. - CloseHandle(hChildStdinWrDup); - CloseHandle(hChildStderrRdDup); - break; - - case _O_WRONLY | _O_BINARY: - // Case for writing to child Stdin in binary mode. - fd1 = _open_osfhandle((INT_PTR)hChildStdinWrDup, mode); - f1 = _fdopen(fd1, "wb"); - f = PyFile_FromFile(f1, cmdstring, "wb", _PyPclose); - PyFile_SetBufSize(f, 0); - // We don't care about these pipes anymore, so close them. - CloseHandle(hChildStdoutRdDup); - CloseHandle(hChildStderrRdDup); - break; - } - file_count = 1; - break; - - case POPEN_2: - case POPEN_4: { - char *m1, *m2; - PyObject *p1, *p2; - - if (mode & _O_TEXT) { - m1 = "r"; - m2 = "w"; - } - else { - m1 = "rb"; - m2 = "wb"; - } - - fd1 = _open_osfhandle((INT_PTR)hChildStdinWrDup, mode); - f1 = _fdopen(fd1, m2); - fd2 = _open_osfhandle((INT_PTR)hChildStdoutRdDup, mode); - f2 = _fdopen(fd2, m1); - p1 = PyFile_FromFile(f1, cmdstring, m2, _PyPclose); - PyFile_SetBufSize(p1, 0); - p2 = PyFile_FromFile(f2, cmdstring, m1, _PyPclose); - PyFile_SetBufSize(p2, 0); - - if (n != 4) - CloseHandle(hChildStderrRdDup); - - f = Py_BuildValue("OO", p1, p2); - Py_XDECREF(p1); - Py_XDECREF(p2); - file_count = 2; - break; - } - - case POPEN_3: { - char *m1, *m2; - PyObject *p1, *p2, *p3; - - if (mode & _O_TEXT) { - m1 = "r"; - m2 = "w"; - } - else { - m1 = "rb"; - m2 = "wb"; - } - - fd1 = _open_osfhandle((INT_PTR)hChildStdinWrDup, mode); - f1 = _fdopen(fd1, m2); - fd2 = _open_osfhandle((INT_PTR)hChildStdoutRdDup, mode); - f2 = _fdopen(fd2, m1); - fd3 = _open_osfhandle((INT_PTR)hChildStderrRdDup, mode); - f3 = _fdopen(fd3, m1); - p1 = PyFile_FromFile(f1, cmdstring, m2, _PyPclose); - p2 = PyFile_FromFile(f2, cmdstring, m1, _PyPclose); - p3 = PyFile_FromFile(f3, cmdstring, m1, _PyPclose); - PyFile_SetBufSize(p1, 0); - PyFile_SetBufSize(p2, 0); - PyFile_SetBufSize(p3, 0); - f = Py_BuildValue("OOO", p1, p2, p3); - Py_XDECREF(p1); - Py_XDECREF(p2); - Py_XDECREF(p3); - file_count = 3; - break; - } - } - - if (n == POPEN_4) { - if (!_PyPopenCreateProcess(cmdstring, hChildStdinRd, hChildStdoutWr, hChildStdoutWr, &hProcess)) - return PyWin_SetAPIError("CreateProcess"); - } - else { - if (!_PyPopenCreateProcess(cmdstring, hChildStdinRd, hChildStdoutWr, hChildStderrWr, &hProcess)) - return PyWin_SetAPIError("CreateProcess"); - } - - /* - * Insert the files we've created into the process dictionary - * all referencing the list with the process handle and the - * initial number of files (see description below in _PyPclose). - * Since if _PyPclose later tried to wait on a process when all - * handles weren't closed, it could create a deadlock with the - * child, we spend some energy here to try to ensure that we - * either insert all file handles into the dictionary or none - * at all. It's a little clumsy with the various popen modes - * and variable number of files involved. - */ - if (!_PyPopenProcs) { - _PyPopenProcs = PyDict_New(); - } - - if (_PyPopenProcs) { - PyObject *procObj, *hProcessObj, *intObj, *fileObj[3]; - int ins_rc[3]; - - fileObj[0] = fileObj[1] = fileObj[2] = NULL; - ins_rc[0] = ins_rc[1] = ins_rc[2] = 0; - - procObj = PyList_New(2); - hProcessObj = PyLong_FromVoidPtr(hProcess); - intObj = PyLong_FromLong(file_count); - - if (procObj && hProcessObj && intObj) { - PyList_SetItem(procObj, 0, hProcessObj); - PyList_SetItem(procObj, 1, intObj); - - fileObj[0] = PyLong_FromVoidPtr(f1); - if (fileObj[0]) { - ins_rc[0] = PyDict_SetItem(_PyPopenProcs, fileObj[0], procObj); - } - if (file_count >= 2) { - fileObj[1] = PyLong_FromVoidPtr(f2); - if (fileObj[1]) { - ins_rc[1] = PyDict_SetItem(_PyPopenProcs, fileObj[1], procObj); - } - } - if (file_count >= 3) { - fileObj[2] = PyLong_FromVoidPtr(f3); - if (fileObj[2]) { - ins_rc[2] = PyDict_SetItem(_PyPopenProcs, fileObj[2], procObj); - } - } - - if (ins_rc[0] < 0 || !fileObj[0] || ins_rc[1] < 0 || (file_count > 1 && !fileObj[1]) || ins_rc[2] < 0 || - (file_count > 2 && !fileObj[2])) { - /* Something failed - remove any dictionary - * entries that did make it. - */ - if (!ins_rc[0] && fileObj[0]) { - PyDict_DelItem(_PyPopenProcs, fileObj[0]); - } - if (!ins_rc[1] && fileObj[1]) { - PyDict_DelItem(_PyPopenProcs, fileObj[1]); - } - if (!ins_rc[2] && fileObj[2]) { - PyDict_DelItem(_PyPopenProcs, fileObj[2]); - } - } - } - - /* - * Clean up our localized references for the dictionary keys - * and value since PyDict_SetItem will Py_INCREF any copies - * that got placed in the dictionary. - */ - Py_XDECREF(procObj); - Py_XDECREF(fileObj[0]); - Py_XDECREF(fileObj[1]); - Py_XDECREF(fileObj[2]); - } - - // Child is launched. Close the parents copy of those pipe handles - // that only the child should have open. - // You need to make sure that no handles to the write end of the - // output pipe are maintained in this process or else the pipe will - // not close when the child process exits and the ReadFile will hang. - if (!CloseHandle(hChildStdinRd)) - return PyWin_SetAPIError("CloseHandle"); - - if (!CloseHandle(hChildStdoutWr)) - return PyWin_SetAPIError("CloseHandle"); - - if ((n != 4) && (!CloseHandle(hChildStderrWr))) - return PyWin_SetAPIError("CloseHandle"); - - return f; -} - -/* - * Wrapper for fclose() to use for popen* files, so we can retrieve the - * exit code for the child process and return as a result of the close. - * - * This function uses the _PyPopenProcs dictionary in order to map the - * input file pointer to information about the process that was - * originally created by the popen* call that created the file pointer. - * The dictionary uses the file pointer as a key (with one entry - * inserted for each file returned by the original popen* call) and a - * single list object as the value for all files from a single call. - * The list object contains the Win32 process handle at [0], and a file - * count at [1], which is initialized to the total number of file - * handles using that list. - * - * This function closes whichever handle it is passed, and decrements - * the file count in the dictionary for the process handle pointed to - * by this file. On the last close (when the file count reaches zero), - * this function will wait for the child process and then return its - * exit code as the result of the close() operation. This permits the - * files to be closed in any order - it is always the close() of the - * final handle that will return the exit code. - */ -static int _PyPclose(FILE *file) -{ - int result; - DWORD exit_code; - HANDLE hProcess; - PyObject *procObj, *hProcessObj, *intObj, *fileObj; - long file_count; - - /* Close the file handle first, to ensure it can't block the - * child from exiting if it's the last handle. - */ - result = fclose(file); - - if (_PyPopenProcs) { - CEnterLeavePython _celp; - if ((fileObj = PyLong_FromVoidPtr(file)) != NULL && - (procObj = PyDict_GetItem(_PyPopenProcs, fileObj)) != NULL && - (hProcessObj = PyList_GetItem(procObj, 0)) != NULL && (intObj = PyList_GetItem(procObj, 1)) != NULL) { - hProcess = PyLong_AsVoidPtr(hProcessObj); - file_count = PyLong_AsLong(intObj); - - if (file_count > 1) { - /* Still other files referencing process */ - file_count--; - PyList_SetItem(procObj, 1, PyLong_FromLong(file_count)); - } - else { - Py_BEGIN_ALLOW_THREADS - /* Last file for this process */ - if (result != EOF && WaitForSingleObject(hProcess, INFINITE) != WAIT_FAILED && - GetExitCodeProcess(hProcess, &exit_code)) - { - /* Possible truncation here in 16-bit environments, but - * real exit codes are just the lower byte in any event. - */ - result = exit_code; - } - else - { - /* Indicate failure - this will cause the file object - * to raise an I/O error and translate the last Win32 - * error code from errno. We do have a problem with - * last errors that overlap the normal errno table, - * but that's a consistent problem with the file object. - */ - if (result != EOF) { - /* If the error wasn't from the fclose(), then - * set errno for the file object error handling. - */ - errno = GetLastError(); - } - result = -1; - } - /* Free up the native handle at this point */ - CloseHandle(hProcess); - Py_END_ALLOW_THREADS - } - - /* Remove this file pointer from dictionary */ - PyDict_DelItem(_PyPopenProcs, fileObj); - - if (PyDict_Size(_PyPopenProcs) == 0) { - Py_DECREF(_PyPopenProcs); - _PyPopenProcs = NULL; - } - - } /* if object retrieval ok */ - - Py_XDECREF(fileObj); - } /* if _PyPopenProcs */ - - return result; -} - -#endif // PY_VERSION_HEX < 0x03000000 diff --git a/win32/src/win32process.i b/win32/src/win32process.i index c0dbedc4aa..d8f633cfc5 100644 --- a/win32/src/win32process.i +++ b/win32/src/win32process.i @@ -1708,10 +1708,8 @@ PyObject *PyWriteProcessMemory(PyObject *self, PyObject *args) %init %{ -#if (PY_VERSION_HEX >= 0x03000000) if (PyType_Ready(&PySTARTUPINFOType) == -1) return NULL; -#endif FARPROC fp=NULL; HMODULE hmodule=NULL; diff --git a/win32/src/win32security.i b/win32/src/win32security.i index 2d73d8c0c0..36a641d9c7 100644 --- a/win32/src/win32security.i +++ b/win32/src/win32security.i @@ -813,7 +813,7 @@ void PyWinObject_FreeTOKEN_PRIVILEGES(TOKEN_PRIVILEGES *pPriv) pfnTranslateName=(TranslateNamefunc)loadapifunc("TranslateNameW",secur32_dll); pfnCreateWellKnownSid=(CreateWellKnownSidfunc)loadapifunc("CreateWellKnownSid",advapi32_dll); - + pfnDsBind=(DsBindfunc)loadapifunc("DsBindW", ntdsapi_dll); pfnDsUnBind=(DsUnBindfunc)loadapifunc("DsUnBindW", ntdsapi_dll); pfnDsGetSpn=(DsGetSpnfunc)loadapifunc("DsGetSpnW", ntdsapi_dll); @@ -831,7 +831,6 @@ void PyWinObject_FreeTOKEN_PRIVILEGES(TOKEN_PRIVILEGES *pPriv) pfnDsGetDcName=(DsGetDcNamefunc)loadapifunc("DsGetDcNameW", netapi32_dll); // Py3k requires that *all* types have to be initialized -#if (PY_VERSION_HEX >= 0x03000000) if (PyType_Ready(&PySecBufferType) == -1) return NULL; if (PyType_Ready(&PySecBufferDescType) == -1) @@ -840,7 +839,6 @@ void PyWinObject_FreeTOKEN_PRIVILEGES(TOKEN_PRIVILEGES *pPriv) return NULL; if (PyType_Ready(&PyCredHandleType) == -1) return NULL; -#endif // old names, these should not be used PyDict_SetItemString(d, "SecBufferType", (PyObject *)&PySecBufferType); diff --git a/win32/src/win32service.i b/win32/src/win32service.i index 4bfbdbb0d8..40d4f8579a 100644 --- a/win32/src/win32service.i +++ b/win32/src/win32service.i @@ -28,11 +28,9 @@ EnumServicesStatusExfunc fpEnumServicesStatusEx=NULL; %init %{ -#if (PY_VERSION_HEX >= 0x03000000) if (PyType_Ready(&PyHWINSTAType) == -1 || PyType_Ready(&PyHDESKType) == -1) return NULL; -#endif // All errors raised by this module are of this type. PyDict_SetItemString(d, "error", PyWinExc_ApiError); @@ -324,7 +322,7 @@ BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM ret) return TRUE; } -// @pymethod (PyUNICODE,...)|PyHWINSTA|EnumDesktops|Lists names of desktops in the window station +// @pymethod (string,...)|PyHWINSTA|EnumDesktops|Lists names of desktops in the window station PyObject *PyHWINSTA::EnumDesktops(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, ":EnumDesktops")) @@ -432,7 +430,7 @@ PyObject *PyGetThreadDesktop(PyObject *self, PyObject *args) } %} -// @pyswig (,,...)|EnumWindowStations|Lists names of window stations +// @pyswig (string,,...)|EnumWindowStations|Lists names of window stations // @comm Only window stations for which you have WINSTA_ENUMERATE access will be returned %native(EnumWindowStations) PyEnumWindowStations; %{ @@ -576,7 +574,7 @@ PyObject *PyOpenWindowStation(PyObject *self, PyObject *args) ACCESS_MASK DesiredAccess; PyObject *obwinsta_name, *ret=NULL; HWINSTA hwinsta; - // @pyparm str/PyUNICODE|szWinSta||Name of window station + // @pyparm string|szWinSta||Name of window station // @pyparm Bool|Inherit||Allow handle to be inherited by subprocesses // @pyparm int|DesiredAccess||Bitmask of access types if (!PyArg_ParseTuple(args,"Oll:OpenWindowStation",&obwinsta_name, &Inherit, &DesiredAccess)) @@ -604,7 +602,7 @@ PyObject *PyOpenDesktop(PyObject *self, PyObject *args) DWORD Flags; PyObject *obdesktop_name, *ret=NULL; HDESK hdesk; - // @pyparm str/unicode|szDesktop||Name of desktop to open + // @pyparm string|szDesktop||Name of desktop to open // @pyparm int|Flags||DF_ALLOWOTHERACCOUNTHOOK or 0 // @pyparm bool|Inherit||Allow handle to be inherited // @pyparm int|DesiredAccess||ACCESS_MASK specifying level of access for handle @@ -633,7 +631,7 @@ PyObject *PyCreateDesktop(PyObject *self, PyObject *args) ACCESS_MASK DesiredAccess; PSECURITY_ATTRIBUTES pSA; HDESK hdesk; - // @pyparm str/unicode|Desktop||Name of desktop to create + // @pyparm string|Desktop||Name of desktop to create // @pyparm int|Flags||DF_ALLOWOTHERACCOUNTHOOK or 0 // @pyparm int|DesiredAccess||An ACCESS_MASK determining level of access available thru returned handle // @pyparm |SecurityAttributes||Specifies inheritance and controls access to desktop @@ -703,7 +701,7 @@ PyObject *PyCreateWindowStation(PyObject *self, PyObject *args) ACCESS_MASK DesiredAccess; PSECURITY_ATTRIBUTES pSA; PyObject *obwinsta_name, *obSA; - // @pyparm str/unicode|WindowStation||Name of window station to create, or None + // @pyparm string|WindowStation||Name of window station to create, or None // @pyparm int|Flags||CWF_CREATE_ONLY or 0 // @pyparm int|DesiredAccess||Bitmask of access types available to returned handle // @pyparm |SecurityAttributes||Specifies security for window station, and whether handle is inheritable @@ -1103,12 +1101,12 @@ static PyObject *MyQueryServiceConfig(PyObject *self, PyObject *args) // @tupleitem 0|int|ServiceType|Combination of SERVICE_*_DRIVER or SERVICE_*_PROCESS constants // @tupleitem 1|int|StartType|One of SERVICE_*_START constants // @tupleitem 2|int|ErrorControl|One of SERVICE_ERROR_* constants - // @tupleitem 3||BinaryPathName|Service's binary executable, can also contain command line args - // @tupleitem 4||LoadOrderGroup|Loading group that service is a member of + // @tupleitem 3|string|BinaryPathName|Service's binary executable, can also contain command line args + // @tupleitem 4|string|LoadOrderGroup|Loading group that service is a member of // @tupleitem 5|int|TagId|Order of service within its load order group - // @tupleitem 6|[,...]|Dependencies|Sequence of names of services on which this service depends - // @tupleitem 7||ServiceStartName|Account name under which service will run - // @tupleitem 8||DisplayName|Name of service + // @tupleitem 6|[string,...]|Dependencies|Sequence of names of services on which this service depends + // @tupleitem 7|string|ServiceStartName|Account name under which service will run + // @tupleitem 8|string|DisplayName|Name of service PyObject *retval = Py_BuildValue("lllNNlNNN", config->dwServiceType, config->dwStartType, @@ -1189,13 +1187,13 @@ typedef float SC_HANDLE, SERVICE_STATUS_HANDLE, SC_LOCK; // This is just to keep // @pyswig |OpenService|Returns a handle to the specified service. SC_HANDLE OpenService( SC_HANDLE hSCManager, // @pyparm |scHandle||Handle to the Service Control Mananger - TCHAR *name, // @pyparm |name||The name of the service to open. + TCHAR *name, // @pyparm string|name||The name of the service to open. unsigned long desiredAccess); // @pyparm int|desiredAccess||The access desired. // @pyswig |OpenSCManager|Returns a handle to the service control manager SC_HANDLE OpenSCManager( - TCHAR *INPUT_NULLOK, // @pyparm |machineName||The name of the computer, or None - TCHAR *INPUT_NULLOK, // @pyparm |dbName||The name of the service database, or None + TCHAR *INPUT_NULLOK, // @pyparm string|machineName||The name of the computer, or None + TCHAR *INPUT_NULLOK, // @pyparm string|dbName||The name of the service database, or None unsigned long desiredAccess); // @pyparm int|desiredAccess||The access desired. (combination of win32service.SC_MANAGER_* flags) %{ @@ -1342,13 +1340,13 @@ PyObject *MyQueryServiceObjectSecurity(PyObject *self, PyObject *args) } %} -// @pyswig |GetServiceKeyName|Translates a service display name into its registry key name +// @pyswig string|GetServiceKeyName|Translates a service display name into its registry key name %native (GetServiceKeyName) MyGetServiceKeyName; %{ PyObject *MyGetServiceKeyName(PyObject *self, PyObject *args) { // @pyparm |hSCManager||Handle to service control manager as returned by - // @pyparm |DisplayName||Display name of a service + // @pyparm string|DisplayName||Display name of a service SC_HANDLE h; PyObject *obh; WCHAR *displayname; @@ -1370,13 +1368,13 @@ PyObject *MyGetServiceKeyName(PyObject *self, PyObject *args) } %} -// @pyswig |GetServiceDisplayName|Translates an internal service name into its display name +// @pyswig string|GetServiceDisplayName|Translates an internal service name into its display name %native (GetServiceDisplayName) MyGetServiceDisplayName; %{ PyObject *MyGetServiceDisplayName(PyObject *self, PyObject *args) { // @pyparm |hSCManager||Handle to service control manager as returned by - // @pyparm |ServiceName||Name of service + // @pyparm string|ServiceName||Name of service SC_HANDLE h; PyObject *obh; WCHAR *keyname; @@ -1417,18 +1415,18 @@ BOOLAPI DeleteService(SC_HANDLE); // @pyswig /(, int)|CreateService|Creates a new service. %name (CreateService) PyObject * MyCreateService( SC_HANDLE hSCManager, // @pyparm |scHandle||handle to service control manager database - TCHAR *name, // @pyparm |name||Name of service - TCHAR *displayName, // @pyparm |displayName||Display name + TCHAR *name, // @pyparm string|name||Name of service + TCHAR *displayName, // @pyparm string|displayName||Display name DWORD dwDesiredAccess, // @pyparm int|desiredAccess||type of access to service DWORD dwServiceType, // @pyparm int|serviceType||type of service DWORD dwStartType, // @pyparm int|startType||When/how to start service DWORD dwErrorControl, // @pyparm int|errorControl||severity if service fails to start - TCHAR *binaryFile, // @pyparm |binaryFile||name of binary file - TCHAR *INPUT_NULLOK, // @pyparm |loadOrderGroup||name of load ordering group , or None + TCHAR *binaryFile, // @pyparm string|binaryFile||name of binary file + TCHAR *INPUT_NULLOK, // @pyparm string|loadOrderGroup||name of load ordering group , or None BOOL bFetchTag, // @pyparm int|bFetchTag||Should the tag be fetched and returned? If TRUE, the result is a tuple of (handle, tag), otherwise just handle. - PyObject *pyobject, // @pyparm [,...]|serviceDeps||sequence of dependency names - TCHAR *INPUT_NULLOK, // @pyparm |acctName||account name of service, or None - TCHAR *INPUT_NULLOK // @pyparm |password||password for service account , or None + PyObject *pyobject, // @pyparm [string,...]|serviceDeps||sequence of dependency names + TCHAR *INPUT_NULLOK, // @pyparm string|acctName||account name of service, or None + TCHAR *INPUT_NULLOK // @pyparm string|password||password for service account , or None ); // @pyswig int/None|ChangeServiceConfig|Changes the configuration of an existing service. @@ -1437,13 +1435,13 @@ BOOLAPI DeleteService(SC_HANDLE); DWORD dwServiceType, // @pyparm int|serviceType||type of service, or SERVICE_NO_CHANGE DWORD dwStartType, // @pyparm int|startType||When/how to start service, or SERVICE_NO_CHANGE DWORD dwErrorControl, // @pyparm int|errorControl||severity if service fails to start, or SERVICE_NO_CHANGE - TCHAR *INPUT_NULLOK, // @pyparm |binaryFile||name of binary file, or None - TCHAR *INPUT_NULLOK, // @pyparm |loadOrderGroup||name of load ordering group , or None + TCHAR *INPUT_NULLOK, // @pyparm string|binaryFile||name of binary file, or None + TCHAR *INPUT_NULLOK, // @pyparm string|loadOrderGroup||name of load ordering group , or None BOOL bFetchTag, // @pyparm int|bFetchTag||Should the tag be fetched and returned? If TRUE, the result is the tag, else None. - PyObject *pyobject, // @pyparm [,...]|serviceDeps||sequence of dependency names - TCHAR *INPUT_NULLOK, // @pyparm |acctName||account name of service, or None - TCHAR *INPUT_NULLOK, // @pyparm |password||password for service account , or None - TCHAR *INPUT_NULLOK // @pyparm |displayName||Display name + PyObject *pyobject, // @pyparm [string,...]|serviceDeps||sequence of dependency names + TCHAR *INPUT_NULLOK, // @pyparm string|acctName||account name of service, or None + TCHAR *INPUT_NULLOK, // @pyparm string|password||password for service account , or None + TCHAR *INPUT_NULLOK // @pyparm string|displayName||Display name ); // @pyswig int|LockServiceDatabase|Locks the service database. @@ -1457,7 +1455,7 @@ BOOLAPI UnlockServiceDatabase( ); %{ -// @pyswig (int, , int)|QueryServiceLockStatus|Retrieves the lock status of the specified service control manager database. +// @pyswig (int, string, int)|QueryServiceLockStatus|Retrieves the lock status of the specified service control manager database. static PyObject *PyQueryServiceLockStatus(PyObject *self, PyObject *args) { SC_HANDLE handle; @@ -1494,12 +1492,12 @@ static PyObject *PyQueryServiceLockStatus(PyObject *self, PyObject *args) // @object SC_ACTION|Tuple of 2 ints (Type,Delay) used to represent an SC_ACTION structure // @prop int|Type|One of SC_ACTION_NONE, SC_ACTION_REBOOT, SC_ACTION_RESTART, SC_ACTION_RUN_COMMAND -// @prop int|Delay|Time delay before specified action is taken (in milliseconds) +// @prop int|Delay|Time delay before specified action is taken (in milliseconds) // @object SERVICE_FAILURE_ACTIONS|A dictionary representing a SERVICE_FAILURE_ACTIONS structure // @prop int|ResetPeriod|Indicates how many seconds to wait to reset the failure count, can be INFINITE -// @prop str/|RebootMsg|Message displayed when reboot action is taken -// @prop str/|Command|Command line to execute for SC_ACTION_RUN_COMMAND +// @prop string|RebootMsg|Message displayed when reboot action is taken +// @prop string|Command|Command line to execute for SC_ACTION_RUN_COMMAND // @prop tuple|Actions|A tuple of tuples %{ diff --git a/win32/src/win32trace.cpp b/win32/src/win32trace.cpp index 41588d4a04..c4360168c1 100644 --- a/win32/src/win32trace.cpp +++ b/win32/src/win32trace.cpp @@ -140,11 +140,7 @@ static PyObject *PyTraceObject_read(PyObject *self, PyObject *args) BOOL ok = static_cast(self)->ReadData(&data, &len, 0); if (!ok) return NULL; -#if (PY_VERSION_HEX < 0x03000000) - PyObject *result = PyBytes_FromStringAndSize(data, len); -#else PyObject *result = PyUnicode_DecodeLatin1(data, len, "replace"); -#endif free(data); return result; } @@ -159,11 +155,7 @@ static PyObject *PyTraceObject_blockingread(PyObject *self, PyObject *args) BOOL ok = static_cast(self)->ReadData(&data, &len, milliSeconds); if (!ok) return NULL; -#if (PY_VERSION_HEX < 0x03000000) - PyObject *result = PyBytes_FromStringAndSize(data, len); -#else PyObject *result = PyUnicode_DecodeLatin1(data, len, "replace"); -#endif free(data); return result; } diff --git a/win32/src/win32wnet/PyNCB.cpp b/win32/src/win32wnet/PyNCB.cpp index ab2f52aab6..d1117362a0 100644 --- a/win32/src/win32wnet/PyNCB.cpp +++ b/win32/src/win32wnet/PyNCB.cpp @@ -16,18 +16,6 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ // @doc -#if !defined(_WIN32_WCE) // so far, none of this is supported by Windows CE -#if defined(_WIN32_WCE_) // defined by Windows CE compiler environment - -#ifndef UNICODE -#define UNICODE -#endif - -#ifndef _UNICODE -#define _UNICODE -#endif - -#endif #include "Pywintypes.h" #include @@ -295,7 +283,7 @@ int PyNCB::setattro(PyObject *self, PyObject *obname, PyObject *v) Py_DECREF(ob_buf); return -1; } - + if (pybuf.len() > USHRT_MAX) { Py_DECREF(ob_buf); PyErr_Format(PyExc_ValueError, "Buffer can be at most %d bytes", USHRT_MAX); @@ -314,5 +302,3 @@ int PyNCB::setattro(PyObject *self, PyObject *obname, PyObject *v) } return PyObject_GenericSetAttr(self, obname, v); } - -#endif diff --git a/win32/src/win32wnet/PyNetresource.cpp b/win32/src/win32wnet/PyNetresource.cpp index 049f288b2f..62be645b32 100644 --- a/win32/src/win32wnet/PyNetresource.cpp +++ b/win32/src/win32wnet/PyNetresource.cpp @@ -17,18 +17,6 @@ ******************************************************************/ // @doc -#if defined(_WIN32_WCE_) // defined by the Windows CE compiler environment - -#ifndef UNICODE -#define UNICODE -#endif - -#ifndef _UNICODE -#define _UNICODE -#endif - -#endif - #include "PyWinTypes.h" #include "netres.h" // C++ header file for NETRESOURCE object @@ -77,11 +65,7 @@ __declspec(dllexport) PyTypeObject PyNETRESOURCEType = { 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ -#if (PY_VERSION_HEX >= 0x03000000) - 0, /* tp_as_async */ -#else - PyNETRESOURCE::compareFunc, /* tp_compare */ -#endif + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ diff --git a/win32/src/win32wnet/win32wnet.cpp b/win32/src/win32wnet/win32wnet.cpp index 6766df2409..a990682463 100644 --- a/win32/src/win32wnet/win32wnet.cpp +++ b/win32/src/win32wnet/win32wnet.cpp @@ -24,10 +24,6 @@ WRT Mark Hammond, on who's examples much of this is based. This module seeks to implement the WNET win32 api functions for Windows NT. - It will compile for both UNICODE and ASCII environments. By extension of the - UNICODE compatibility, it seeks to support Windows CE. This functionality - (Windows CE) has not yet been tested (or even compiled!). - REVISION HISTORY: 7/00 - Convert comments to autoduck strings. mh @@ -40,18 +36,6 @@ 2/99 - First public release. Work in Progress. SC */ -#if defined(_WIN32_WCE_) // defined by Windows CE compiler environment - -#ifndef UNICODE -#define UNICODE -#endif - -#ifndef _UNICODE -#define _UNICODE -#endif - -#endif - #include "PyWinTypes.h" #include "PyWinObjects.h" // for the PyHANDLE impl. #include "netres.h" // NETRESOURCE Type