[PyQt] PyQt_qreal_double (Was: Re: PyQt5 5.7.1 Bug: debug build on Windows broken)

Dmitry Shachnev mitya57 at ubuntu.com
Thu Jan 19 11:47:36 GMT 2017


Hi all,

On Tue, Jan 17, 2017 at 06:33:31PM +0100, Hans-Peter Jansen wrote:
> > We now have this patch in Debian too (thanks Pete!).
>
> Hehe. Funnily, the fix_qreal_check.diff mentioned below in "openSUSE patches
> of PyQt" is yours. Thank you, Dmitry. The world "feels" small sometimes.
>
> You might want to comment on this, why Phil should consider your approach.

We no longer have this patch in Debian because we switched to qreal = double
on all architectures, however having this patch applied to mainstream PyQt
would still make sense in my opinion.

While qreal = double by default, it is still possible (and supported) to do
a custom Qt build with qreal = float. As far as I know, Sailfish still has
qreal = float, so it would be useful at least for them.

I would also update the patch because the sizeof-based check can be applied
always, not only for old Qt versions.

However there are some inconsistencies in PyQt code. It seems quite naturally
that PyQt_qreal_double tells that qreal *is* double. The code in qglobal.sip
seems to agree with that definition:

  %If (PyQt_qreal_double)
  typedef double qreal;
  %End
  %If (!PyQt_qreal_double)
  typedef float qreal;
  %End

However, the code in (unpatched) configure.py and qpygui_qvector.sip seems to
be using the opposite logic. Here is a fragment from qpygui_qvector.sip:

  %If (PyQt_qreal_double)

  %MappedType QVector<qreal>
          /TypeHintIn="Iterable[float]", TypeHintOut="List[float]",
          TypeHintValue="[]"/

I hope Phil can clarify what is correct and what is not.

A potential updated patch for configure.py that would agree with qglobal.sip
code is below (note the '==' instead of '!=' which was in the initial patch).
When applying this, the code in qpygui_qvector.sip should be either fixed or
dropped altogether.

To test the changes with qreal = float, qtbase should be configured with
'-qreal float' option.

--- a/configure.py
+++ b/configure.py
@@ -687,13 +687,8 @@ int main(int argc, char **argv)
     out << "PyQt_Desktop_OpenGL\\n";
 #endif
 
-#if QT_VERSION < 0x050200
-// This is the test used in qglobal.h in Qt prior to v5.2.  In v5.2 and later
-// qreal is always double.
-#if defined(QT_NO_FPU) || defined(Q_PROCESSOR_ARM) || defined(Q_OS_WINCE)
-    out << "PyQt_qreal_double\\n";
-#endif
-#endif
+    if (sizeof (qreal) == sizeof (double))
+        out << "PyQt_qreal_double\\n";
 
 #if defined(QT_NO_PROCESS)
     out << "PyQt_Process\\n";

--
Dmitry Shachnev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170119/13be2f50/attachment.sig>


More information about the PyQt mailing list