summaryrefslogtreecommitdiff
path: root/Doc/library/zipfile.rst
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-11-25 01:30:37 -0800
committerGitHub <noreply@github.com>2018-11-25 01:30:37 -0800
commit89a3087d40feed3ca78033319389437bb4b5bcd7 (patch)
treed3a79646368d349c7d3aa1f9d0dc4a3975f51697 /Doc/library/zipfile.rst
parentbc665b42ba3a372bc60451583bfaff41d8e1993d (diff)
downloadcpython-git-89a3087d40feed3ca78033319389437bb4b5bcd7.tar.gz
bpo-32035: Fix words about strings and bytes in zipfile documentation. (GH-10592)
(cherry picked from commit 4bb186d7e253ad4def875305e06690181e923dfd) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Doc/library/zipfile.rst')
-rw-r--r--Doc/library/zipfile.rst24
1 files changed, 10 insertions, 14 deletions
diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst
index 7804e92e53..e1f8b9a4a3 100644
--- a/Doc/library/zipfile.rst
+++ b/Doc/library/zipfile.rst
@@ -380,13 +380,6 @@ ZipFile Objects
.. note::
- There is no official file name encoding for ZIP files. If you have unicode file
- names, you must convert them to byte strings in your desired encoding before
- passing them to :meth:`write`. WinZip interprets all file names as encoded in
- CP437, also known as DOS Latin.
-
- .. note::
-
Archive names should be relative to the archive root, that is, they should not
start with a path separator.
@@ -404,7 +397,9 @@ ZipFile Objects
.. method:: ZipFile.writestr(zinfo_or_arcname, data, compress_type=None, \
compresslevel=None)
- Write the string *data* to the archive; *zinfo_or_arcname* is either the file
+ Write a file into the archive. The contents is *data*, which may be either
+ a :class:`str` or a :class:`bytes` instance; if it is a :class:`str`,
+ it is encoded as UTF-8 first. *zinfo_or_arcname* is either the file
name it will be given in the archive, or a :class:`ZipInfo` instance. If it's
an instance, at least the filename, date, and time must be given. If it's a
name, the date and time is set to the current date and time.
@@ -445,11 +440,11 @@ The following data attributes are also available:
.. attribute:: ZipFile.comment
- The comment text associated with the ZIP file. If assigning a comment to a
+ The comment associated with the ZIP file as a :class:`bytes` object.
+ If assigning a comment to a
:class:`ZipFile` instance created with mode ``'w'``, ``'x'`` or ``'a'``,
- this should be a
- string no longer than 65535 bytes. Comments longer than this will be
- truncated in the written archive when :meth:`close` is called.
+ it should be no longer than 65535 bytes. Comments longer than this will be
+ truncated.
.. _pyzipfile-objects:
@@ -606,13 +601,14 @@ Instances have the following methods and attributes:
.. attribute:: ZipInfo.comment
- Comment for the individual archive member.
+ Comment for the individual archive member as a :class:`bytes` object.
.. attribute:: ZipInfo.extra
Expansion field data. The `PKZIP Application Note`_ contains
- some comments on the internal structure of the data contained in this string.
+ some comments on the internal structure of the data contained in this
+ :class:`bytes` object.
.. attribute:: ZipInfo.create_system