Rocket Terminal Emulator

 View Only

 Automate Rocket BlueZone Mainframe Display with Python 3.8

Jump to Best Answer
Michael Quinn's profile image
Michael Quinn posted 07-11-2022 09:37
I recently upgraded my Python from 3.6 to 3.8 and now I am receiving an error when running my scripts. 
BlueZone version is BlueZone Mainframe Display v7.1.4.2796 (64-bit)
Python version is 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)]
My company limits what Python modules I can use. I was able to get the below code to work in Python 3.6
from comtypes.client import CreateObject

bzhao = CreateObject("BZWhll.WhllObj")
bzhao.WaitReady(10, 1)​
When I run the above code I now get the below error.
Traceback (most recent call last):
  File "C:\Program Files\Python38\lib\ctypes\", line 123, in WINFUNCTYPE
    return _win_functype_cache[(restype, argtypes, flags)]
KeyError: (<class 'ctypes.HRESULT'>, (<class 'comtypes.BSTR'>, <class 'comtypes.automation.tagVARIANT'>, <class 'comtypes.automation.tagVARIANT'>), 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/PL14714/Desktop/Mike/Python/connectToMainframe/", line 3, in <module>
    bzhao = CreateObject("BZWhll.WhllObj")
  File "C:\Users\PL14714\AppData\Roaming\Python\Python38\site-packages\comtypes\client\", line 250, in CreateObject
    return _manage(obj, clsid, interface=interface)
  File "C:\Users\PL14714\AppData\Roaming\Python\Python38\site-packages\comtypes\client\", line 188, in _manage
    obj = GetBestInterface(obj)
  File "C:\Users\PL14714\AppData\Roaming\Python\Python38\site-packages\comtypes\client\", line 110, in GetBestInterface
    mod = GetModule(tlib)
  File "C:\Users\PL14714\AppData\Roaming\Python\Python38\site-packages\comtypes\client\", line 159, in GetModule
    mod = _CreateWrapper(tlib, pathname)
  File "C:\Users\PL14714\AppData\Roaming\Python\Python38\site-packages\comtypes\client\", line 242, in _CreateWrapper
    mod = _my_import(fullname)
  File "C:\Users\PL14714\AppData\Roaming\Python\Python38\site-packages\comtypes\client\", line 26, in _my_import
    return __import__(fullname, globals(), locals(), ['DUMMY'])
  File "C:\Users\PL14714\AppData\Roaming\Python\Python38\site-packages\comtypes\gen\", line 1925, in <module>
    IAutPS._methods_ = [
  File "C:\Users\PL14714\AppData\Roaming\Python\Python38\site-packages\comtypes\", line 328, in __setattr__
  File "C:\Users\PL14714\AppData\Roaming\Python\Python38\site-packages\comtypes\", line 697, in _make_methods
    prototype = WINFUNCTYPE(restype, *argtypes)
  File "C:\Program Files\Python38\lib\ctypes\", line 125, in WINFUNCTYPE
    class WinFunctionType(_CFuncPtr):
TypeError: item 2 in _argtypes_ passes a union by value, which is unsupported.

Process finished with exit code 1
Limei Wu's profile image
ROCKETEER Limei Wu Best Answer
Hi Michael, your code works in my Python 3.8.10.  This seems a known Python bug in Python 2.7.6 and 3.8.1 and fixed in later versions (3.7.7+ or 3.8.2+). Please see