New submission from Donald Stufft:

While working on PyPI 2.0 (which is currently running Python 3) I discovered 
that ``setup.py upload`` was causing an exception. After tracing things I 
determined that the reason for this is that Python 3 fails to handle leading 
whitespace in a multipart body.

I've attached a minimum reproducer that runs without error on Python 2.6 and 
Python 2.7 which fails on Python 3.2, 3.3, and 3.4.

If I go into the cgi.py module and add a print() statement that will print the 
header of each part, I get output that looks like:

b'----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\nContent-Disposition: 
form-data; name="protcol_version"\r\n\r\n'
b'Content-Disposition: form-data; name="summary"\r\n\r\n'
b'Content-Disposition: form-data; name="home_page"\r\n\r\n'
b'Content-Disposition: form-data; name="filetype"\r\n\r\n'
b'Content-Disposition: form-data; name="content"; 
filename="jasmin-13.13.13.tar.gz"\r\n\r\n'

The first line of that is obviously suspicious since it includes the inner 
boundary marker. Looking at the Python 3.x code it throws away the first line 
off the fp and then proceeds to process the rest of the fp. However in this 
case the first line is just a blank b'\r\n'. Looking at the Python 2.7 code it 
throws away an entire first part, not just the first line.

I'm guessing that the "read first line and throw it away code" needs to 
continue reading lines until it's read enough lines to get to the boundary 
marker.

----------
files: reproduce.py
messages: 239471
nosy: dstufft
priority: normal
severity: normal
status: open
title: cgi.FieldStorage has different (wrong?) behavior on Python3 than Python2
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file38721/reproduce.py

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

Reply via email to