[tor-commits] [bridgedb/develop] Type fix for generation of qrcodes
phw at torproject.org
phw at torproject.org
Wed Feb 19 18:27:18 UTC 2020
commit 82f4566fa127690184cd3aa443d1d5fd9001ff8d
Author: Damian Johnson <atagar at torproject.org>
Date: Sun Jan 19 17:33:59 2020 -0800
Type fix for generation of qrcodes
Fixing the following test failures...
Traceback (most recent call last):
File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_qrcodes.py", line 49, in test_generateQR
self.assertTrue(qrcodes.generateQR(self.bridgelines))
File "/usr/local/lib/python3.5/dist-packages/twisted/trial/_synctest.py", line 395, in assertTrue
super(_Assertions, self).assertTrue(condition, msg)
File "/usr/lib/python3.5/unittest/case.py", line 677, in assertTrue
raise self.failureException(msg)
twisted.trial.unittest.FailTest: None is not true
The actual problem was being masked by another catch-all...
Traceback (most recent call last):
File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_qrcodes.py", line 68, in test_generateQR_bridgeSchema
self.assertTrue(qrcodes.generateQR(self.bridgelines, bridgeSchema=True))
File "/home/atagar/Desktop/tor/bridgedb/bridgedb/qrcodes.py", line 65, in generateQR
img.save(buf, imageFormat)
File "/usr/local/lib/python3.5/dist-packages/PIL/Image.py", line 2084, in save
save_handler(self, fp, filename)
File "/usr/local/lib/python3.5/dist-packages/PIL/JpegImagePlugin.py", line 770, in _save
ImageFile._save(im, fp, [("jpeg", (0, 0) + im.size, 0, rawmode)], bufsize)
File "/usr/local/lib/python3.5/dist-packages/PIL/ImageFile.py", line 513, in _save
fp.write(d)
builtins.TypeError: string argument expected, got 'bytes'
Test results changed as follows...
before: FAILED (skips=115, failures=23, successes=846)
after: FAILED (skips=115, failures=21, successes=848)
---
bridgedb/qrcodes.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bridgedb/qrcodes.py b/bridgedb/qrcodes.py
index 80e82c8..6030a42 100644
--- a/bridgedb/qrcodes.py
+++ b/bridgedb/qrcodes.py
@@ -26,7 +26,7 @@ except ImportError: # pragma: no cover
"python-qrcode package."))
-def generateQR(bridgelines, imageFormat=u'JPEG', bridgeSchema=False):
+def generateQR(bridgelines, imageFormat='JPEG', bridgeSchema=False):
"""Generate a QRCode for the client's bridge lines.
:param str bridgelines: The Bridge Lines which we are distributing to the
@@ -60,7 +60,7 @@ def generateQR(bridgelines, imageFormat=u'JPEG', bridgeSchema=False):
qr = qrcode.QRCode()
qr.add_data(bridgelines)
- buf = io.StringIO()
+ buf = io.BytesIO()
img = qr.make_image().resize([350, 350])
img.save(buf, imageFormat)
buf.seek(0)
More information about the tor-commits
mailing list