summaryrefslogtreecommitdiffstats
path: root/Lib/tempfile.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-07-09 10:24:45 (GMT)
committerGuido van Rossum <guido@python.org>2007-07-09 10:24:45 (GMT)
commit9a63470fd7f1d96eff03ffd33bf75371d5bb6fac (patch)
treed6ed7a64fc9f557d04bef5d9285c807b10a105b3 /Lib/tempfile.py
parentb4e87e379219afd6ef1a0fba400275fa22180c63 (diff)
downloadcpython-9a63470fd7f1d96eff03ffd33bf75371d5bb6fac.zip
cpython-9a63470fd7f1d96eff03ffd33bf75371d5bb6fac.tar.gz
cpython-9a63470fd7f1d96eff03ffd33bf75371d5bb6fac.tar.bz2
Make test_tempfile.py work. Make SpooledTempFile work in text and binary mode.
Diffstat (limited to 'Lib/tempfile.py')
-rw-r--r--Lib/tempfile.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index 109dc59..68cc540 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -29,6 +29,7 @@ __all__ = [
# Imports.
+import io as _io
import os as _os
import errno as _errno
from random import Random as _Random
@@ -37,8 +38,6 @@ if _os.name == 'mac':
import Carbon.Folder as _Folder
import Carbon.Folders as _Folders
-from io import StringIO as _StringIO
-
try:
import fcntl as _fcntl
except ImportError:
@@ -486,7 +485,10 @@ class SpooledTemporaryFile:
def __init__(self, max_size=0, mode='w+b', bufsize=-1,
suffix="", prefix=template, dir=None):
- self._file = _StringIO()
+ if 'b' in mode:
+ self._file = _io.BytesIO()
+ else:
+ self._file = _io.StringIO()
self._max_size = max_size
self._rolled = False
self._TemporaryFileArgs = (mode, bufsize, suffix, prefix, dir)