This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: assertion failure in zipimporter.get_source() in case of a bad zlib.decompress()
Type: crash Stage: resolved
Components: Extension Modules Versions: Python 3.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: Oren Milman, brett.cannon
Priority: normal Keywords: patch

Created on 2017-09-27 06:24 by Oren Milman, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3784 merged Oren Milman, 2017-09-27 07:21
Messages (2)
msg303100 - (view) Author: Oren Milman (Oren Milman) * Date: 2017-09-27 06:24
The following code causes an assertion failure (in case there exists a
compressed zip file named '' with a file called '' in it):

import zlib
import zipimport
def bad_decompress(*args):
    return None

zlib.decompress = bad_decompress

This is because get_data() (in Modules/zipimport.c) assumes that
zlib.decompress() returned a bytes object, and returns it.
zipimport_zipimporter_get_source_impl() assumes that get_data() returned a
bytes object, and passes it to PyBytes_AS_STRING(), which asserts it is a bytes
msg303351 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2017-09-29 18:34
New changeset 01c6a8859ef2ff5545a87cf537573bd342c848bf by Brett Cannon (Oren Milman) in branch 'master':
bpo-31602: Fix an assertion failure in zipimporter.get_source() in case of a bad zlib.decompress() (GH-3784)
Date User Action Args
2022-04-11 14:58:52adminsetgithub: 75783
2017-09-29 18:35:09brett.cannonsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-09-29 18:34:33brett.cannonsetmessages: + msg303351
2017-09-29 17:11:31brett.cannonsetassignee: brett.cannon

nosy: + brett.cannon
2017-09-27 07:21:47Oren Milmansetkeywords: + patch
stage: patch review
pull_requests: + pull_request3769
2017-09-27 06:24:51Oren Milmancreate