[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: pyqt on python 3.10 - implicit float to int conversion issue
From:       Erik Hvatum <ice.rikh () gmail ! com>
Date:       2022-06-13 16:28:03
Message-ID: CAJOi7yvT6rw7a=92u5AtgtTVDVAZPM67s1OZnMp55F0FKYpi9Q () mail ! gmail ! com
[Download RAW message or body]

Thank you for this link <https://bugs.python.org/issue36048>. I had
wondered why lots of production code using PyQt was breaking upon updating
old Linux installations, but I simply had no time to look into it and froze
Python package versions, thinking it's the usual stuff with Guido van
Rossum doing *things.*

The PySide6 behavior described by Mark Dickinson in your link seems ideal,
to me. Here's my vote for making PyQt adopt the same behavior.

It is appropriate for an interface to a C++ library, because C++ does and
always will do implicit float / int conversion, except when explicitly
forbidden by use of asserts with the type_traits library, overloads, etc.

Thanks,
Erik

On Mon, Jun 13, 2022 at 10:57 AM meta <0x0meta@gmail.com> wrote:

> Hello,
>
> When using PyQt with previous versions of Python, a float can be passed
> where an int is expected e.g. QColor(0, 0, 0, 255 * some_float).
>
> With 3.10 however, the same code gives the following error:
> ```
> TypeError: arguments did not match any overloaded call:
>   QColor(Qt.GlobalColor): argument 1 has unexpected type 'int'
>   QColor(int): too many arguments
>   QColor(QRgba64): argument 1 has unexpected type 'int'
>   QColor(Any): too many arguments
>   QColor(): too many arguments
>   QColor(int, int, int, alpha: int = 255): argument 4 has unexpected type
> 'float'
>   QColor(str): argument 1 has unexpected type 'int'
>   QColor(Union[QColor, Qt.GlobalColor, QGradient]): argument 1 has
> unexpected type 'int'
> ```
>
> Specifically `QColor(int, int, int, alpha: int = 255): argument 4 has
> unexpected type 'float'`.
>
> I believe this is related to the following deprecation in 3.8 which was
> solidified in 3.10: https://bugs.python.org/issue36048
>
> Cheers
>

[Attachment #3 (text/html)]

<div dir="ltr"><div>Thank you for <a href="https://bugs.python.org/issue36048">this \
link</a>. I had wondered why lots of production code using PyQt was breaking upon \
updating old Linux installations, but I simply had no time to look into it and froze \
Python package versions, thinking it&#39;s the usual stuff with Guido van Rossum \
doing <i>things.</i></div><div><br></div><div>The PySide6 behavior described by  Mark \
Dickinson in your link  seems ideal, to me. Here&#39;s my vote for making PyQt adopt \
the same behavior.  </div><div><br></div><div>It is appropriate for an interface to a \
C++ library, because C++ does and always will do implicit float / int conversion, \
except when explicitly forbidden by use of asserts with the type_traits library, \
overloads, etc.</div><div><br></div><div>Thanks,</div><div>Erik</div><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 13, 2022 at 10:57 \
AM meta &lt;<a href="mailto:0x0meta@gmail.com">0x0meta@gmail.com</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div \
dir="ltr">Hello,<br><br>When using PyQt with previous versions of Python, a float can \
be passed where an int is expected e.g. QColor(0, 0, 0, 255 * \
some_float).<br><br>With 3.10 however, the same code gives the following \
error:<br>```<br>TypeError: arguments did not match any overloaded call:<br>   \
QColor(Qt.GlobalColor): argument 1 has unexpected type &#39;int&#39;<br>   \
QColor(int): too many arguments<br>   QColor(QRgba64): argument 1 has unexpected type \
&#39;int&#39;<br>   QColor(Any): too many arguments<br>   QColor(): too many \
arguments<br>   QColor(int, int, int, alpha: int = 255): argument 4 has unexpected \
type &#39;float&#39;<br>   QColor(str): argument 1 has unexpected type \
&#39;int&#39;<br>   QColor(Union[QColor, Qt.GlobalColor, QGradient]): argument 1 has \
unexpected type &#39;int&#39;<br>```<br><br>Specifically `QColor(int, int, int, \
alpha: int = 255): argument 4 has unexpected type &#39;float&#39;`.<br><br>I believe \
this is related to the following deprecation in 3.8 which was solidified in 3.10:  <a \
href="https://bugs.python.org/issue36048" \
target="_blank">https://bugs.python.org/issue36048</a>  <br><br>Cheers<br></div> \
</blockquote></div></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic