PIL exception fromstring

Bug #1587249 reported by Muelli
32
This bug affects 6 people
Affects Status Importance Assigned to Milestone
Qreator
Confirmed
Medium
Unassigned
python-qrencode (Ubuntu)
Fix Released
Medium
Unassigned
Xenial
New
Undecided
Unassigned
Yakkety
Fix Released
Undecided
Chow Loong Jin
qreator (Ubuntu)
Fix Released
Undecided
Unassigned
Xenial
New
Undecided
Unassigned
Yakkety
Won't Fix
Undecided
Unassigned

Bug Description

[Impact]
python-qrencode is currently broken for all users in yakkety due to the removal of Image.fromstring from pillow.

The fix is to replace all calls to Image.fromstring with Image.frombytes.

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

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

[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 Yakkety.

[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]:

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: python-qrencode 1.01-5
Uname: Linux 4.6.0-040600-generic x86_64
ApportVersion: 2.20.1-0ubuntu2.1
Architecture: amd64
CurrentDesktop: GNOME
Date: Tue May 31 07:40:21 2016
InstallationDate: Installed on 2015-12-02 (180 days ago)
InstallationMedia: Ubuntu-GNOME 16.04 LTS "Xenial Xerus" - Alpha amd64 (20151027)
SourcePackage: python-qrencode
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Muelli (ubuntu-bugs-auftrags-killer) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

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

Changed in python-qrencode (Ubuntu):
status: New → Confirmed
Revision history for this message
Felix Eckhofer (eckhofer) wrote :
Changed in python-qrencode (Ubuntu):
importance: Undecided → Medium
Revision history for this message
David Planella (dpm) wrote :

It might be worth filing a bug upstream too, even though they don't seem to be much active: https://github.com/Arachnid/pyqrencode

Revision history for this message
Felix Eckhofer (eckhofer) wrote :
Revision history for this message
Chow Loong Jin (hyperair) wrote :

Fixed in zesty.

Changed in python-qrencode (Ubuntu):
status: Confirmed → Fix Released
Changed in python-qrencode (Ubuntu Yakkety):
assignee: nobody → Chow Loong Jin (hyperair)
Revision history for this message
Chow Loong Jin (hyperair) wrote :
Changed in python-qrencode (Ubuntu Yakkety):
status: New → Confirmed
description: updated
Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello Muelli, or anyone else affected,

Accepted python-qrencode into yakkety-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/python-qrencode/1.01-5ubuntu1 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 to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

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 Yakkety):
status: Confirmed → Fix Committed
tags: added: verification-needed
Revision history for this message
Chow Loong Jin (hyperair) wrote :

It works:

In [1]: import qrencode

In [2]: qrencode.encode_scaled('foo', 1)
Out[2]: (1, 21, <PIL.Image.Image image mode=L size=21x21 at 0x7F6D7418E550>)

tags: added: verification-done
removed: verification-needed
Revision history for this message
Andy Whitcroft (apw) wrote : Update Released

The verification of the Stable Release Update for python-qrencode 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.

Revision history for this message
Launchpad Janitor (janitor) wrote :

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

---------------
python-qrencode (1.01-5ubuntu1) yakkety-proposed; urgency=medium

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

 -- Chow Loong Jin <email address hidden> Sun, 15 Jan 2017 22:00:46 +0800

Changed in python-qrencode (Ubuntu Yakkety):
status: Fix Committed → Fix Released
Revision history for this message
Phillip "ZyanKLee" Stockmann (zyanklee) wrote :

when running qreator on xenial this error occurs as well:

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.

David Planella (dpm)
Changed in qreator:
status: New → Confirmed
importance: Undecided → Medium
Changed in qreator (Ubuntu Yakkety):
status: New → Confirmed
Revision history for this message
David Planella (dpm) wrote :

Qreator in 16.04 and beyond requires the fix to python-qrencode and this fix [1] to Qreator itself. See bug 1573577 for more details.

The 16.04 Qreator package with the fix is available in the Qreator PPA. You can install it as a workaround as per the instructions on that bug. Adding them here again:

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

And again, if someone wants to lend a hand in doing an SRU upload to backport the Qreator fix to 16.04, help would be very welcome!

[1] https://code.launchpad.net/~eckhofer/qreator/qreator/+merge/297065

tags: added: patch
Revision history for this message
Launchpad Janitor (janitor) wrote :

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

Changed in qreator (Ubuntu):
status: New → Confirmed
Revision history for this message
Chow Loong Jin (hyperair) wrote :

Hmm, as far as I can tell, Qreator 16.06.1-1 and python-qrencode 1.2-1 are no longer affected by this bug. This means that it should be fixed in Ubuntu Zesty (17.04) upwards. I guess that leaves.. Xenial?

Changed in qreator (Ubuntu):
status: Confirmed → Fix Released
Changed in qreator (Ubuntu Yakkety):
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.