@@ -387,13 +387,6 @@ ZipFile Objects
387
387
given.
388
388
The archive must be open with mode ``'w' ``, ``'x' `` or ``'a' ``.
389
389
390
- .. note ::
391
-
392
- There is no official file name encoding for ZIP files. If you have unicode file
393
- names, you must convert them to byte strings in your desired encoding before
394
- passing them to :meth: `write `. WinZip interprets all file names as encoded in
395
- CP437, also known as DOS Latin.
396
-
397
390
.. note ::
398
391
399
392
Archive names should be relative to the archive root, that is, they should not
@@ -413,7 +406,9 @@ ZipFile Objects
413
406
.. method :: ZipFile.writestr(zinfo_or_arcname, data, compress_type=None, \
414
407
compresslevel=None)
415
408
416
- Write the string *data * to the archive; *zinfo_or_arcname * is either the file
409
+ Write a file into the archive. The contents is *data *, which may be either
410
+ a :class: `str ` or a :class: `bytes ` instance; if it is a :class: `str `,
411
+ it is encoded as UTF-8 first. *zinfo_or_arcname * is either the file
417
412
name it will be given in the archive, or a :class: `ZipInfo ` instance. If it's
418
413
an instance, at least the filename, date, and time must be given. If it's a
419
414
name, the date and time is set to the current date and time.
@@ -454,11 +449,11 @@ The following data attributes are also available:
454
449
455
450
.. attribute :: ZipFile.comment
456
451
457
- The comment text associated with the ZIP file. If assigning a comment to a
452
+ The comment associated with the ZIP file as a :class: `bytes ` object.
453
+ If assigning a comment to a
458
454
:class: `ZipFile ` instance created with mode ``'w' ``, ``'x' `` or ``'a' ``,
459
8000
code>
- this should be a
460
- string no longer than 65535 bytes. Comments longer than this will be
461
- truncated in the written archive when :meth: `close ` is called.
455
+ it should be no longer than 65535 bytes. Comments longer than this will be
456
+ truncated.
462
457
463
458
464
459
.. _pyzipfile-objects :
@@ -625,13 +620,14 @@ Instances have the following methods and attributes:
625
620
626
621
.. attribute :: ZipInfo.comment
627
622
628
- Comment for the individual archive member.
623
+ Comment for the individual archive member as a :class: ` bytes ` object .
629
624
630
625
631
626
.. attribute :: ZipInfo.extra
632
627
633
628
Expansion field data. The `PKZIP Application Note `_ contains
634
- some comments on the internal structure of the data contained in this string.
629
+ some comments on the internal structure of the data contained in this
630
+ :class: `bytes ` object.
635
631
636
632
637
633
.. attribute :: ZipInfo.create_system
0 commit comments