def test_COMError(self): from _ctypes import COMError if support.HAVE_DOCSTRINGS: self.assertEqual(COMError.__doc__, "Raised when a COM method call failed.") ex = COMError(-1, "text", ("details",)) self.assertEqual(ex.hresult, -1) self.assertEqual(ex.text, "text") self.assertEqual(ex.details, ("details",))
def test_COMError(self): import _ctypes from _ctypes import COMError assert COMError.__doc__ == "Raised when a COM method call failed." ex = COMError(-1, "text", ("details", )) assert ex.hresult == -1 assert ex.text == "text" assert ex.details == ("details", ) assert (ex.hresult, ex.text, ex.details) == ex[:]
def test_COMError(self): from _ctypes import COMError self.assertEqual(COMError.__doc__, "Raised when a COM method call failed.") ex = COMError(-1, "text", ("details", )) self.assertEqual(ex.hresult, -1) self.assertEqual(ex.text, "text") self.assertEqual(ex.details, ("details", )) self.assertEqual((ex.hresult, ex.text, ex.details), ex[:])
def get_com_error(errcode, riid, pIunk): "Win32 specific: build a COM Error exception" # XXX need C support code from _ctypes import COMError return COMError(errcode, None, None)
if actual != required: raise ImportError("Wrong version") if not hasattr(sys, "frozen"): g = sys._getframe(1).f_globals mod_path = g.get("__file__") tlb_path = g.get("typelib_path") try: mod_mtime = os.stat(mod_path).st_mtime tlib_mtime = os.stat(tlb_path).st_mtime except (OSError, TypeError): return if mod_mtime < tlib_mtime: raise ImportError("Typelib newer than module") try: COMError() except TypeError: pass else: # Python 2.5 and 2.5.1 have a bug in the COMError implementation: # The type has no __init__ method, and no hresult, text, and # details instance vars. Work around this bug by monkeypatching # COMError. def monkeypatch_COMError(): def __init__(self, hresult, text, details): self.hresult = hresult self.text = text self.details = details super(COMError, self).__init__(hresult, text, details) COMError.__init__ = __init__ monkeypatch_COMError()