<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def fileobj(path_or_file, mode='r'):
 """Returns a file-like object that can be used as a context manager"""

    if isinstance(path_or_file, six.string_types):
        try:
            return open(path_or_file, mode)
        except IOError:
            log = logging.getLogger('sos')
            log.debug("fileobj: %s could not be opened" % path_or_file)
            return closing(six.StringIO())
    else:
        return closing(path_or_file)