Skip to content

Fix Python 3 type checking in file uploads

Python 3 does not have the built-in file type. Instead it has a hierarchy of types in the io module. This fixes tracebacks like the following:

Traceback (most recent call last):
  File "/private/tmp/gwcelery/lib/python3.6/site-packages/celery/app/trace.py", line 382, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/private/tmp/gwcelery/lib/python3.6/site-packages/celery/app/trace.py", line 641, in __protected_call__
    return self.run(*args, **kwargs)
  File "/Users/lpsinger/src/gwcelery/gwcelery/tasks/gracedb.py", line 27, in upload
    graceid, message, filename, filecontents, tags)
  File "/private/tmp/gwcelery/lib/python3.6/site-packages/ligo/gracedb/rest.py", line 820, in writeLog
    elif isinstance(filecontents, file):
NameError: name 'file' is not defined

Merge request reports