def _set_mode(self, mode="<STR_LIT:r>", bufsize=-<NUM_LIT:1>):
<EOL>self._bufsize = self._DEFAULT_BUFSIZE<EOL>if bufsize < <NUM_LIT:0>:<EOL><INDENT>bufsize = <NUM_LIT:0><EOL><DEDENT>if bufsize == <NUM_LIT:1>:<EOL><INDENT>self._flags |= self.FLAG_BUFFERED | self.FLAG_LINE_BUFFERED<EOL><DEDENT>elif bufsize > <NUM_LIT:1>:<EOL><INDENT>self._bufsize = bufsize<EOL>self._flags |= self.FLAG_BUFFERED<EOL>self._flags &= ~self.FLAG_LINE_BUFFERED<EOL><DEDENT>elif bufsize == <NUM_LIT:0>:<EOL><INDENT>self._flags &= ~(self.FLAG_BUFFERED | self.FLAG_LINE_BUFFERED)<EOL><DEDENT>if ("<STR_LIT:r>" in mode) or ("<STR_LIT:+>" in mode):<EOL><INDENT>self._flags |= self.FLAG_READ<EOL><DEDENT>if ("<STR_LIT:w>" in mode) or ("<STR_LIT:+>" in mode):<EOL><INDENT>self._flags |= self.FLAG_WRITE<EOL><DEDENT>if "<STR_LIT:a>" in mode:<EOL><INDENT>self._flags |= self.FLAG_WRITE | self.FLAG_APPEND<EOL>self._size = self._get_size()<EOL>self._pos = self._realpos = self._size<EOL><DEDENT>if "<STR_LIT:b>" in mode:<EOL><INDENT>self._flags |= self.FLAG_BINARY<EOL><DEDENT>if "<STR_LIT>" in mode:<EOL><INDENT>self._flags |= self.FLAG_UNIVERSAL_NEWLINE<EOL>self.newlines = None<EOL><DEDENT>
Subclasses call this method to initialize the BufferedFile.