jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1326220?usp=email )

Change subject: [bugfix] Hash photo content as bytes in data_ingestion
......................................................................

[bugfix] Hash photo content as bytes in data_ingestion

BytesIO.getbuffer() returns a memoryview which PyPy's cffi based hashlib
implementation cannot pass to ffi.from_buffer(), so
TestPhoto.test_find_duplicate_images fails with a TypeError there.

Use getvalue() which returns bytes on both CPython and PyPy and keep
SHA-1 marked as non-security use.

Bug: T435049
Change-Id: I1f1596f0a77a4073dcc198daa042dac705f3a365
---
M scripts/data_ingestion.py
1 file changed, 3 insertions(+), 1 deletion(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/scripts/data_ingestion.py b/scripts/data_ingestion.py
index cd050e9..63951f9 100755
--- a/scripts/data_ingestion.py
+++ b/scripts/data_ingestion.py
@@ -157,8 +157,10 @@

         TODO: Add exception handling, fix site thing
         """
+        # getvalue() returns bytes; the memoryview from getbuffer() cannot
+        # be passed to PyPy's cffi based hashlib implementation (T435049)
         hash_object = hashlib.sha1(
-            self.download_photo().getbuffer(), usedforsecurity=False)
+            self.download_photo().getvalue(), usedforsecurity=False)
         return [page.title(with_ns=False)
                 for page in self.site.allimages(
                     sha1=base64.b16encode(hash_object.digest()))]

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1326220?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I1f1596f0a77a4073dcc198daa042dac705f3a365
Gerrit-Change-Number: 1326220
Gerrit-PatchSet: 1
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to