diff options
author | Jason Kirtland <jek@discorporate.us> | 2008-01-10 23:16:56 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2008-01-10 23:16:56 +0000 |
commit | 3e9df22546cb4c7af0ece290f4f57a377516f142 (patch) | |
tree | a02dee0b6513ee58d80da2f58577a0cc53e58c5c /lib/sqlalchemy/util.py | |
parent | 04ad3303dc84b220292752afe343e73e35707e00 (diff) | |
download | sqlalchemy-3e9df22546cb4c7af0ece290f4f57a377516f142.tar.gz |
Include column name in length-less String warning (more [ticket:912])
Diffstat (limited to 'lib/sqlalchemy/util.py')
-rw-r--r-- | lib/sqlalchemy/util.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py index 01cbf5865..5c391ac3d 100644 --- a/lib/sqlalchemy/util.py +++ b/lib/sqlalchemy/util.py @@ -100,6 +100,16 @@ def to_set(x): else: return x +def to_ascii(x): + """Convert Unicode or a string with unknown encoding into ASCII.""" + + if isinstance(x, str): + return x.encode('string_escape') + elif isinstance(x, unicode): + return x.encode('unicode_escape') + else: + raise TypeError + def flatten_iterator(x): """Given an iterator of which further sub-elements may also be iterators, flatten the sub-elements into a single iterator. |