Red Hat Bugzilla – Bug 1287830
[abrt] python3-qrcode: PngImagePlugin.py:690:_save:TypeError: must be str, not bytes
Last modified: 2016-12-20 11:35:48 EST
Description of problem:
bar" > qr.png
Version-Release number of selected component:
cmdline: /usr/bin/python3 /usr/bin/qrcode 'G\xc3\xbcltig:/Valid 01.10.15-30.09.16\nID: ev80uhys'
runlevel: N 5
PngImagePlugin.py:690:_save:TypeError: must be str, not bytes
Traceback (most recent call last):
File "/usr/bin/qrcode", line 9, in <module>
load_entry_point('qrcode==5.1', 'console_scripts', 'qr')()
File "/usr/lib/python3.4/site-packages/qrcode/console_scripts.py", line 59, in main
File "/usr/lib/python3.4/site-packages/qrcode/image/pil.py", line 32, in save
File "/usr/lib64/python3.4/site-packages/PIL/Image.py", line 1665, in save
save_handler(self, fp, filename)
File "/usr/lib64/python3.4/site-packages/PIL/PngImagePlugin.py", line 690, in _save
TypeError: must be str, not bytes
Local variables in innermost frame:
chunk: <function putchunk at 0x7f45cf8c9048>
im: <PIL.Image.Image image mode=1 size=410x410 at 0x7F45D074EB70>
fp: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
Created attachment 1101595 [details]
Created attachment 1101596 [details]
File PIL/PngImagePlugin.py looks like this:
_MAGIC = b"\211PNG\r\n\032\n" # line 53, initialize as bytes
fp.write(_MAGIC) # line 690, write() expects string, not bytes
Variable "_MAGIC" is initialized as bytes, but method write() expects a string if the file object has not been opened in binary mode:
Now the file object "fp" originates in qrcode/console_scripts.py:
img.save(sys.stdout) # line 59
Clearly "sys.stdout" is not in binary mode!
The official solution is to use "sys.stdout.buffer" instead of "sys.stdout":
This bug has been fixed upstream:
Unfortunately it's still there in current stable version 5.1.
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora 'version'
Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.
Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 23 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.
Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.
Still there in Fedora 24.
I cannot change the version as I don't own the bug. Anyone?
Fedora 23 changed to end-of-life (EOL) status on 2016-12-20. Fedora 23 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.
If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
Thank you for reporting this bug and we are sorry it could not be fixed.