浏览代码

[xattr] Write bytestrings, not characters

Philipp Hagemeister 11 年之前
父节点
当前提交
42cc71e80b
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      youtube_dl/postprocessor/xattrpp.py

+ 4 - 2
youtube_dl/postprocessor/xattrpp.py

@@ -5,6 +5,7 @@ import sys
 from .common import PostProcessor
 from ..utils import (
     hyphenate_date,
+    preferredencoding,
 )
 
 
@@ -70,7 +71,7 @@ class XAttrMetadataPP(PostProcessor):
                                     e = OSError(potential_errno, potential_errorstr)
                                     e.__cause__ = None
                                     raise e
-                            raise # Reraise unhandled error
+                            raise  # Reraise unhandled error
 
                 else:
                     # On Unix, and can't find pyxattr, setfattr, or xattr.
@@ -113,7 +114,8 @@ class XAttrMetadataPP(PostProcessor):
                     if infoname == "upload_date":
                         value = hyphenate_date(value)
 
-                    write_xattr(filename, xattrname, value)
+                    byte_value = value.encode(preferredencoding())
+                    write_xattr(filename, xattrname, byte_value)
 
             return True, info