[bug] QFontMetrics Regression in 5.13 on Python2

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug] QFontMetrics Regression in 5.13 on Python2

Chris Billington-2
The following example raises an exception on Python 2 with PyQt5 5.13. It does not raise an exception on Python 3 or on PyQt5 5.12.3.

from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import QFontMetrics
app = QApplication([])
QFontMetrics(app.font()).inFont(u'\u2605')

Traceback (most recent call last):
  File "292.py", line 4, in <module>
    QFontMetrics(app.font()).inFont(u'\u2605')
ValueError: string of length 1 expected

This causes tortoisehg to crash for example, as it contains the above QFontMetrics call. u'\u2605' looks like a string of length one to me, so this looks like perhaps confounding byte-length with codepoint-length.

regards,

Chris



_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: [bug] QFontMetrics Regression in 5.13 on Python2

Chris Billington-2
Investigating a bit more, I tried to diff PyQt5 5.12.3 and 5.13.0 and if I'm understanding correctly, the two source tarballs are identical, meaning the difference is just which version of Qt it is built with. This makes me think that the problem I'm seeing must be due to a change in Qt itself rather than PyQt, though I suspect the required solution would be in PyQt still, since the problem is only present on Python 2.

-Chris



On Mon, Jul 8, 2019 at 10:18 AM Chris Billington <[hidden email]> wrote:
The following example raises an exception on Python 2 with PyQt5 5.13. It does not raise an exception on Python 3 or on PyQt5 5.12.3.

from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import QFontMetrics
app = QApplication([])
QFontMetrics(app.font()).inFont(u'\u2605')

Traceback (most recent call last):
  File "292.py", line 4, in <module>
    QFontMetrics(app.font()).inFont(u'\u2605')
ValueError: string of length 1 expected

This causes tortoisehg to crash for example, as it contains the above QFontMetrics call. u'\u2605' looks like a string of length one to me, so this looks like perhaps confounding byte-length with codepoint-length.

regards,

Chris



_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: [bug] QFontMetrics Regression in 5.13 on Python2

Phil Thompson-5
In reply to this post by Chris Billington-2
On 08/07/2019 15:18, Chris Billington wrote:

> The following example raises an exception on Python 2 with PyQt5 5.13.
> It
> does not raise an exception on Python 3 or on PyQt5 5.12.3.
>
> from PyQt5.QtWidgets import QApplication
> from PyQt5.QtGui import QFontMetrics
> app = QApplication([])
> QFontMetrics(app.font()).inFont(u'\u2605')
>
> Traceback (most recent call last):
>   File "292.py", line 4, in <module>
>     QFontMetrics(app.font()).inFont(u'\u2605')
> ValueError: string of length 1 expected
>
> This causes tortoisehg to crash for example, as it contains the above
> QFontMetrics call. u'\u2605' looks like a string of length one to me,
> so
> this looks like perhaps confounding byte-length with codepoint-length.

This will be fixed in tonight's snapshot.

It's actually a bad regression (but only affects Python v2) so there
will be a v5.13.1 release soon.

Thanks,
Phil
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: [bug] QFontMetrics Regression in 5.13 on Python2

Chris Billington-2
Fantastic, thanks very much Phil.

-Chris

On Thu, Jul 11, 2019 at 9:35 AM Phil Thompson <[hidden email]> wrote:
On 08/07/2019 15:18, Chris Billington wrote:
> The following example raises an exception on Python 2 with PyQt5 5.13.
> It
> does not raise an exception on Python 3 or on PyQt5 5.12.3.
>
> from PyQt5.QtWidgets import QApplication
> from PyQt5.QtGui import QFontMetrics
> app = QApplication([])
> QFontMetrics(app.font()).inFont(u'\u2605')
>
> Traceback (most recent call last):
>   File "292.py", line 4, in <module>
>     QFontMetrics(app.font()).inFont(u'\u2605')
> ValueError: string of length 1 expected
>
> This causes tortoisehg to crash for example, as it contains the above
> QFontMetrics call. u'\u2605' looks like a string of length one to me,
> so
> this looks like perhaps confounding byte-length with codepoint-length.

This will be fixed in tonight's snapshot.

It's actually a bad regression (but only affects Python v2) so there
will be a v5.13.1 release soon.

Thanks,
Phil

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: [bug] QFontMetrics Regression in 5.13 on Python2

marco
In reply to this post by Phil Thompson-5
Hi, I am an Opensuse Tumbleweed user and I am in the very same situation as
described by Chris (TortoiseHg crash trying to open a repository).
My distro have PyQt5 5.13.0 (and python 2.7). I tried to downgrade to 5.12
but it doesn't help, so I am stuck.
When  a fix for this will be available? I searched a lot but I can't find a
newer version for this package.
In the Opensuse software repository the 5.13.0 is the latest version
available since July 16.
Please let me know about this

thank in advance,
Marco




--
Sent from: http://python.6.x6.nabble.com/PyQt-f1792048.html
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt