FS#53045 - QPixmap in python2-pyqt5 appears broken.

Attached to Project: Arch Linux
Opened by Eric Soroos (wiredfool) - Wednesday, 22 February 2017, 10:37 GMT
Last edited by Antonio Rojas (arojas) - Wednesday, 22 February 2017, 15:24 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To No-one
Architecture x86_64
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

On Arch, calling QPixmap.fromImage(QImage) fails, (as well as other similar methods, like convertFromImage).

This succeeds on Ubuntu Xenial 16.04, so I'm suspecting that it's a packaging issue somewhere.


Additional info:
* pacman -Q python2-pyqt5
python2-pyqt5 5.8-1
* Pillow: https://github.com/python-pillow/Pillow/commit/9b82bdbb1026346b6788ebaa54b678b112f81ecb

Steps to reproduce:

With this dockerfile/repo: https://github.com/python-pillow/docker-images/blob/master/arch/Dockerfile

Install pillow @ this commit > https://github.com/python-pillow/Pillow/commit/9b82bdbb1026346b6788ebaa54b678b112f81ecb

(subsequent commits skip the failing test on Arch)

from Pillow directory:
python2 test-installed.py Tests/test_image_toqpixmap.py
This task depends upon

Closed by  Antonio Rojas (arojas)
Wednesday, 22 February 2017, 15:24 GMT
Reason for closing:  Upstream
Comment by Antonio Rojas (arojas) - Wednesday, 22 February 2017, 11:08 GMT
Works fine on an up-to-date Arch installation

> git clone https://github.com/python-pillow/Pillow
...
> cd Pillow
> git checkout 9b82bdbb1026346b6788ebaa54b678b112f81ecb
Note: checking out '9b82bdbb1026346b6788ebaa54b678b112f81ecb'.
HEAD is now at 9b82bdbb... fix ToQimage tests for QT5
> python Tests/test_image_toqpixmap.py
QSettings::value: Empty key passed
QSettings::value: Empty key passed
/usr/lib/python3.6/site-packages/PIL/Image.py:844: ResourceWarning: unclosed file <_io.BufferedReader name='Tests/images/hopper.ppm'>
self.load()
.
----------------------------------------------------------------------
Ran 1 test in 0.071s

OK
Comment by Antonio Rojas (arojas) - Wednesday, 22 February 2017, 11:10 GMT
Also with python2

> python2 Tests/test_image_toqpixmap.py
QSettings::value: Empty key passed
QSettings::value: Empty key passed
.
----------------------------------------------------------------------
Ran 1 test in 0.454s

OK

Please post the actual errors
Comment by Eric Soroos (wiredfool) - Wednesday, 22 February 2017, 11:23 GMT
I just ran this on a freshly refreshed docker image:

(vpy) [pillow@b5aa74789d15 Pillow]$ xvfb-run -a python2 Tests/test_image_toqpixmap.py
F=== orphaned temp file: /tmp/tempmkbp64_1.png

======================================================================
FAIL: TestToQPixmap.test_sanity
----------------------------------------------------------------------
Traceback (most recent call last):
File "Tests/test_image_toqpixmap.py", line 19, in test_sanity
self.assertFalse(data.isNull())
AssertionError: True is not false

----------------------------------------------------------------------
Ran 1 test in 0.032s

FAILED (failures=1)

#(and without xvfb, I don't have an X connection)
(vpy) [pillow@b5aa74789d15 Pillow]$ python2 Tests/test_image_toqpixmap.py
QXcbConnection: Could not connect to display
Aborted (core dumped)
(vpy) [pillow@b5aa74789d15 Pillow]$


# and in Python3:

(vpy3) [pillow@b5aa74789d15 Pillow]$ xvfb-run -a python Tests/test_image_toqpixmap.py
/vpy3/lib/python3.6/site-packages/Pillow-4.1.0.dev0-py3.6-linux-x86_64.egg/PIL/Image.py:844: ResourceWarning: unclosed file <_io.BufferedReader name='Tests/images/hopper.ppm'>
F
======================================================================
FAIL: TestToQPixmap.test_sanity
----------------------------------------------------------------------
Traceback (most recent call last):
File "Tests/test_image_toqpixmap.py", line 19, in test_sanity
self.assertFalse(data.isNull())
AssertionError: True is not false

----------------------------------------------------------------------
Ran 1 test in 0.123s

FAILED (failures=1)
Comment by Antonio Rojas (arojas) - Wednesday, 22 February 2017, 12:18 GMT
So, QPixmap::fromImage fails if there is no display available. Given that Xenial ships Qt 5.5, this is quite more likely to be a regression in Qt rather than a packaging problem.
Comment by Antonio Rojas (arojas) - Wednesday, 22 February 2017, 13:18 GMT
More precisely: it's a regression in Qt 5.7, works in Qt 5.6. Please report upstream.
Comment by Eric Soroos (wiredfool) - Wednesday, 22 February 2017, 13:21 GMT
So, you think it's an interaction with xvfb vs a real x session?
Comment by Antonio Rojas (arojas) - Wednesday, 22 February 2017, 14:16 GMT
Yes, I can reproduce the issue by running the test via SSH on the same machine, so it's the X session that makes the difference
Comment by Antonio Rojas (arojas) - Wednesday, 22 February 2017, 14:37 GMT
As a workaround you can explicitely set QT_QPA_PLATFORM to 'offscreen' (which is a good idea in any case if you plan to run the tests on a displayless setup)
Comment by Eric Soroos (wiredfool) - Wednesday, 22 February 2017, 15:14 GMT
Ok, Thanks, that does it here as well.

(vpy) [pillow@85a03a27d5eb Pillow]$ xvfb-run -a ./test-installed.py Tests/test_image_toqpixmap.py
F
======================================================================
FAIL: TestToQPixmap.test_sanity
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Pillow/Tests/test_image_toqpixmap.py", line 19, in test_sanity
self.assertFalse(data.isNull())
AssertionError: True is not false

----------------------------------------------------------------------
Ran 1 test in 0.195s

FAILED (failures=1)
(vpy) [pillow@85a03a27d5eb Pillow]$ QT_QPA_PLATFORM=offscreen xvfb-run -a ./test-installed.py Tests/test_image_toqpixmap.py
.
----------------------------------------------------------------------
Ran 1 test in 0.186s

OK

Loading...