diff options
| author | Tomaz Solc <tomaz.solc@tablix.org> | 2013-01-16 20:32:56 +0100 |
|---|---|---|
| committer | Tomaz Solc <tomaz.solc@tablix.org> | 2013-01-16 20:32:56 +0100 |
| commit | 3bf9ab1cf27af03c68dea92f91e4134d6d3fd016 (patch) | |
| tree | 153768ba291419e12909ce968d69fc5b0a808cf6 /unidecode | |
| parent | f97558eda5570e36e5ff7ab8007d54414b00f58d (diff) | |
| download | unidecode-3bf9ab1cf27af03c68dea92f91e4134d6d3fd016.tar.gz | |
Warn if argument is not a subclass of unicode
Diffstat (limited to 'unidecode')
| -rw-r--r-- | unidecode/__init__.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/unidecode/__init__.py b/unidecode/__init__.py index 4a08bf0..f86fb03 100644 --- a/unidecode/__init__.py +++ b/unidecode/__init__.py @@ -13,6 +13,9 @@ In Python 3, a standard string object will be returned. If you need bytes, use: >>> unidecode("Κνωσός").encode("ascii") b'Knosos' """ +import warnings +from sys import version_info + Cache = {} def unidecode(string): @@ -22,6 +25,11 @@ def unidecode(string): "Bei Jing " """ + if version_info[0] < 3 and not isinstance(string, unicode): + warnings.warn( "Argument %r is not an unicode object. " + "Passing an encoded string will likely have " + "unexpected results." % (type(string),) , RuntimeWarning) + retval = [] for char in string: |
