mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Always use binary mode in NamedTempoeraryFile
Text mode would enable auto line ending translation, but we want to handle them ourselves (in io.open) instead. This would not affect the ability to write text files (io.open does the right thing as long as we give it the correct mode).
This commit is contained in:
+2
-3
@@ -9,7 +9,7 @@ import io
|
||||
import os
|
||||
import six
|
||||
import warnings
|
||||
from tempfile import _bin_openflags, gettempdir, _mkstemp_inner, mkdtemp, _text_openflags
|
||||
from tempfile import _bin_openflags, gettempdir, _mkstemp_inner, mkdtemp
|
||||
from .utils import (logging, rmtree)
|
||||
|
||||
try:
|
||||
@@ -258,13 +258,12 @@ def NamedTemporaryFile(
|
||||
if os.name == "nt" and delete:
|
||||
flags |= os.O_TEMPORARY
|
||||
if six.PY2:
|
||||
flags = _text_openflags if 'b' not in mode else flags
|
||||
(fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)
|
||||
else:
|
||||
(fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
|
||||
try:
|
||||
file = io.open(
|
||||
fd, mode, buffering=buffering, newline=newline, encoding=encoding
|
||||
fd, mode, buffering=buffering, newline=newline, encoding=encoding,
|
||||
)
|
||||
return _TemporaryFileWrapper(file, name, delete)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user