diff options
author | Emile Anclin <emile.anclin@logilab.fr> | 2010-09-21 15:25:09 +0200 |
---|---|---|
committer | Emile Anclin <emile.anclin@logilab.fr> | 2010-09-21 15:25:09 +0200 |
commit | 4ceefe71e176b38d333cc54597bc9427ea842f75 (patch) | |
tree | 960eceedad69ecd3e1df9f9c709acba42cb979ee /configuration.py | |
parent | 4619682b0138bf6cff28530a8a0af29f2bcc8749 (diff) | |
download | logilab-common-4ceefe71e176b38d333cc54597bc9427ea842f75.tar.gz |
[py3k] compat: add str_to_bytes and str_encode
In py3k, things are different: we will sometimes need to convert str to bytes
if we want to write data into a file;
and on other times we don't need to encode str to something
Diffstat (limited to 'configuration.py')
-rw-r--r-- | configuration.py | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/configuration.py b/configuration.py index fefe519..4357fcf 100644 --- a/configuration.py +++ b/configuration.py @@ -114,6 +114,7 @@ from ConfigParser import ConfigParser, NoOptionError, NoSectionError, \ from warnings import warn from logilab.common.compat import set, reversed, callable, raw_input +from logilab.common.compat import str_encode as _encode from logilab.common.textutils import normalize_text, unquote from logilab.common.deprecation import deprecated @@ -134,11 +135,6 @@ def _get_encoding(encoding, stream): encoding = locale.getpreferredencoding() return encoding -def _encode(string, encoding): - if isinstance(string, unicode): - return string.encode(encoding) - return str(string) - # validation functions ######################################################## |