comtypes icon indicating copy to clipboard operation
comtypes copied to clipboard

Windows fatal exception: access violation

Open czhhua28 opened this issue 5 years ago • 5 comments

image This is my script.

image This is the result.

I just wonder how that fatal exception occurs and how we can fix it.

czhhua28 avatar Mar 11 '20 01:03 czhhua28

I have a pretty similar problem with using pytest. I think it has nothing to do with pywinauto.

================================================== warnings summary ===================================================
test/*****.py::test_open_dialog
  D:\U****\Python38\site-packages\win32\lib\pywintypes.py:2: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    import imp, sys, os

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=============================================== short test summary info ===============================================
FAILED test/test_****.py::test_open_dialog - NameError: name '****' is not defined
============================================ 1 failed, 1 warning in 0.34s =============================================
Windows fatal exception: code 0x80010108

Thread 0x00002418 (most recent call first):
  File "D:\Users\*****\AppData(Roaming)\Python\Python38\site-packages\comtypes\__init__.py", line 185 in shutdown
Windows fatal exception: code 0x80010108

Thread 0x00002418 (most recent call first):
  File "D:\Users\*****\AppData(Roaming)\Python\Python38\site-packages\comtypes\__init__.py", line 185 in shutdown

pytest version 5.4.0 and 5.4.1 comtypes Version: 1.1.7

michel117 avatar Mar 17 '20 08:03 michel117

I have a similar issue with a different COM library where pytest ends up printing out a

Windows fatal exception: access violation

The interesting thing about my issue is that it only happens when I run

C:\%userprofile%\projects\pycygnet\py.test

Current thread 0x0000cfec (most recent call first):
  File "C:\%userprofile%\anaconda3\envs\pycygnet_dev\lib\site-packages\comtypes\__init__.py", line 1354 in CoGetClassObject
  File "C:\%userprofile%\anaconda3\envs\pycygnet_dev\lib\site-packages\comtypes\client\__init__.py", line 203 in GetClassObject
  File "C:\%userprofile%\Projects\PyCygNet\src\pycygnet\cx_fac\__init__", line 6 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
...
  File "C:\%userprofile%\anaconda3\envs\pycygnet_dev\Scripts\py.test-script.py", line 10 in <module>
Windows fatal exception: access violation

if I specify the test a little more I get the normal output from pytest

C:\%userprofile%\projects\pycygnet\py.test tests\test_cx_fac

============================================================================================== test session starts ============================================================================================== platform win32 -- Python 3.7.4, pytest-5.2.1, py-1.8.1, pluggy-0.13.1
rootdir: C:\%userprofile%\Projects\PyCygNet
collected 19 items

tests\test_fac\test_cx_fac.py ...........sss....s

RoyLarson avatar May 14 '20 15:05 RoyLarson

I have a similar issue. execute result are as follows:

(auto-client) D:\Projects\Python\Client_UI>python test_client.py
..                                                                                                               [100%]
2 passed in 3.21s
Windows fatal exception: code 0x80010108

Thread 0x00003460 (most recent call first):
  File "C:\Anaconda3\envs\auto-client\lib\site-packages\comtypes\__init__.py", line 185 in shutdown
Windows fatal exception: code 0x80010108

Thread 0x00003460 (most recent call first):
  File "C:\Anaconda3\envs\auto-client\lib\site-packages\comtypes\__init__.py", line 185 in shutdown

(auto-client) D:\Projects\Python\Client_UI>

my test code :

import Client
import pytest
import faulthandler
faulthandler.disable()


class TestClient(object):

    def setup(self):
        print("======= [ Start ] =======")
        self.meetingpage = Client.MeetingsPage()

    def teardown(self):
        print("======= [ Stop ] =======")

    def test_a(self):
        self.meetingpage = Client.MeetingsPage()
        self.meetingpage.click_meetings_icon()
        meeting_id = '2126549589'
        meeting_cell = self.meetingpage.meeting_item(meeting_id)

    def test_b(self):
        print("------->test_b")


if __name__ == '__main__':
    pytest.main(["-q", "test_client.py"])

comtypes : 1.1.7 pytest: 5.4.2

iloeng avatar Jun 01 '20 08:06 iloeng

I'm Facing the same issue : pytest : 5.2.2 comtype: 1.1.10

bored002 avatar May 23 '21 11:05 bored002