[pywin32-checkins] /hgroot/pywin32/pywin32: Remove more Python 2.3 workarounds
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <pyw...@li...> - 2013-04-11 03:04:58
|
changeset 07ce8a09c2ac in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=07ce8a09c2ac summary: Remove more Python 2.3 workarounds diffstat: Pythonwin/pywin/debugger/debugger.py | 8 +- SWIG/swig_lib/python/pywintypes.i | 13 +- com/win32com/client/build.py | 8 +- com/win32com/test/testShell.py | 7 - com/win32comext/authorization/src/PyGSecurityInformation.cpp | 4 - com/win32comext/shell/src/shell.cpp | 13 - isapi/src/StdAfx.h | 6 - isapi/threaded_extension.py | 9 - pywin32_postinstall.py | 4 +- setup.py | 227 +++------- win32/src/PyWinTypes.h | 103 +---- win32/src/odbc.cpp | 6 - win32/src/win32consolemodule.cpp | 4 - win32/src/win32dynamicdialog.cpp | 5 - win32/src/win32file.i | 8 +- win32/src/win32gui.i | 19 - win32/test/test_win32file.py | 7 +- 17 files changed, 73 insertions(+), 378 deletions(-) diffs (truncated from 815 to 300 lines): diff -r cc9272f5fb01 -r 07ce8a09c2ac Pythonwin/pywin/debugger/debugger.py --- a/Pythonwin/pywin/debugger/debugger.py Mon Apr 08 08:51:02 2013 -0400 +++ b/Pythonwin/pywin/debugger/debugger.py Wed Apr 10 23:03:24 2013 -0400 @@ -651,10 +651,7 @@ try: if start_stepping: self.skipBotFrame = SKIP_STEP else: self.skipBotFrame = SKIP_RUN - if sys.version_info > (2,2): - exec cmd in globals, locals - else: - _doexec(cmd, globals, locals) + exec cmd in globals, locals except bdb.BdbQuit: pass finally: @@ -986,6 +983,3 @@ line = linecache.getline(filename, lineno) print "%s(%d): %s" % (os.path.basename(filename), lineno, line[:-1].expandtabs(4)) return 0 - -def _doexec(cmd, globals, locals): - exec cmd in globals, locals diff -r cc9272f5fb01 -r 07ce8a09c2ac SWIG/swig_lib/python/pywintypes.i --- a/SWIG/swig_lib/python/pywintypes.i Mon Apr 08 08:51:02 2013 -0400 +++ b/SWIG/swig_lib/python/pywintypes.i Wed Apr 10 23:03:24 2013 -0400 @@ -47,18 +47,7 @@ // PyLong_AsUnsignedLongMask isn't ideal - no overflow checking - but // this is what the 'k' format specifier in PyArg_ParseTuple uses, and // that is what much of pywin32 uses for DWORDS, so we use it here too - // Also, Python 2.3 and below will not accept a plain int for the PyLong_* functions - #if (PY_VERSION_HEX < 0x02040000) - { - PyObject *tmpLong = PyNumber_Long($source); - if (tmpLong == NULL) - return NULL; - $target = PyLong_AsUnsignedLongMask(tmpLong); - Py_DECREF(tmpLong); - } - #else - $target = PyLong_AsUnsignedLongMask($source); - #endif + $target = PyLong_AsUnsignedLongMask($source); if ($target==(DWORD)-1 && PyErr_Occurred()) return NULL; } diff -r cc9272f5fb01 -r 07ce8a09c2ac com/win32com/client/build.py --- a/com/win32com/client/build.py Mon Apr 08 08:51:02 2013 -0400 +++ b/com/win32com/client/build.py Wed Apr 10 23:03:24 2013 -0400 @@ -394,13 +394,7 @@ assert typeinfo is not None, "Cant build vtables without type info!" meth_list = list(self.mapFuncs.values()) + list(self.propMapGet.values()) + list(self.propMapPut.values()) - - if sys.version_info < (2,4): - def cmp_vtable_off(m1, m2): - return cmp(m1.desc[7], m2.desc[7]) - meth_list.sort(cmp_vtable_off) - else: - meth_list.sort(key=lambda m: m.desc[7]) + meth_list.sort(key=lambda m: m.desc[7]) # Now turn this list into the run-time representation # (ready for immediate use or writing to gencache) diff -r cc9272f5fb01 -r 07ce8a09c2ac com/win32com/test/testShell.py --- a/com/win32com/test/testShell.py Mon Apr 08 08:51:02 2013 -0400 +++ b/com/win32com/test/testShell.py Wed Apr 10 23:03:24 2013 -0400 @@ -145,9 +145,6 @@ self._testSimple(True) def testComplex(self): - if sys.hexversion < 0x2030000: - # no kw-args to dict in 2.2 - not worth converting! - return clsid = pythoncom.MakeIID("{CD637886-DB8B-4b04-98B5-25731E1495BE}") ctime, atime, wtime = self._getTestTimes() d = dict(cFileName="foo.txt", @@ -163,10 +160,6 @@ def testUnicode(self): # exercise a bug fixed in build 210 - multiple unicode objects failed. - if sys.hexversion < 0x2030000: - # no kw-args to dict in 2.2 - not worth converting! - return - ctime, atime, wtime = self._getTestTimes() d = [dict(cFileName="foo.txt", sizel=(1,2), diff -r cc9272f5fb01 -r 07ce8a09c2ac com/win32comext/authorization/src/PyGSecurityInformation.cpp --- a/com/win32comext/authorization/src/PyGSecurityInformation.cpp Mon Apr 08 08:51:02 2013 -0400 +++ b/com/win32comext/authorization/src/PyGSecurityInformation.cpp Wed Apr 10 23:03:24 2013 -0400 @@ -281,11 +281,7 @@ else{ hr=InvokeViaPolicy("MapGeneric", &result, "OBk", obObjectType, *pAceFlags, *pMask); if (!FAILED(hr)){ -#if (PY_VERSION_HEX < 0x02030000) - *pMask=PyLong_AsUnsignedLong(result); -#else *pMask=PyInt_AsUnsignedLongMask(result); -#endif if ((*pMask==-1) && PyErr_Occurred()) hr=MAKE_PYCOM_GATEWAY_FAILURE_CODE("MapGeneric"); else diff -r cc9272f5fb01 -r 07ce8a09c2ac com/win32comext/shell/src/shell.cpp --- a/com/win32comext/shell/src/shell.cpp Mon Apr 08 08:51:02 2013 -0400 +++ b/com/win32comext/shell/src/shell.cpp Wed Apr 10 23:03:24 2013 -0400 @@ -1053,8 +1053,6 @@ return ok; } -#if (PY_VERSION_HEX >= 0x02030000) // PyGILState only in 2.3+ - // Callback for BrowseForFolder struct PyCallback { PyObject *fn; @@ -1096,8 +1094,6 @@ return rc; } -#endif // PY_VERSION_HEX - // @object PySHELL_ITEM_RESOURCE|Tuple of (<o PyIID>, str) that identifies a shell resource BOOL PyWinObject_AsSHELL_ITEM_RESOURCE(PyObject *ob, SHELL_ITEM_RESOURCE *psir) { @@ -1144,9 +1140,7 @@ TCHAR retPath[MAX_PATH]; bi.pszDisplayName = retPath; LPITEMIDLIST pl = NULL; -#if (PY_VERSION_HEX >= 0x02030000) // PyGILState only in 2.3+ PyCallback pycb; -#endif if(!PyArg_ParseTuple(args, "|OOOlOO:SHBrowseForFolder", &obhwndOwner, // @pyparm <o PyHANDLE>|hwndOwner|None|Parent window for the dialog box, can be None @@ -1159,7 +1153,6 @@ if (!PyWinObject_AsHANDLE(obhwndOwner, (HANDLE *)&bi.hwndOwner)) return NULL; if (obcb != Py_None) { -#if (PY_VERSION_HEX >= 0x02030000) // PyGILState only in 2.3+ if (!PyCallable_Check(obcb)) { PyErr_SetString(PyExc_TypeError, "Callback item must None or a callable object"); goto done; @@ -1168,12 +1161,6 @@ pycb.data = obcbparam; bi.lParam = (LPARAM)&pycb; bi.lpfn = PyBrowseCallbackProc; -#else // PY_VERSION_HEX - PyErr_SetString(PyExc_NotImplementedError, - "Callbacks can only be specified in Python 2.3+"); - return NULL; -#endif // PY_VERSION_HEX - } // else bi.lParam/lpfn remains 0 if (!PyObject_AsPIDL(obPIDL, (LPITEMIDLIST *)&bi.pidlRoot, TRUE)) goto done; diff -r cc9272f5fb01 -r 07ce8a09c2ac isapi/src/StdAfx.h --- a/isapi/src/StdAfx.h Mon Apr 08 08:51:02 2013 -0400 +++ b/isapi/src/StdAfx.h Wed Apr 10 23:03:24 2013 -0400 @@ -37,12 +37,6 @@ #undef small #include "Python.h" -// No Py_RETURN_NONE in py23 -#if (PY_VERSION_HEX < 0x02040000) -/* Macro for returning Py_None from a function */ -#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None -#endif - // include structmember here to deal with warnings related to WRITE_RESTRICTED #ifdef WRITE_RESTRICTED #undef WRITE_RESTRICTED diff -r cc9272f5fb01 -r 07ce8a09c2ac isapi/threaded_extension.py --- a/isapi/threaded_extension.py Mon Apr 08 08:51:02 2013 -0400 +++ b/isapi/threaded_extension.py Wed Apr 10 23:03:24 2013 -0400 @@ -11,15 +11,6 @@ from win32event import INFINITE from pywintypes import OVERLAPPED -# Python 2.3 and earlier insists on "C" locale - if it isn't, subtle things -# break, such as floating point constants loaded from .pyc files. -# The threading module uses such floating-points as an argument to sleep(), -# resulting in extremely long sleeps when tiny intervals are specified. -# We can work around this by resetting the C locale before the import. -if sys.hexversion < 0x02040000: - import locale - locale.setlocale(locale.LC_NUMERIC, "C") - import threading import traceback diff -r cc9272f5fb01 -r 07ce8a09c2ac pywin32_postinstall.py --- a/pywin32_postinstall.py Mon Apr 08 08:51:02 2013 -0400 +++ b/pywin32_postinstall.py Wed Apr 10 23:03:24 2013 -0400 @@ -451,9 +451,7 @@ # Check the MFC dll exists - it is doesn't, point them at it # (I should install it, but its a bit tricky with distutils) # Unfortunately, this is quite likely on Windows XP and MFC71.dll - if sys.hexversion < 0x2040000: - mfc_dll = "mfc42.dll" - elif sys.hexversion < 0x2060000: + if sys.hexversion < 0x2060000: mfc_dll = "mfc71.dll" elif sys.hexversion < 0x2070000: mfc_dll = "mfc90.dll" diff -r cc9272f5fb01 -r 07ce8a09c2ac setup.py --- a/setup.py Mon Apr 08 08:51:02 2013 -0400 +++ b/setup.py Wed Apr 10 23:03:24 2013 -0400 @@ -19,13 +19,10 @@ versions. Below are the Windows SDK versions required (and the URL - although these are subject to being changed by MS at any time:) -Python 2.3->2.5: +Python 2.4->2.5: Microsoft Windows Software Development Kit Update for Windows Vista (version 6.0) http://www.microsoft.com/downloads/en/details.aspx?FamilyID=4377f86d-c913-4b5c-b87e-ef72e5b4e065 - ** If you want to build Python 2.3, be sure to install the SDK compilers - too - although we don't use them, this setup option installs some .lib - files we do need. - ** + Python 2.6+: Microsoft Windows SDK for Windows 7 and .NET Framework 4 (version 7.1) http://www.microsoft.com/downloads/en/details.aspx?FamilyID=6b6c21d2-2006-4afa-9702-529fa782d63b @@ -94,27 +91,9 @@ from distutils.command.build_py import build_py from distutils.command.build_scripts import build_scripts -try: - from distutils.command.bdist_msi import bdist_msi -except ImportError: - # py23 and earlier - bdist_msi = None -try: - from distutils.msvccompiler import get_build_version -except ImportError: - # py22 - def get_build_version(): - return 6.0 -# nor distutils.log -try: - from distutils import log -except ImportError: - class Log: - def debug(self, msg, *args): - print msg % args - def info(self, msg, *args): - print msg % args - log = Log() +from distutils.command.bdist_msi import bdist_msi +from distutils.msvccompiler import get_build_version +from distutils import log # some modules need a static CRT to avoid problems caused by them having a # manifest. @@ -460,16 +439,14 @@ # basic info - but its better than nothing!) # For now use the temp dir - later we may package them, so should # maybe move them next to the output file. - # ack - but fails with obscure errors in py23 :( - if sys.version_info > (2,4): - pch_dir = os.path.join(build_ext.build_temp) - if not build_ext.debug: - self.extra_compile_args.append("/Zi") - self.extra_compile_args.append("/Fd%s\%s_vc.pdb" % - (pch_dir, self.name)) - self.extra_link_args.append("/DEBUG") - self.extra_link_args.append("/PDB:%s\%s.pdb" % - (pch_dir, self.name)) + pch_dir = os.path.join(build_ext.build_temp) + if not build_ext.debug: + self.extra_compile_args.append("/Zi") + self.extra_compile_args.append("/Fd%s\%s_vc.pdb" % + (pch_dir, self.name)) + self.extra_link_args.append("/DEBUG") + self.extra_link_args.append("/PDB:%s\%s.pdb" % + (pch_dir, self.name)) # enable unwind semantics - some stuff needs it and I can't see # it hurting self.extra_compile_args.append("/EHsc") @@ -807,16 +784,6 @@ os.environ["LIB"] += ";" + os.path.join(sdk_dir, 'VC', 'LIB') log.debug("Vista SDK found: %%LIB%% now %s", os.environ["LIB"]) - if sys.hexversion < 0x02030000: - # Python 2.2 distutils doesn't handle the 'PC'/PCBuild directory for - # us (it only exists if building from the source tree) - extra = os.path.join(sys.exec_prefix, 'PC') - if extra not in self.include_dirs and os.path.isdir(extra): - self.compiler.add_include_dir(extra) - extra = os.path.join(sys.exec_prefix, 'PCBuild') - if extra not in self.library_dirs and os.path.isdir(extra): - self.compiler.add_library_dir(os.path.join(extra)) - def _why_cant_build_extension(self, ext): # Return None, or a reason it can't be built. # This kinda sucks, but I'm giving up on exchange support in 64bit @@ -884,9 +851,6 @@ return "No library '%s'" % lib self.found_libraries[lib.lower()] = found patched_libs.append(os.path.splitext(os.path.basename(found))[0]) - # axdebug struggles under debug builds - worry about that when I care :) |