Simplified preferredencoding()

Not sure what is the point to use yield to return encoding, thus
it will simplify the whole function.

Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
pull/8/head
Arvydas Sidorenko 2012-07-01 18:21:27 +02:00
rodzic d4e16d3e97
commit bae611f216
1 zmienionych plików z 7 dodań i 9 usunięć

Wyświetl plik

@ -32,15 +32,13 @@ def preferredencoding():
Returns the best encoding scheme for the system, based on
locale.getpreferredencoding() and some further tweaks.
"""
def yield_preferredencoding():
try:
pref = locale.getpreferredencoding()
u'TEST'.encode(pref)
except:
pref = 'UTF-8'
while True:
yield pref
return yield_preferredencoding().next()
try:
pref = locale.getpreferredencoding()
u'TEST'.encode(pref)
except:
pref = 'UTF-8'
return pref
def htmlentity_transform(matchobj):