@@ -1707,12 +1707,6 @@ in :mod:`!ctypes`) which inherits from the private :class:`_CFuncPtr` class:
17071707 and raise an exception if the foreign function call failed.
17081708
17091709
1710- .. exception :: ArgumentError
1711-
1712- This exception is raised when a foreign function call cannot convert one of the
1713- passed arguments.
1714-
1715-
17161710.. audit-event :: ctypes.set_exception code foreign-functions
17171711
17181712 On Windows, when a foreign function call raises a system exception (for
@@ -1799,10 +1793,15 @@ different ways, depending on the type and number of the parameters in the call:
17991793 integer. *name * is name of the COM method. *iid * is an optional pointer to
18001794 the interface identifier which is used in extended error reporting.
18011795
1796+ If *iid * is not specified, an :exc: `OSError ` is raised if the COM method
1797+ call fails. If *iid * is specified, a :exc: `~ctypes.COMError ` is raised
1798+ instead.
1799+
18021800 COM methods use a special calling convention: They require a pointer to
18031801 the COM interface as first argument, in addition to those parameters that
18041802 are specified in the :attr: `!argtypes ` tuple.
18051803
1804+
18061805The optional *paramflags * parameter creates foreign function wrappers with much
18071806more functionality than the features described above.
18081807
@@ -2741,3 +2740,39 @@ Arrays and pointers
27412740
27422741 Returns the object to which to pointer points. Assigning to this
27432742 attribute changes the pointer to point to the assigned object.
2743+
2744+
2745+ .. _ctypes-exceptions :
2746+
2747+ Exceptions
2748+ ^^^^^^^^^^
2749+
2750+ .. exception :: ArgumentError
2751+
2752+ This exception is raised when a foreign function call cannot convert one of the
2753+ passed arguments.
2754+
2755+
2756+ .. exception :: COMError(hresult, text, details)
2757+
2758+ Windows only: This exception is raised when a COM method call failed.
2759+
2760+ .. attribute :: hresult
2761+
2762+ The integer value representing the error code.
2763+
2764+ .. attribute :: text
2765+
2766+ The error message.
2767+
2768+ .. attribute :: details
2769+
2770+ The 5-tuple ``(descr, source, helpfile, helpcontext, progid) ``.
2771+
2772+ *descr * is the textual description. *source * is the language-dependent
2773+ ``ProgID `` for the class or application that raised the error. *helpfile *
2774+ is the path of the help file. *helpcontext * is the help context
2775+ identifier. *progid * is the ``ProgID `` of the interface that defined the
2776+ error.
2777+
2778+ .. versionadded :: next
0 commit comments