Skip to content

Fix Python 3 unicode exception in file uploads

This fixes the crash when attempting to create a new file in Python 3:

$ gracedb Test gstlal HighMass coinc.xml
Traceback (most recent call last):
  File "/Users/lpsinger/local/bin/gracedb", line 564, in <module>
    code = main()
  File "/Users/lpsinger/local/bin/gracedb", line 501, in main
    offline=options.offline, labels=options.labels)
  File "/Users/lpsinger/local/lib/python3.6/site-packages/ligo/gracedb/rest.py", line 619, in createEvent
    return self.post(uri, fields, files=files)
  File "/Users/lpsinger/local/lib/python3.6/site-packages/ligo/gracedb/rest.py", line 381, in post
    return self.post_or_put("POST", *args, **kwargs)
  File "/Users/lpsinger/local/lib/python3.6/site-packages/ligo/gracedb/rest.py", line 399, in post_or_put
    content_type, body = encode_multipart_formdata(body, files)
  File "/Users/lpsinger/local/lib/python3.6/site-packages/ligo/gracedb/rest.py", line 1285, in encode_multipart_formdata
    body = CRLF.join(L)
TypeError: sequence item 20: expected str instance, bytes found

Merge request reports

Loading