def tail(self, fname, encoding, window, position=None):
if window <= <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>' % window)<EOL><DEDENT>encodings = ENCODINGS<EOL>if encoding:<EOL><INDENT>encodings = [encoding] + ENCODINGS<EOL><DEDENT>for enc in encodings:<EOL><INDENT>try:<EOL><INDENT>f = self.open(encoding=enc)<EOL>if f:<EOL><INDENT>return self.tail_read(f, window, position=position)<EOL><DEDENT>return False<EOL><DEDENT>except IOError as err:<EOL><INDENT>if err.errno == errno.ENOENT:<EOL><INDENT>return []<EOL><DEDENT>raise<EOL><DEDENT>except UnicodeDecodeError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>
Read last N lines from file fname.