diff --git a/docs/source/com_interfaces.rst b/docs/source/com_interfaces.rst index af4907c9..056b0a8a 100644 --- a/docs/source/com_interfaces.rst +++ b/docs/source/com_interfaces.rst @@ -92,8 +92,10 @@ The ``IUnknown`` as a Python class if ``Release`` is called at the aforementioned timing, it may raise an ``OSError``. - .. sourcecode:: pycon + .. doctest:: + >>> import contextlib + >>> import io >>> from comtypes.client import CreateObject, GetModule >>> GetModule('UIAutomationCore.dll') # doctest: +ELLIPSIS @@ -103,7 +105,11 @@ The ``IUnknown`` as a Python class >>> iuia.Release() 0 - >>> del iuia # doctest: +ELLIPSIS + >>> stderr = io.StringIO() + >>> with contextlib.redirect_stderr(stderr): + ... del iuia + ... + >>> print(stderr.getvalue()[:-1]) # doctest: +ELLIPSIS Exception ignored in: Traceback (most recent call last): ...