aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/doc/feature-why.rst
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2021-10-26 17:38:46 +0200
committerChristian Tismer <tismer@stackless.com>2021-10-28 16:02:19 +0200
commitbee4cd31d60f3b35a37a2eb98fdfc60ba76cfe1c (patch)
tree865360d7c052a6afe294d0e38252f0566a41420c /sources/pyside6/doc/feature-why.rst
parent9548ddd822b839ed0dfea27b26c74ad1c87746fd (diff)
__feature__: handle properties with function overloads
This is the implementation, see the conclusion of the issue. [ChangeLog][PySide6] When a property would override an existing function with multiple arity or parameters, append an underscore to the property name. REMARK: The current implementation is very correct. It uses introspection via the signature module. But that adds a constant overhead to the true_property feature. Actually, there are only 2 known cases where this overlap happens. It might be considered to simplify things by checking the string names of these two functions? Fixes: PYSIDE-1670 Pick-to: 6.2 Change-Id: I14927995698726957ba8c515dddf5e37c21910ce Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside6/doc/feature-why.rst')
-rw-r--r--sources/pyside6/doc/feature-why.rst30
1 files changed, 30 insertions, 0 deletions
diff --git a/sources/pyside6/doc/feature-why.rst b/sources/pyside6/doc/feature-why.rst
index a2f3e146b..a795e640c 100644
--- a/sources/pyside6/doc/feature-why.rst
+++ b/sources/pyside6/doc/feature-why.rst
@@ -220,6 +220,36 @@ the Qt documentation, it would be easier to add all properties that
should be properties and are obviously missing.
+Name Clashes and Solution
+-------------------------
+
+There are some rare cases where a property already exists as a function,
+either with multiple signatures or having parameters.
+This is not very nice in C++ as well, but for Python this is forbidden.
+Example:
+
+.. code-block:: python
+
+ >>> from PySide6 import *
+ >>> import pprint
+ >>> pprint.pprint(QtCore.QTimer.singleShot.__signature__)
+ [<Signature (arg__1: int, arg__2: Callable) -> None>,
+ <Signature (msec: int, receiver: PySide6.QtCore.QObject, member: bytes) -> None>,
+ <Signature (msec: int, timerType: PySide6.QtCore.Qt.TimerType,
+ receiver: PySide6.QtCore.QObject, member: bytes) -> None>]
+
+When creating this property, we respect the existing function and use a slightly
+different name for the property by appending an underscore.
+
+.. code-block:: python
+
+ >>> from __feature__ import true_property
+ >>> QtCore.QTimer.singleShot_
+ <property object at 0x118e5f8b0>
+
+We hope that these clashes can be removed in future Qt versions.
+
+
The __feature__ import
======================