New submission from Brad Greenlee <b...@footle.org>:

If GZipFile.__init_ is passed a fileobj that has a mode attribute set to None, 
it will crash with a "'NoneType' object is unsubscriptable" error when it tries 
to read the first character of the mode.

I ran across this when trying to pass GZipFile an uploaded file in Django 
1.2.3. Django produced an InMemoryUploadedFile object that has a mode attribute 
set to None.

The attached patch fixes the issue by only using fileobj.mode if it exists and 
is not None.

(The patch is against 2.7, although the issue exists in all versions I've 
looked at.)

----------
components: Library (Lib)
files: gzip_mode_fix.diff
keywords: patch
messages: 121021
nosy: bgreenlee
priority: normal
severity: normal
status: open
title: GZipFile crash when fileobj.mode is None
type: crash
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3
Added file: http://bugs.python.org/file19576/gzip_mode_fix.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue10392>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to