def set_os_eol_chars(self, index=None, osname=None):
        """Sets the EOL character(s) based on the operating system.

        If `osname` is None, then the default line endings for the current
        operating system (`os.name` value) will be used.

        `osname` can be one of:
            ('posix', 'nt', 'java')
        """
        if osname is None:
            osname = os.name
        if index is None:
            index = self.get_stack_index()
        finfo = self.data[index]
        eol_chars = sourcecode.get_eol_chars_from_os_name(osname)
        finfo.editor.set_eol_chars(eol_chars)
        finfo.editor.document().setModified(True)