bpo-32035: Fix words about strings and bytes in zipfile documentation… · python/cpython@af009fb

@@ -360,13 +360,6 @@ ZipFile Objects

360360

the new entry.

361361

The archive must be open with mode ``'w'``, ``'x'`` or ``'a'``.

362362363-

.. note::

364-365-

There is no official file name encoding for ZIP files. If you have unicode file

366-

names, you must convert them to byte strings in your desired encoding before

367-

passing them to :meth:`write`. WinZip interprets all file names as encoded in

368-

CP437, also known as DOS Latin.

369-370363

.. note::

371364372365

Archive names should be relative to the archive root, that is, they should not

@@ -385,7 +378,9 @@ ZipFile Objects

385378386379

.. method:: ZipFile.writestr(zinfo_or_arcname, data[, compress_type])

387380388-

Write the string *data* to the archive; *zinfo_or_arcname* is either the file

381+

Write a file into the archive. The contents is *data*, which may be either

382+

a :class:`str` or a :class:`bytes` instance; if it is a :class:`str`,

383+

it is encoded as UTF-8 first. *zinfo_or_arcname* is either the file

389384

name it will be given in the archive, or a :class:`ZipInfo` instance. If it's

390385

an instance, at least the filename, date, and time must be given. If it's a

391386

name, the date and time is set to the current date and time.

@@ -425,11 +420,11 @@ The following data attributes are also available:

425420426421

.. attribute:: ZipFile.comment

427422428-

The comment text associated with the ZIP file. If assigning a comment to a

423+

The comment associated with the ZIP file as a :class:`bytes` object.

424+

If assigning a comment to a

429425

:class:`ZipFile` instance created with mode ``'w'``, ``'x'`` or ``'a'``,

430-

this should be a

431-

string no longer than 65535 bytes. Comments longer than this will be

432-

truncated in the written archive when :meth:`close` is called.

426+

it should be no longer than 65535 bytes. Comments longer than this will be

427+

truncated.

433428434429435430

.. _pyzipfile-objects:

@@ -583,13 +578,14 @@ Instances have the following methods and attributes:

583578584579

.. attribute:: ZipInfo.comment

585580586-

Comment for the individual archive member.

581+

Comment for the individual archive member as a :class:`bytes` object.

587582588583589584

.. attribute:: ZipInfo.extra

590585591586

Expansion field data. The `PKZIP Application Note`_ contains

592-

some comments on the internal structure of the data contained in this string.

587+

some comments on the internal structure of the data contained in this

588+

:class:`bytes` object.

593589594590595591

.. attribute:: ZipInfo.create_system