##// END OF EJS Templates
typing: disable a few errors when accessing Windows specific attributes...
Matt Harbison -
r47542:65f437c2 stable
parent child Browse files
Show More
@@ -152,8 +152,8 b' if pycompat.ispy3:'
152 152
153 153 if pycompat.iswindows:
154 154 # Work around Windows bugs.
155 stdout = platform.winstdout(stdout)
156 stderr = platform.winstdout(stderr)
155 stdout = platform.winstdout(stdout) # pytype: disable=module-attr
156 stderr = platform.winstdout(stderr) # pytype: disable=module-attr
157 157 if isatty(stdout):
158 158 # The standard library doesn't offer line-buffered binary streams.
159 159 stdout = make_line_buffered(stdout)
@@ -164,8 +164,8 b' else:'
164 164 stderr = sys.stderr
165 165 if pycompat.iswindows:
166 166 # Work around Windows bugs.
167 stdout = platform.winstdout(stdout)
168 stderr = platform.winstdout(stderr)
167 stdout = platform.winstdout(stdout) # pytype: disable=module-attr
168 stderr = platform.winstdout(stderr) # pytype: disable=module-attr
169 169 if isatty(stdout):
170 170 if pycompat.iswindows:
171 171 # The Windows C runtime library doesn't support line buffering.
@@ -20,10 +20,12 b' from . import ('
20 20 pycompat,
21 21 )
22 22
23 # pytype: disable=module-attr
23 24 _kernel32 = ctypes.windll.kernel32
24 25 _advapi32 = ctypes.windll.advapi32
25 26 _user32 = ctypes.windll.user32
26 27 _crypt32 = ctypes.windll.crypt32
28 # pytype: enable=module-attr
27 29
28 30 _BOOL = ctypes.c_long
29 31 _WORD = ctypes.c_ushort
@@ -311,7 +313,9 b' except AttributeError:'
311 313 _kernel32.GetCurrentProcessId.argtypes = []
312 314 _kernel32.GetCurrentProcessId.restype = _DWORD
313 315
316 # pytype: disable=module-attr
314 317 _SIGNAL_HANDLER = ctypes.WINFUNCTYPE(_BOOL, _DWORD)
318 # pytype: enable=module-attr
315 319 _kernel32.SetConsoleCtrlHandler.argtypes = [_SIGNAL_HANDLER, _BOOL]
316 320 _kernel32.SetConsoleCtrlHandler.restype = _BOOL
317 321
@@ -336,7 +340,9 b' except AttributeError:'
336 340 _user32.ShowWindow.argtypes = [_HANDLE, ctypes.c_int]
337 341 _user32.ShowWindow.restype = _BOOL
338 342
343 # pytype: disable=module-attr
339 344 _WNDENUMPROC = ctypes.WINFUNCTYPE(_BOOL, _HWND, _LPARAM)
345 # pytype: enable=module-attr
340 346 _user32.EnumWindows.argtypes = [_WNDENUMPROC, _LPARAM]
341 347 _user32.EnumWindows.restype = _BOOL
342 348
@@ -357,7 +363,7 b' def _raiseoserror(name):'
357 363 code = _kernel32.GetLastError()
358 364 if code > 0x7FFFFFFF:
359 365 code -= 2 ** 32
360 err = ctypes.WinError(code=code)
366 err = ctypes.WinError(code=code) # pytype: disable=module-attr
361 367 raise OSError(
362 368 err.errno, '%s: %s' % (encoding.strfromlocal(name), err.strerror)
363 369 )
@@ -466,7 +472,7 b' def samedevice(path1, path2):'
466 472
467 473
468 474 def peekpipe(pipe):
469 handle = msvcrt.get_osfhandle(pipe.fileno())
475 handle = msvcrt.get_osfhandle(pipe.fileno()) # pytype: disable=module-attr
470 476 avail = _DWORD()
471 477
472 478 if not _kernel32.PeekNamedPipe(
@@ -475,7 +481,7 b' def peekpipe(pipe):'
475 481 err = _kernel32.GetLastError()
476 482 if err == _ERROR_BROKEN_PIPE:
477 483 return 0
478 raise ctypes.WinError(err)
484 raise ctypes.WinError(err) # pytype: disable=module-attr
479 485
480 486 return avail.value
481 487
@@ -506,10 +512,12 b' def executablepath():'
506 512 size = 600
507 513 buf = ctypes.create_string_buffer(size + 1)
508 514 len = _kernel32.GetModuleFileNameA(None, ctypes.byref(buf), size)
515 # pytype: disable=module-attr
509 516 if len == 0:
510 517 raise ctypes.WinError() # Note: WinError is a function
511 518 elif len == size:
512 519 raise ctypes.WinError(_ERROR_INSUFFICIENT_BUFFER)
520 # pytype: enable=module-attr
513 521 return buf.value
514 522
515 523
@@ -528,7 +536,8 b' def getvolumename(path):'
528 536 buf = ctypes.create_string_buffer(size)
529 537
530 538 if not _kernel32.GetVolumePathNameA(realpath, ctypes.byref(buf), size):
531 raise ctypes.WinError() # Note: WinError is a function
539 # Note: WinError is a function
540 raise ctypes.WinError() # pytype: disable=module-attr
532 541
533 542 return buf.value
534 543
@@ -558,7 +567,8 b' def getfstype(path):'
558 567 if not _kernel32.GetVolumeInformationA(
559 568 volume, None, 0, None, None, None, ctypes.byref(name), size
560 569 ):
561 raise ctypes.WinError() # Note: WinError is a function
570 # Note: WinError is a function
571 raise ctypes.WinError() # pytype: disable=module-attr
562 572
563 573 return name.value
564 574
@@ -568,7 +578,7 b' def getuser():'
568 578 size = _DWORD(300)
569 579 buf = ctypes.create_string_buffer(size.value + 1)
570 580 if not _advapi32.GetUserNameA(ctypes.byref(buf), ctypes.byref(size)):
571 raise ctypes.WinError()
581 raise ctypes.WinError() # pytype: disable=module-attr
572 582 return buf.value
573 583
574 584
@@ -589,7 +599,7 b' def setsignalhandler():'
589 599 h = _SIGNAL_HANDLER(handler)
590 600 _signalhandler.append(h) # needed to prevent garbage collection
591 601 if not _kernel32.SetConsoleCtrlHandler(h, True):
592 raise ctypes.WinError()
602 raise ctypes.WinError() # pytype: disable=module-attr
593 603
594 604
595 605 def hidewindow():
@@ -686,7 +696,7 b' def spawndetached(args):'
686 696 ctypes.byref(pi),
687 697 )
688 698 if not res:
689 raise ctypes.WinError()
699 raise ctypes.WinError() # pytype: disable=module-attr
690 700
691 701 _kernel32.CloseHandle(pi.hProcess)
692 702 _kernel32.CloseHandle(pi.hThread)
General Comments 0
You need to be logged in to leave comments. Login now