Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 564930 - dev-python/qrcode Python3 - TypeError: must be str, not bytes
Summary: dev-python/qrcode Python3 - TypeError: must be str, not bytes
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: Normal minor (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-05 10:55 UTC by Graham
Modified: 2015-12-03 10:21 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Graham 2015-11-05 10:55:54 UTC
Symptoms
--------
Using the command line 

>qr "sometext" myimage.png 

I get error "TypeError: must be str, not bytes" 

My system has python 3.4 as default.


Workaround
----------
Changing console_scripts.py (line 60 in the current package) from  

> img.save(sys.stdout)

to

> img.save(sys.stdout.buffer)  

means qr is now working on my machine, and producing the qr code image.

Possible Solution
-----------------
A more sensible fix for the package is perhaps to add in a patch 

> -    img.save(sys.stdout)
> +    img.save(sys.stdout.buffer if sys.version_info[0] >= 3 else sys.stdout)

Which i found here :-
https://github.com/lincolnloop/python-qrcode/issues/66

(its a bit ugly, but it looks like it should do the job until upstream sort it out)
Comment 1 Tomáš Mózes 2015-11-05 19:10:50 UTC
Well yeah, but upstream said they will release a new version, try to ping the maintainer @github.
Comment 2 Justin Lecher (RETIRED) gentoo-dev 2015-12-03 10:21:51 UTC
commit 1b4109b06fe34ac39f3fc55996d66a9b6cc8d809
Author: Justin Lecher <jlec@gentoo.org>
Date:   Thu Dec 3 10:37:05 2015 +0100

    dev-python/qrcode: Backport fix for Python3

    Gentoo-Bug: https://bugs.gentoo.org/show_bug.cgi?id=564930

    Package-Manager: portage-2.2.25
    Signed-off-by: Justin Lecher <jlec@gentoo.org>

    https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1b4109b06fe34ac39f3fc55996d66a9b6cc8d809