QR code image does not generate after upgrade to Ubuntu 16.04

Bug #1573577 reported by emptythevoid on 2016-04-22
100
This bug affects 18 people
Affects Status Importance Assigned to Milestone
Qreator
Critical
David Planella
python-qrencode (Ubuntu)
Undecided
Unassigned
Xenial
Undecided
Unassigned
qreator (Ubuntu)
Undecided
Unassigned
Xenial
Undecided
Unassigned

Bug Description

=== Begin SRU Boilerplate for Ubuntu ===

[Impact]
python-qrencode is currently broken for all users in xenial due to the removal of Image.fromstring from pillow. The fix is to replace all calls to Image.fromstring with Image.frombytes.

qreator is also affected similarly in xenial, and requires a fix to switch the usage of PIL.Image.Image.tostring() with PIL.Image.Image.tobytes()

[Test Case]
Run the following script and see if it ends in an exception:

```
import qrencode
qrencode.encode_scaled("foo", 1)
```

In the case of qreator:
1. Launch Qreator after installing both the fixed qreator and python-qrencode packages.
2. Create a QR code
3. Verify that the QR code is displayed.
4. Save the QR code
5. Verify that the QR code was saved correctly.

[Regression Potential]
It's unlikely that python-qrencode can regress any further, because in its current state, both exported python methods are completely broken and will throw an exception unconditionally with the pillow version in Xenial.

[Other Info]
rdeps may also be broken if they use Image.tostring on the output. So far, the only known rdep that is broken is qreator.

Below is the stack trace and exception thrown by the broken version of qrencode.

In [5]: qrencode.encode_scaled("foo",1)
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-5-be07c22beab2> in <module>()
----> 1 qrencode.encode_scaled("foo",1)

