Search code examples
pythonpostpypi

Why does pypi upload include \r\n in POST request data?


I recently upgraded my Mac to El Capitan. After the upgrade I started seeing strange behavior when I run "python setup.py upload"

The POST request generated by the upload command now inserts \r\n into each of the data fields.

It doesn't cause any issues uploading to python.org/pypi/ but I am using djangopypi (github.com/benliles/djangopypi/) and the library does string compares on that post request data. I've pushed a patch to my instance of djangopypi where it just strips the POST request data, but I still don't understand why my OS is adding those characters?

Here is an example of what the post data looks like on the server side.

 {u'comment': [u'\r\n\r'], 
u'license': [u'\r\nUNKNOWN\r'], 
u'protcol_version': [u'\r\n1\r'], 
u'metadata_version': [u'\r\n1.0\r'], 
u'author': [u'\r\nMe\r'], 
u'home_page': [u'\r\nhttp://[email protected]\r'], 
u'md5_digest': [u'\r\nesdfg2345f361b982345sdfg9952a\r'], 
u'filetype': [u'\r\nsdist\r'], 
u':action': [u'\r\nfile_upload\r'], 
u'download_url': [u'\r\nUNKNOWN\r'], 
u'name': [u'\r\nsample.app\r'], 
u'platform': [u'\r\nUNKNOWN\r'], 
u'version': [u'\r\n2.0\r'], 
u'pyversion': [u'\r\n\r'], 
u'keywords': [u'\r\ndjango sample\r'], 
u'author_email': [u'\r\[email protected]\r'], 
u'summary': [u'\r\nSample Summary\r'],}

I don't know how to look at it from my client side, help with that would also be helpful.


Solution

  • I found the root cause of this.

    Distutils was updated in Sept of 2014

    https://bugs.python.org/issue10510