Skip to content

PR: Add workaround for mode argument in QTextCursor.movePosition (Pyside2)#341

Merged
dalthviz merged 1 commit intospyder-ide:masterfrom
procitec:pyside_qtextcursor
Apr 28, 2022
Merged

PR: Add workaround for mode argument in QTextCursor.movePosition (Pyside2)#341
dalthviz merged 1 commit intospyder-ide:masterfrom
procitec:pyside_qtextcursor

Conversation

@rear1019
Copy link
Copy Markdown
Contributor

See commit message/comment in code for details.

…on()

PySide2 does not accept the `mode` keyword argument in
QTextCursor.movePosition() even though it is a valid optional argument
as per C++ API. Fix this by monkeypatching.

Notes:

* The `mode` argument is called `arg__2` in PySide2 as per
  QTextCursor.movePosition.__doc__ and __signature__. Using `arg__2` as
  keyword argument works as intended, so does using a positional
  argument. Tested with PySide2 5.15.0, 5.15.2.1 and 5.15.3; older
  version, down to PySide 1, are probably affected as well [1].

* PySide2 5.15.0 and 5.15.2.1 silently ignore invalid keyword arguments,
  i.e. passing the `mode` keyword argument has no effect and doesn’t
  raise an exception. Older versions, down to PySide 1, are probably
  affected as well [1]. PySide2 5.15.3 raises an exception when `mode`or
  any other invalid keyword argument is passed.

[1] https://bugreports.qt.io/browse/PYSIDE-185
@ccordoba12 ccordoba12 changed the title pyside2: Add workaround for mode argument in QTextCursor.movePosition() PR: Add workaround for mode argument in QTextCursor.movePosition (Pyside2) Apr 28, 2022
@ccordoba12 ccordoba12 requested a review from dalthviz April 28, 2022 12:25
@ccordoba12 ccordoba12 added this to the v2.1.0 milestone Apr 28, 2022
Copy link
Copy Markdown
Member

@dalthviz dalthviz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rear1019 for helping with this! LGTM 👍

Also, maybe could be worthy to open an issue over PySide @ccordoba12 @rear1019 ? The only one I found related to this is closed: https://bugreports.qt.io/browse/PYSIDE-185

@dalthviz dalthviz merged commit aed5492 into spyder-ide:master Apr 28, 2022
@CAM-Gerlach
Copy link
Copy Markdown
Member

Also, maybe could be worthy to open an issue over PySide @ccordoba12 @rear1019 ? The only one I found related to this is closed: https://bugreports.qt.io/browse/PYSIDE-185

I'm not sure they're still accepting bug reports against PySide2 since they've stopped providing LTS for open source users, but it could potentially be patched in the PySide2 conda packages.

@rear1019
Copy link
Copy Markdown
Contributor Author

PySide6 is affected as well. At the very least, one gets an exception as with PySide2 >= 5.15.3

@ccordoba12
Copy link
Copy Markdown
Member

Please open a pull request to patch Pyside6 as well.

rear1019 added a commit to procitec/spyder that referenced this pull request Sep 22, 2022
* Arguments are called differently than they are in C++ interface
* PySide2 < 5.15.3 doesn’t raise an exception for unknown kwarg
* Also see [1] for a similar issue

[1] spyder-ide/qtpy#341
rear1019 added a commit to procitec/spyder that referenced this pull request Sep 23, 2022
* Arguments are called differently than they are in C++ interface
* PySide2 < 5.15.3 doesn’t raise an exception for unknown kwarg
* Also see [1] for a similar issue

[1] spyder-ide/qtpy#341
rear1019 added a commit to procitec/spyder that referenced this pull request Oct 4, 2022
* Arguments are called differently than they are in C++ interface
* PySide2 < 5.15.3 doesn’t raise an exception for unknown kwarg
* Also see [1] for a similar issue

[1] spyder-ide/qtpy#341
rear1019 added a commit to procitec/spyder that referenced this pull request Apr 3, 2023
The argument “[hv]Policy” is called “[hv]Data” in PySide2 and PySide2<5.15.3
doesn’t raise an exception for invalid keyword arguments (also see [1]).

[1] spyder-ide/qtpy#341
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants