<div style="font-family: sans-serif; font-size: 14px;"><span>One of the users of my application came across a bug that looks to come from PyQt 6.10.0, where the QWidgetTextControl::inputMethodQuery returns a mine object wrapped in a struct that PyQt does not know about.</span><div><br></div><div><span>TypeError:</span></div><div><span>unable to convert a C++ 'MimeDataSelection' instance to a Python object</span></div><div><br></div><div><span>The object in question comes from here: <a target="_blank" rel="noreferrer nofollow noopener" href="https://github.com/qt/qtbase/blob/a0cee3e49d7d20c43955bc1fc2a6a9733c8e1a69/src/gui/text/qinputcontrol.cpp#L115">https://github.com/qt/qtbase/blob/a0cee3e49d7d20c43955bc1fc2a6a9733c8e1a69/src/gui/text/qinputcontrol.cpp#L115</a></span></div><div><br></div><div><span>The TypeError occurs, as far as I can tell, when processing the return value from here: <a target="_blank" rel="noreferrer nofollow noopener" href="https://github.com/qt/qtbase/blob/a0cee3e49d7d20c43955bc1fc2a6a9733c8e1a69/src/widgets/widgets/qwidgettextcontrol.cpp#L2193">https://github.com/qt/qtbase/blob/a0cee3e49d7d20c43955bc1fc2a6a9733c8e1a69/src/widgets/widgets/qwidgettextcontrol.cpp#L2193</a></span></div><div><br></div><div><span>The Python code that fails is a QPlainTextEdit with the following overload:</span></div><div><br></div><div><span>    def inputMethodQuery(self, query: Qt.InputMethodQuery) -> QRect | QVariant:</span></div><div><span>        """Adjust completion windows for CJK input methods to consider</span></div><div><span>        the viewport margins.</span></div><div><span>        """</span></div><div><span>        if query == QtImCursorRectangle:</span></div><div><span>            # See issues #2267 and #2517</span></div><div><span>            vM = self.viewportMargins()</span></div><div><span>            rect = self.cursorRect()</span></div><div><span>            rect.translate(vM.left(), vM.top())</span></div><div><span>            return rect</span></div><div><span>        return super().inputMethodQuery(query)</span></div><div><br></div><div><span>The failure happens on the last line, with the call to super().inputMethodQuery(query). It seems to happen when using Spotlight on MacOS according to my incoming bug report, but I don't have access to a Mac, so can't confirm.</span></div><div><br></div><span>I'm not very familiar with how PyQt extracts the objects to handle in the interface, but I suspect MimeDataSelection that lives entirely within the function in the first link is being missed here.</span><br></div><div style="font-family: sans-serif; font-size: 14px;"><br></div>
<div style="font-family: sans-serif; font-size: 14px;" class="protonmail_signature_block "><span style="font-family: sans-serif;">
    </span><div class="protonmail_signature_block-user "><div><b><span style="color: rgb(20, 83, 144);" class="colour">Veronica Berglyd Olsen</span></b><br></div></div><span style="font-family: sans-serif;">
    
            </span><div class="protonmail_signature_block-proton protonmail_signature_block-empty"><span style="font-family: sans-serif;">
        
            </span></div>
</div><span style="font-family: sans-serif;">
</span>