aboutsummaryrefslogtreecommitdiffstats
path: root/libbe
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2011-09-08 16:03:09 -0400
committerW. Trevor King <wking@drexel.edu>2011-09-08 16:03:09 -0400
commitbcd7ba792889ab804e8c312535afdfd17474b10f (patch)
tree67c0333229d98fb4450a05fd013c8ee968a132a6 /libbe
parentacef411a2c4c98aba73f894b361c2eb5f2d7606f (diff)
downloadbugseverywhere-bcd7ba792889ab804e8c312535afdfd17474b10f.tar.gz
Adjust encoding detection (using sys.getfilesystemencoding for file contents).
Diffstat (limited to 'libbe')
-rw-r--r--libbe/util/encoding.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/libbe/util/encoding.py b/libbe/util/encoding.py
index 22a2e30..3fde8cb 100644
--- a/libbe/util/encoding.py
+++ b/libbe/util/encoding.py
@@ -41,19 +41,22 @@ def get_encoding():
if ENCODING != None:
return ENCODING
encoding = locale.getpreferredencoding() or sys.getdefaultencoding()
- if sys.platform != 'win32' or sys.version_info[:2] > (2, 3):
- encoding = locale.getlocale(locale.LC_TIME)[1] or encoding
- # Python 2.3 on windows doesn't know about 'XYZ' alias for 'cpXYZ'
return encoding
def get_input_encoding():
- return get_encoding()
+ return sys.__stdin__.encoding or get_encoding()
def get_output_encoding():
return sys.__stdout__.encoding or get_encoding()
def get_filesystem_encoding():
- return get_encoding()
+ """Return the encoding that should be used for file contents
+
+ Note that `sys.getfilesystemencoding` returns the prefered
+ encoding for file *names*, and we're assuming that this is also
+ the prefered encoding for their contents.
+ """
+ return sys.getfilesystemencoding() or get_encoding()
def get_argv_encoding():
return get_encoding()