'PyQt5 on macOS no space after comma and period in text displayed in a widget

I have a weird issue that seems to happen on macOS (I have Big Sur 11.6.4), but not on Windows 10. Basically, in the text displayed in a QWidget with PyQt5 the spaces after commas and periods are not displayed (or very very small?).

Does anyone know if this is a bug or if I am doing something wrong? Here is a minimal example

from PyQt5.QtWidgets import QLabel, QWidget, QApplication

app = QApplication([])

label = QLabel()

text = 'This is a list: first, second, third, fourth, fifth. This is a sentence! And this is what?'
label.setText(text)

label.show()

app.exec_()

When I run this code on macOS I get the following window. As you can see there is no space after commas and periods, while the spaces are visible after exclamation marks and colons.

I made the text selectable, and if I copy and paste the text then the space is there, it's just a visualization issue.

QLabel macOS

I know that the bug was reported for Qt v5.15.1 and fixed for Qt v5.15.3 (see here), but I have PyQt v5.15.6 so maybe I am doing something wrong?



Solution 1:[1]

As pointed out by musicamante in the comments, PyQt versions do not match the Qt version. After checking the Qt version I have (with print(QtCore.QT_VERSION_STR) I found that I have 5.15.2 which still has this visualization bug.

It is fixed in Qt 5.15.3 so I will wait for the release of that version in PyQt.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Francesco