Browse files

catch UnicodeWarnings from AsciiDammit

  • Loading branch information...
1 parent 6e8ac5c commit fc9d3adb3e7c0efce7b30930280816d86a79ca41 @smartt committed Oct 20, 2011
Showing with 9 additions and 4 deletions.
  1. +9 −4 sanitizer.py
View
13 sanitizer.py
@@ -29,7 +29,12 @@ def ascii_dammit(s):
s = unicodedata.normalize('NFKD', s).encode('ascii', 'ignore')
#s = unicodedata.normalize('NFKD', s).encode('ascii', 'replace')
- return AsciiDammit.asciiDammit(s)
+ try:
+ result = AsciiDammit.asciiDammit(s)
+ except UnicodeWarning:
+ result = s
+
+ return result
# --
def html_dammit(s):
@@ -306,13 +311,13 @@ def super_flat(s):
"""
>>> super_flat('')
''
-
+
>>> super_flat(None)
''
-
+
>>> super_flat('123-456-abc')
'123456ABC'
-
+
"""
if s is None:
return ''

0 comments on commit fc9d3ad

Please sign in to comment.