Simplified preferredencoding()
authorArvydas Sidorenko <asido4@gmail.com>
Sun, 1 Jul 2012 16:21:27 +0000 (18:21 +0200)
committerArvydas Sidorenko <asido4@gmail.com>
Sun, 1 Jul 2012 16:21:27 +0000 (18:21 +0200)
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>
youtube_dl/utils.py

index 2853ba50f228bb1f87900aa78a256b1637fcee2b..7faa046c8cf6f9a464f8de65cfd0c637664329ba 100644 (file)
@@ -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):