Mercurial > ~astiob > upreckon > hgweb
comparison win32.py @ 81:24752db487c5
Fixed errors in the win32 module
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Wed, 16 Feb 2011 15:30:57 +0000 |
parents | 809b77302b21 |
children | 06356af50bf9 |
comparison
equal
deleted
inserted
replaced
80:809b77302b21 | 81:24752db487c5 |
---|---|
2 | 2 |
3 from __future__ import division, with_statement | 3 from __future__ import division, with_statement |
4 | 4 |
5 try: | 5 try: |
6 from compat import * | 6 from compat import * |
7 from testcases import (TimeLimitExceeded, MemoryLimitExceeded, | |
8 CanceledByUser, CannotStartTestee) | |
7 except ImportError: | 9 except ImportError: |
8 import __main__ | 10 import __main__ |
9 __main__.import_error(sys.exc_info()[1]) | 11 __main__.import_error(sys.exc_info()[1]) |
10 | 12 |
11 from __main__ import clock | 13 from __main__ import clock |
85 proc = HANDLE(int(GetCurrentProcess())) | 87 proc = HANDLE(int(GetCurrentProcess())) |
86 handle = DuplicateHandle(proc, handle, proc, 0, flags & 1, 2) | 88 handle = DuplicateHandle(proc, handle, proc, 0, flags & 1, 2) |
87 self.handle = handle.Detach() | 89 self.handle = handle.Detach() |
88 else: | 90 else: |
89 raise TypeError("Handle() argument must be a handle, not '%s'" % | 91 raise TypeError("Handle() argument must be a handle, not '%s'" % |
90 type(name).__name__) | 92 type(handle).__name__) |
91 | 93 |
92 def __int__(self): | 94 def __int__(self): |
93 return int(self.handle) | 95 return int(self.handle) |
94 | 96 |
95 def Detach(self): | 97 def Detach(self): |
113 | 115 |
114 try: | 116 try: |
115 unicode | 117 unicode |
116 except NameError: | 118 except NameError: |
117 LPCTSTR = LPCWSTR | 119 LPCTSTR = LPCWSTR |
118 unisuffix = 'W' | 120 UNISUFFIX = 'W' |
119 else: | 121 else: |
120 LPCTSTR = LPCSTR | 122 LPCTSTR = LPCSTR |
121 unisuffix = 'A' | 123 UNISUFFIX = 'A' |
122 | 124 |
123 | 125 |
124 prototype = WINFUNCTYPE(BOOL, Handle, | 126 prototype = WINFUNCTYPE(BOOL, Handle, |
125 LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME) | 127 LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME) |
126 flags = ((1, 'process'), | 128 flags = ((1, 'process'), |
242 | 244 |
243 | 245 |
244 prototype = WINFUNCTYPE(HANDLE, c_void_p, LPCTSTR) | 246 prototype = WINFUNCTYPE(HANDLE, c_void_p, LPCTSTR) |
245 flags = (5, 'attributes'), (1, 'name') | 247 flags = (5, 'attributes'), (1, 'name') |
246 try: | 248 try: |
247 CreateJobObject = prototype(('CreateJobObject'+unisuffix, windll.kernel32), | 249 CreateJobObject = prototype(('CreateJobObject'+UNISUFFIX, windll.kernel32), |
248 flags) | 250 flags) |
249 except AttributeError: | 251 except AttributeError: |
250 # Available on 2000 and up, NT line only | 252 # Available on 2000 and up, NT line only |
251 CreateJobObject = lambda name: None | 253 CreateJobObject = lambda name: None |
252 else: | 254 else: |
398 TerminateProcess.errcheck = errcheck | 400 TerminateProcess.errcheck = errcheck |
399 | 401 |
400 | 402 |
401 # Do not show error messages due to errors in the program being tested | 403 # Do not show error messages due to errors in the program being tested |
402 try: | 404 try: |
403 errmode = ctypes.windll.kernel32.GetErrorMode() | 405 errmode = windll.kernel32.GetErrorMode() |
404 except AttributeError: | 406 except AttributeError: |
405 # GetErrorMode is available on Vista/2008 and up | 407 # GetErrorMode is available on Vista/2008 and up |
406 errmode = ctypes.windll.kernel32.SetErrorMode(0) | 408 errmode = windll.kernel32.SetErrorMode(0) |
407 ctypes.windll.kernel32.SetErrorMode(errmode | 0x8003) | 409 windll.kernel32.SetErrorMode(errmode | 0x8003) |
408 | 410 |
409 stdin = GetStdHandle(STD_INPUT_HANDLE) | 411 stdin = GetStdHandle(STD_INPUT_HANDLE) |
410 try: | 412 try: |
411 SetConsoleMode(stdin, ENABLE_PROCESSED_INPUT) | 413 SetConsoleMode(stdin, ENABLE_PROCESSED_INPUT) |
412 except WindowsError: | 414 except WindowsError: |