/usr/lib/python2.7/dist-packages/qrencode/__init__.pyc in encode_scaled(data, size, version, level, hint, case_sensitive)
     67 the QR-code.
     68 """
---> 69 version, src_size, im = encode(data, version, level, hint, case_sensitive)
     70 if size < src_size:
     71 size = src_size

/usr/lib/python2.7/dist-packages/qrencode/__init__.pyc in encode(data, version, level, hint, case_sensitive)
     45 version, size, data = _encode(data, version, level, hint, False)
     46
---> 47 im = Image.fromstring('L', (size, size), data)
     48 return (version, size, im)
     49

/usr/lib/python2.7/dist-packages/PIL/Image.pyc in fromstring(*args, **kw)
   2061 def fromstring(*args, **kw):
   2062 raise Exception("fromstring() has been removed. " +
-> 2063 "Please call frombytes() instead.")
   2064
   2065

Exception: fromstring() has been removed. Please call frombytes() instead.

In [6]:

=== End SRU Boilerplate for Ubuntu ===

[Original bug report]

The program opens like normally, however it never displays a QR, even if you do Text, or URL, etc. If it doesn't display the QR code, you can't save it, either. Running from terminal, I'm getting lots of verbage that seems like a python 2.7 issue.

/usr/share/qreator/qreator_lib/Builder.py:21: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import GObject, Gtk # pylint: disable=E0611
/usr/share/qreator/qreator/qrcodes/QRCodeLocationGtk.py:17: PyGIWarning: GtkChamplain was imported without specifying a version first. Use gi.require_version('GtkChamplain', '0.12') before import to ensure that the right version gets loaded.
  from gi.repository import Gtk, GtkChamplain, Clutter, Champlain
/usr/share/qreator/qreator/qrcodes/QRCodeLocationGtk.py:19: PyGIWarning: GtkClutter was imported without specifying a version first. Use gi.require_version('GtkClutter', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import GtkClutter
/usr/share/qreator/qreator/qrcodes/QRCodeWifiGtk.py:20: PyGIWarning: NetworkManager was imported without specifying a version first. Use gi.require_version('NetworkManager', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import Gtk, NetworkManager, NMClient, GLib, GdkPixbuf
/usr/share/qreator/qreator/qrcodes/QRCodeWifiGtk.py:20: PyGIWarning: NMClient was imported without specifying a version first. Use gi.require_version('NMClient', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import Gtk, NetworkManager, NMClient, GLib, GdkPixbuf
No handlers could be found for logger "qreator_lib"
Traceback (most recent call last):
  File "/usr/share/qreator/qreator/QreatorWindow.py", line 512, in on_qr_drawingarea_draw
    output_type=QRCodeOutput.CAIRO_SURFACE)
  File "/usr/share/qreator/qreator/QRCode.py", line 61, in encode
    border)
  File "/usr/share/qreator/qreator/QRCode.py", line 70, in _encode_to_cairo
    current_color_bg, previous_color_bg, border)
  File "/usr/share/qreator/qreator/QRCode.py", line 94, in _encode_to_pil
    version, self.qrcode_size, self.image = qrencode.encode(text)
  File "/usr/lib/python2.7/dist-packages/qrencode/__init__.py", line 47, in encode
    im = Image.fromstring('L', (size, size), data)
  File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 2063, in fromstring
    "Please call frombytes() instead.")
Exception: fromstring() has been removed. Please call frombytes() instead.
Traceback (most recent call last):
  File "/usr/share/qreator/qreator/QreatorWindow.py", line 512, in on_qr_drawingarea_draw
    output_type=QRCodeOutput.CAIRO_SURFACE)
  File "/usr/share/qreator/qreator/QRCode.py", line 61, in encode
    border)
  File "/usr/share/qreator/qreator/QRCode.py", line 70, in _encode_to_cairo
    current_color_bg, previous_color_bg, border)
  File "/usr/share/qreator/qreator/QRCode.py", line 94, in _encode_to_pil
    version, self.qrcode_size, self.image = qrencode.encode(text)
  File "/usr/lib/python2.7/dist-packages/qrencode/__init__.py", line 47, in encode
    im = Image.fromstring('L', (size, size), data)
  File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 2063, in fromstring
    "Please call frombytes() instead.")
Exception: fromstring() has been removed. Please call frombytes() instead.

Related branches

-=SSD=- (m-sauer) on 2016-05-08
Changed in qreator:
status: New → Confirmed
Felix Eckhofer (eckhofer) wrote :

The fix is to replace
"self.image.tostring" with "self.image.tobytes" in /usr/share/qreator/qreator/QRCode.py:76 and
"Image.fromstring" with "Image.frombytes" in /usr/lib/python2.7/dist-packages/qrencode/__init__.py:47

The latter is a bug in python-qrencode, which has already been reported at https://bugs.launchpad.net/ubuntu/+source/python-qrencode/+bug/1587249

Please:

1. Create a new report following (https://help.ubuntu.com/community/ReportingBugs#Reporting_non-crash_hardware_and_desktop_application_bugs).

2. Mark this report as duplicate of the new one.

Thank you.

Changed in qreator:
status: Confirmed → Incomplete

After doing that also mark the new report as duplicate of bug #1587249.

David Planella (dpm) wrote :

Felix, thanks a lot for uncovering the fix!

For the Qreator one, would you mind proposing a branch? I'd then merge the fix here.

For the upstream bug, if they are not responsive we might as well have to add a patch to the python-qrencode Ubuntu package.

Changed in qreator:
status: Incomplete → Triaged
importance: Undecided → High
Felix Eckhofer (eckhofer) wrote :

I've proposed a branch (first time, sorry if I did something wrong) and created a pull request upstream. Don't have much hope with the activity upstream has seen, though.

Felix Eckhofer (eckhofer) wrote :

... aaaand I'm wrong and it's already merged :)

David Planella (dpm) on 2016-06-13
Changed in qreator:
milestone: none → 16.06.1
David Planella (dpm) on 2016-06-13
Changed in qreator:
status: Triaged → Fix Committed
David Planella (dpm) on 2016-06-13
Changed in qreator:
importance: High → Critical
assignee: nobody → David Planella (dpm)
David Planella (dpm) wrote :

Thanks so much Felix for the fixes here and upstream, you rock!

I created a new release in the Qreator stable PPA. You can install it with:

sudo add-apt-repository ppa:qreator-hackers/qreator-stable
sudo apt update
sudo apt install qreator python-qrencode

I've backported your fix to pyqrencode upstream to the python-qrencode package and uploaded it to the Qreator PPA. This way both packages will be updated and Qreator will ultimately work.

The final, proper, fix is to do an SRU (Stable Release Upload) of both packages to Ubuntu 16.04, but I'll have to leave that for later. If someone wants to pick up the task of preparing an SRU for python-qrencode based on the package I uploaded to the PPA, the help will be really welcome!

Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in python-qrencode (Ubuntu):
status: New → Confirmed
Chris Hermansen (c-hermansen) wrote :

For what it's worth I confirm that the bug exists in 16.10 and the patches described here work there as well.

Byte Commander (bytecommander) wrote :

16.04 (Xenial) still contains only the old versions with the bug, which are unusable.

David Planella (dpm) wrote :

Thanks for the comment. What I mentioned in my last reply still applies: if someone wants to lend a hand in doing an SRU upload to backport the fixes to 16.04, help would be very welcome.

In the meantime, you can install the fixed Qreator and python-qrencode in 16.04 using the version from the PPA, as per the instructions on my previous comment in this bug report.

Changed in qreator (Ubuntu):
status: New → Confirmed
John Carey (djjohhnyjetson) wrote :

The fix
sudo add-apt-repository ppa:qreator-hackers/qreator-stable
sudo apt update
sudo apt install qreator python-qrencode

Does fix this, but why is the old version still in any app stores that will not create any QR Codes?

Surely if this is a simple fix like this, the repositories should be updated with this newer version so that anyone wishing to create QR codes can do this once again!!

Chow Loong Jin (hyperair) wrote :

Sorry, slipped my notice that Xenial was still affected. It's fixed in Ubuntu 17.04 onwards.

John, which version of Ubuntu are you using?

Changed in python-qrencode (Ubuntu):
status: Confirmed → Fix Released
Changed in qreator (Ubuntu):
status: Confirmed → Fix Released
Changed in python-qrencode (Ubuntu Xenial):
status: New → Confirmed
Changed in qreator (Ubuntu Xenial):
status: New → Confirmed
description: updated
Robie Basak (racb) wrote :

4:36 -queuebot:#ubuntu-release- Unapproved: python-qrencode (xenial-proposed/universe) [1.01-5 => 1.01-5ubuntu1~xenial] (no packageset)
14:43 <rbasak> ^ ~xenial is dangerous
14:44 <rbasak> Because xenial > artful.

In this particular case it may be fine. But please don't start that pattern, and use something like ~16.04 at least.

Hello emptythevoid, or anyone else affected,

Accepted qreator into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/qreator/13.05.3-2ubuntu1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-xenial to verification-done-xenial. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-xenial. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in qreator (Ubuntu Xenial):
status: Confirmed → Fix Committed
tags: added: verification-needed verification-needed-xenial
Brian Murray (brian-murray) wrote :

Hello emptythevoid, or anyone else affected,

Accepted python-qrencode into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/python-qrencode/1.01-5ubuntu1~16.04 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-xenial to verification-done-xenial. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-xenial. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in python-qrencode (Ubuntu Xenial):
status: Confirmed → Fix Committed
Chow Loong Jin (hyperair) wrote :

Alright, looks like it's fixed for both.

Simon Quigley (tsimonq2) wrote :

Oh, looks like this was never marked. Changing the bug tags...

tags: added: verification-done verification-done-xenial
removed: verification-needed verification-needed-xenial
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package qreator - 13.05.3-2ubuntu1

---------------
qreator (13.05.3-2ubuntu1) xenial; urgency=medium

  * Fix PIL.Image.Image.tostring usage (LP: #1573577)

 -- Chow Loong Jin <email address hidden> Thu, 14 Dec 2017 22:09:47 +0800

Changed in qreator (Ubuntu Xenial):
status: Fix Committed → Fix Released

The verification of the Stable Release Update for qreator has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-qrencode - 1.01-5ubuntu1~16.04

---------------
python-qrencode (1.01-5ubuntu1~16.04) xenial; urgency=medium

  * Backport upstream patch to fix fromstring PIL exception
    (LP: #1573577)

 -- Chow Loong Jin <email address hidden> Thu, 14 Dec 2017 22:23:44 +0800

Changed in python-qrencode (Ubuntu Xenial):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers