This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Unicode issue with tempfile on Windows
Type: behavior Stage: commit review
Components: IO Versions: Python 3.1, Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: amaury.forgeotdarc Nosy List: amaury.forgeotdarc, daniel.ugra, ezio.melotti, pitrou
Priority: normal Keywords: needs review, patch

Created on 2009-05-21 10:37 by daniel.ugra, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
UnicodeTest.py daniel.ugra, 2009-05-21 10:37 Python source showing the wrong behavior
tempfile.patch amaury.forgeotdarc, 2009-05-27 11:23
Messages (4)
msg88151 - (view) Author: Ugra Dániel (daniel.ugra) Date: 2009-05-21 10:37
Opening a file with tempfile.TemporaryFile using "wt+" mode, then
reading content back, will cause reading to stop (without any exception)
when encountering byte '0x1a' (aka. Ctrl+Z) on Windows even tough UTF-16
encoding is used. When using built-in open with the same parameters
(plus a file name of course) everything works as expected. On Linux this
issue does not exists.
msg88411 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-05-27 11:23
File descriptors wrapped by the new IO module should be opened in binary
mode.

The attached patch changes TemporaryFile and NamedTemporaryFile to
always call os.open() in binary mode; the mode is really used by the
io.open() function.

mkstemp() returns a raw file descriptor and was not changed.
msg95552 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-11-20 15:13
The patch looks ok to me.
msg95827 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-11-30 00:17
Fixed with r76593 (py3k) and r76594 (release31-maint)
History
Date User Action Args
2022-04-11 14:56:49adminsetgithub: 50327
2009-11-30 00:17:01amaury.forgeotdarcsetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg95827
2009-11-20 15:13:52pitrousetnosy: + pitrou
messages: + msg95552

assignee: amaury.forgeotdarc
resolution: accepted
stage: patch review -> commit review
2009-11-20 12:33:18pitrousetpriority: normal
versions: + Python 3.1, Python 3.2, - Python 3.0
components: + IO, - Library (Lib)
stage: patch review
2009-05-27 11:23:51amaury.forgeotdarcsetfiles: + tempfile.patch

nosy: + amaury.forgeotdarc
messages: + msg88411

keywords: + needs review, patch
2009-05-21 10:55:11ezio.melottisetnosy: + ezio.melotti
2009-05-21 10:37:59daniel.ugracreate