'Return the set of file descriptors to exclude closing.
Returns a set containing the file descriptors for the
items in `files_preserve`, and also each of `stdin`,
`stdout`, and `stderr`:
* If the item is ``None``, it is omitted from the return
set.
* If the item has a ``fileno()`` method, that method\'s
return value is in the return set.
* Otherwise, the item is in the return set verbatim.'

def _get_exclude_file_descriptors(self):

    files_preserve = self.files_preserve
    if (files_preserve is None):
        files_preserve = []
    files_preserve.extend((item for item in [self.stdin, self.stdout, self.stderr] if hasattr(item, 'fileno')))
    exclude_descriptors = set()
    for item in files_preserve:
        if (item is None):
            continue
        if hasattr(item, 'fileno'):
            exclude_descriptors.add(item.fileno())
        else:
            exclude_descriptors.add(item)
    return exclude_descriptors
