# HG changeset patch # User Paul Boddie # Date 1481840800 -3600 # Node ID 839fad2aab0a0de8935cda2cb85914a4f0bd7092 # Parent 4ef5d5e656c050d269771a1ebb876f8a921bc04f Added a localised stdin stream employing the preferred encoding from the locale. diff -r 4ef5d5e656c0 -r 839fad2aab0a lib/posix/io.py --- a/lib/posix/io.py Thu Dec 15 23:25:48 2016 +0100 +++ b/lib/posix/io.py Thu Dec 15 23:26:40 2016 +0100 @@ -21,6 +21,7 @@ from __builtins__.file import filestream from __builtins__.types import check_int, check_string + from native import ( close as _close, fdopen as _fdopen, @@ -28,6 +29,8 @@ write as _write ) +import locale + # Abstractions for system-level files and streams. class sysfile: @@ -78,6 +81,13 @@ stdout = sysstream(1, "w") stderr = sysstream(2, "w") +# Localised streams. +# Perform locale initialisation explicitly to ensure that the locale module +# and various function defaults have been initialised. + +locale.initlocale() +lstdin = sysstream(0, "r", locale.getpreferredencoding()) + # Input/output functions. def close(fd): diff -r 4ef5d5e656c0 -r 839fad2aab0a lib/sys.py --- a/lib/sys.py Thu Dec 15 23:25:48 2016 +0100 +++ b/lib/sys.py Thu Dec 15 23:26:40 2016 +0100 @@ -20,7 +20,8 @@ """ from __builtins__.int import maxint, minint -from posix.io import stdin, stdout, stderr +from posix.io import lstdin, stdin, stdout, stderr + from native import ( exit as _exit, get_argv as _get_argv,