瀏覽代碼

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>
Arvydas Sidorenko 13 年之前
父節點
當前提交
bae611f216
共有 1 個文件被更改,包括 7 次插入9 次删除
  1. 7 9
      youtube_dl/utils.py

+ 7 - 9
youtube_dl/utils.py

@@ -32,15 +32,13 @@ def preferredencoding():
 	Returns the best encoding scheme for the system, based on
 	Returns the best encoding scheme for the system, based on
 	locale.getpreferredencoding() and some further tweaks.
 	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):
 def htmlentity_transform(matchobj):