Kaydet (Commit) 3ade6f90 authored tarafından Alexandre Vassalotti's avatar Alexandre Vassalotti

Fixed test_tempfile.

Added the encoding, errors, line_buffering attribute to io.StringIO
make more compatible with TextIOWrapper's API.
üst 3c415a26
...@@ -1839,6 +1839,22 @@ try: ...@@ -1839,6 +1839,22 @@ try:
raise UnsupportedOperation("%s.buffer attribute is unsupported" % raise UnsupportedOperation("%s.buffer attribute is unsupported" %
self.__class__.__name__) self.__class__.__name__)
# XXX Cruft to support the TextIOWrapper API. This would only
# be meaningful if StringIO supported the buffer attribute.
# Hopefully, a better solution, than adding these pseudo-attributes,
# will be found.
@property
def encoding(self):
return "utf-8"
@property
def errors(self):
return "strict"
@property
def line_buffering(self):
return False
def _decode_newlines(self, input, final=False): def _decode_newlines(self, input, final=False):
# decode input (with the eventual \r from a previous pass) # decode input (with the eventual \r from a previous pass)
if self._pending: if self._pending:
......
...@@ -502,7 +502,7 @@ class SpooledTemporaryFile: ...@@ -502,7 +502,7 @@ class SpooledTemporaryFile:
# Setting newline="\n" avoids newline translation; # Setting newline="\n" avoids newline translation;
# this is important because otherwise on Windows we'd # this is important because otherwise on Windows we'd
# hget double newline translation upon rollover(). # hget double newline translation upon rollover().
self._file = _io.StringIO(encoding=encoding, newline="\n") self._file = _io.StringIO(newline="\n")
self._max_size = max_size self._max_size = max_size
self._rolled = False self._rolled = False
self._TemporaryFileArgs = {'mode': mode, 'buffering': buffering, self._TemporaryFileArgs = {'mode': mode, 'buffering': buffering,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment