[pywin32-checkins] /hgroot/pywin32/pywin32: 2 new changesets
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <pyw...@li...> - 2013-04-14 05:01:16
|
changeset 6eb23bcb9730 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=6eb23bcb9730 summary: Handle REG_QWORD (64-bit ints) changeset f7dd8d279929 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=f7dd8d279929 summary: Remove some more 2.3 workarounds diffstat: Pythonwin/win32uiExt.h | 9 --------- com/win32com/client/genpy.py | 22 +++++++--------------- com/win32com/test/pippo_server.py | 5 ----- win32/Demos/OpenEncryptedFileRaw.py | 2 +- win32/Demos/win32rcparser_demo.py | 6 ------ win32/src/win32apimodule.cpp | 31 +++++++++++++++++++++++++++++-- win32/test/test_win32api.py | 1 + win32/test/test_win32file.py | 11 ++--------- win32/test/testall.py | 21 +++++++-------------- 9 files changed, 47 insertions(+), 61 deletions(-) diffs (225 lines): diff -r 07ce8a09c2ac -r f7dd8d279929 Pythonwin/win32uiExt.h --- a/Pythonwin/win32uiExt.h Wed Apr 10 23:03:24 2013 -0400 +++ b/Pythonwin/win32uiExt.h Sun Apr 14 01:00:24 2013 -0400 @@ -993,19 +993,10 @@ template <class T> const AFX_MSGMAP_ENTRY CPythonPrtDlgFramework<T>::_messageEntries[] = { -#if _MFC_VER < 0x0700 - // Python 2.3 (ie, VS6) doesn't like the new version below. - ON_MESSAGE(WM_INITDIALOG, HandleInitDialog) - ON_COMMAND(IDC_PRINT_TO_FILE, HandlePrintToFile) - ON_COMMAND(IDC_PRINT_COLLATE, HandleCollate) - ON_COMMAND_RANGE(IDC_PRINT_RANGE_ALL, IDC_PRINT_RANGE_PAGES, HandlePrintRange) -#else - // Either vista/x64 doesn't like the old version above. ON_MESSAGE(WM_INITDIALOG, &CPythonPrtDlgFramework<T>::HandleInitDialog) ON_COMMAND(IDC_PRINT_TO_FILE, &CPythonPrtDlgFramework<T>::HandlePrintToFile) ON_COMMAND(IDC_PRINT_COLLATE, &CPythonPrtDlgFramework<T>::HandleCollate) ON_COMMAND_RANGE(IDC_PRINT_RANGE_ALL, IDC_PRINT_RANGE_PAGES, &CPythonPrtDlgFramework<T>::HandlePrintRange) -#endif {0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 } }; diff -r 07ce8a09c2ac -r f7dd8d279929 com/win32com/client/genpy.py --- a/com/win32com/client/genpy.py Wed Apr 10 23:03:24 2013 -0400 +++ b/com/win32com/client/genpy.py Sun Apr 14 01:00:24 2013 -0400 @@ -204,22 +204,14 @@ vdesc = entry.desc if vdesc[4] == pythoncom.VAR_CONST: val = vdesc[1] - if sys.version_info <= (2,4) and (isinstance(val, int) or isinstance(val, long)): - # in python 2.3, 0x80000000L == 2147483648 - if val==2147483648: # == 0x80000000L - special case for 2.3... - use = "0x80000000L" # 'L' for future warning - elif val > 2147483648 or val < 0: # avoid a FutureWarning - use = long(val) - else: - use = hex(val) - else: - use = repr(val) - # Make sure the repr of the value is valid python syntax - # still could cause an error on import if it contains a module or type name - # not available in the global namespace - try: + + use = repr(val) + # Make sure the repr of the value is valid python syntax + # still could cause an error on import if it contains a module or type name + # not available in the global namespace + try: compile(use, '<makepy>', 'eval') - except SyntaxError: + except SyntaxError: # At least add the repr as a string, so it can be investigated further # Sanitize it, in case the repr contains its own quotes. (??? line breaks too ???) use = use.replace('"',"'") diff -r 07ce8a09c2ac -r f7dd8d279929 com/win32com/test/pippo_server.py --- a/com/win32com/test/pippo_server.py Wed Apr 10 23:03:24 2013 -0400 +++ b/com/win32com/test/pippo_server.py Sun Apr 14 01:00:24 2013 -0400 @@ -8,11 +8,6 @@ import winerror from win32com.server.util import wrap -try: - __file__ # 2.3 only for __main__ -except NameError: - __file__ = sys.argv[0] - class CPippo: # # COM declarations diff -r 07ce8a09c2ac -r f7dd8d279929 win32/Demos/OpenEncryptedFileRaw.py --- a/win32/Demos/OpenEncryptedFileRaw.py Wed Apr 10 23:03:24 2013 -0400 +++ b/win32/Demos/OpenEncryptedFileRaw.py Sun Apr 14 01:00:24 2013 -0400 @@ -6,7 +6,7 @@ ## print fnamein, fnameout, buflen f.write(input_buffer) ## python 2.3 throws an error if return value is a plain int - return long(winerror.ERROR_SUCCESS) + return winerror.ERROR_SUCCESS def WriteCallback(output_buffer, data, buflen): fnamebackup, fnameout, f = data diff -r 07ce8a09c2ac -r f7dd8d279929 win32/Demos/win32rcparser_demo.py --- a/win32/Demos/win32rcparser_demo.py Wed Apr 10 23:03:24 2013 -0400 +++ b/win32/Demos/win32rcparser_demo.py Sun Apr 14 01:00:24 2013 -0400 @@ -7,12 +7,6 @@ import commctrl import sys, os -# We use the .rc file in our 'test' directory. -try: - __file__ -except NameError: # pre 2.3 - __file__ = sys.argv[0] - this_dir = os.path.abspath(os.path.dirname(__file__)) g_rcname = os.path.abspath( os.path.join( this_dir, "..", "test", "win32rcparser", "test.rc")) diff -r 07ce8a09c2ac -r f7dd8d279929 win32/src/win32apimodule.cpp --- a/win32/src/win32apimodule.cpp Wed Apr 10 23:03:24 2013 -0400 +++ b/win32/src/win32apimodule.cpp Sun Apr 14 01:00:24 2013 -0400 @@ -3546,6 +3546,25 @@ } } return true; + + case REG_QWORD: + *retDataSize=sizeof(ULONGLONG); + *retDataBuf = (BYTE *)PyMem_MALLOC(*retDataSize); + if (*retDataBuf==NULL){ + PyErr_NoMemory(); + return false; + } + if (value==Py_None){ + *(ULONGLONG *)*retDataBuf=0; + return true; + } + * (ULONGLONG *)*retDataBuf=PyLong_AsUnsignedLongLong(value); + if (* (ULONGLONG *)*retDataBuf == -1 && PyErr_Occurred()){ + PyMem_Free(*retDataBuf); + *retDataBuf=NULL; + return false; + } + return true; case REG_SZ: case REG_EXPAND_SZ:{ *retDataBuf=NULL; @@ -3592,9 +3611,15 @@ switch (typ) { case REG_DWORD: if (retDataSize==0) - obData = Py_BuildValue("i", 0); + obData = PyInt_FromLong(0); + else // ??? Should be returned as unsigned ??? + obData = PyInt_FromLong(*(int *)retDataBuf); + break; + case REG_QWORD: + if (retDataSize==0) + obData = PyInt_FromLong(0); else - obData = Py_BuildValue("i", *(int *)retDataBuf); + obData = PyLong_FromUnsignedLongLong(*(ULONGLONG *)retDataBuf); break; case REG_SZ: case REG_EXPAND_SZ:{ @@ -4299,6 +4324,8 @@ // @flag REG_BINARY|Binary data in any form. // @flag REG_DWORD|A 32-bit number. // @flag REG_DWORD_LITTLE_ENDIAN|A 32-bit number in little-endian format. This is equivalent to REG_DWORD.<nl>In little-endian format, a multi-byte value is stored in memory from the lowest byte (the little end) to the highest byte. For example, the value 0x12345678 is stored as (0x78 0x56 0x34 0x12) in little-endian format. + // @flag REG_QWORD|A 64-bit number. + // @flag REG_QWORD_LITTLE_ENDIAN|A 64-bit number in little-endian format. This is equivalent to REG_QWORD.<nl>In little-endian format, a multi-byte value is stored in memory from the lowest byte (the little end) to the highest byte. For example, the value 0x12345678 is stored as (0x78 0x56 0x34 0x12) in little-endian format. // Windows NT and Windows 95 are designed to run on little-endian computer architectures. A user may connect to computers that have big-endian architectures, such as some UNIX systems. // @flag REG_DWORD_BIG_ENDIAN|A 32-bit number in big-endian format. // In big-endian format, a multi-byte value is stored in memory from the highest byte (the big end) to the lowest byte. For example, the value 0x12345678 is stored as (0x12 0x34 0x56 0x78) in big-endian format. diff -r 07ce8a09c2ac -r f7dd8d279929 win32/test/test_win32api.py --- a/win32/test/test_win32api.py Wed Apr 10 23:03:24 2013 -0400 +++ b/win32/test/test_win32api.py Sun Apr 14 01:00:24 2013 -0400 @@ -71,6 +71,7 @@ ('REG_MULTI_SZ', win32con.REG_MULTI_SZ, ['string 1','string 2','string 3','string 4']), ('REG_MULTI_SZ_empty', win32con.REG_MULTI_SZ, []), ('REG_DWORD', win32con.REG_DWORD, 666), + ('REG_QWORD', win32con.REG_QWORD, 2**33), ('REG_BINARY', win32con.REG_BINARY, str2bytes('\x00\x01\x02\x03\x04\x05\x06\x07\x08\x01\x00')), ) diff -r 07ce8a09c2ac -r f7dd8d279929 win32/test/test_win32file.py --- a/win32/test/test_win32file.py Wed Apr 10 23:03:24 2013 -0400 +++ b/win32/test/test_win32file.py Sun Apr 14 01:00:24 2013 -0400 @@ -37,10 +37,7 @@ class TestSimpleOps(unittest.TestCase): def testSimpleFiles(self): - try: - fd, filename = tempfile.mkstemp() - except AttributeError: - self.fail("This test requires Python 2.3 or later") + fd, filename = tempfile.mkstemp() os.close(fd) os.unlink(filename) handle = win32file.CreateFile(filename, win32file.GENERIC_WRITE, 0, None, win32con.CREATE_NEW, 0, None) @@ -720,11 +717,7 @@ class TestTransmit(unittest.TestCase): def test_transmit(self): import binascii - try: - bytes = os.urandom(1024*1024) - except AttributeError: - # must be py2.3... - bytes = ''.join([chr(random.randint(0,255)) for _ in range(5)]) + bytes = os.urandom(1024*1024) val = binascii.hexlify(bytes) val_length = len(val) f = tempfile.TemporaryFile() diff -r 07ce8a09c2ac -r f7dd8d279929 win32/test/testall.py --- a/win32/test/testall.py Wed Apr 10 23:03:24 2013 -0400 +++ b/win32/test/testall.py Sun Apr 14 01:00:24 2013 -0400 @@ -73,20 +73,13 @@ def __init__(self, argv): self.argv = argv def __call__(self): - try: - import subprocess - p = subprocess.Popen(self.argv, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - output, _ = p.communicate() - rc = p.returncode - except ImportError: - # py2.3? - fin, fout, ferr = os.popen3(" ".join(self.argv)) - fin.close() - output = fout.read() + ferr.read() - fout.close() - rc = ferr.close() + import subprocess + p = subprocess.Popen(self.argv, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + output, _ = p.communicate() + rc = p.returncode + if rc: base = os.path.basename(self.argv[1]) # See if we can detect and reconstruct an exception in the output. |