bpo-32035: Update zipfile doc#4698
Conversation
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
Patches are in 3.7.0a3 even if this update is not.
When tk event handling is driven by IDLE's run loop, a confusing and distracting queue.EMPTY traceback context is no longer added to tk event exception tracebacks. The traceback is now the same as when event handling is driven by user code. Patch based on a suggestion by Serhiy Storchaka.
| 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 | ||
| Write the string or bytes *data* to the archive; if it is a *str*, it should be encoded as UTF-8. | ||
| *zinfo_or_arcname* is either the name of the file in the archive or a :class:`ZipInfo` instance. |
There was a problem hiding this comment.
The doc string wording works better IMO; see https://hg.python.org/cpython/rev/19196cce1431. In particular “bytes instance” makes more sense than “the bytes data”, and “it is encoded” is clearer; “it should be encoded” sounds like the responsibility of the caller.
…to some fields (#4685) * Rather than raise TypeError, warn and call list() on the value. * Fix tests, revise NEWS and whatsnew text. * Revise documentation, a string is okay as well. * Ensure 'requires' and 'obsoletes' are real lists. * Test that requires and obsoletes are turned to lists.
The undecodable file name cannot be created on macOS APFS file systems.
* Simplify _PyCoreConfig_INIT, _PyMainInterpreterConfig_INIT, _PyPathConfig_INIT macros: no need to set fields to 0/NULL, it's redundant (the C language sets them to 0/NULL for us). * Fix typo: pymain_run_statup() => pymain_run_startup() * Remove a few XXX/TODO
* Py_Main() now starts by reading Py_xxx configuration variables to only work on its own private structure, and then later writes back the configuration into these variables. * Replace Py_GETENV() with pymain_get_env_var() which ignores empty variables. * Add _PyCoreConfig.dump_refs * Add _PyCoreConfig.malloc_stats * _PyObject_DebugMallocStats() is now responsible to check if debug hooks are installed. The function returns 1 if stats were written, or 0 if the hooks are disabled. Mark _PyMem_PymallocEnabled() as static.
PyImport_ExtendInittab() now uses PyMem_RawRealloc() rather than PyMem_Realloc(). PyImport_ExtendInittab() can be called before Py_Initialize() whereas only the PyMem_Raw allocator is supposed to be used before Py_Initialize(). Add _PyImport_Fini2() to release the memory allocated by PyImport_ExtendInittab() at exit. PyImport_ExtendInittab() now forces the usage of the default raw allocator, to be able to release memory in _PyImport_Fini2(). Don't export these functions anymore to be C API, only to Py_BUILD_CORE: * _PyExc_Fini() * _PyImport_Fini() * _PyGC_DumpShutdownStats() * _PyGC_Fini() * _PyType_Fini() * _Py_HashRandomization_Fini()
…into fix-issue-32035
| 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. | ||
| Write a file into archive. The content is *data* which may be either a *str* or a *bytes* instance; |
There was a problem hiding this comment.
Isn't this line too long?
ZipFile.write() writes a file into archive. ZipFile.writestr() writes a bytes data or a string.
| 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. | ||
| Write a file into archive. The content is *data* which may be either a *str* or a *bytes* instance; | ||
| if it is a *str*, it is encoded as UTF-8. |
There was a problem hiding this comment.
I'm not sure this looks correct. str instance is not encoded. It is just a sequence of character, and how it is represented internally is an implementation detail.
There was a problem hiding this comment.
Yes, you are right. Thanks for the update.
| name, the date and time is set to the current date and time. | ||
| Write a file into archive. The content is *data* which may be either a *str* or a *bytes* instance; | ||
| if it is a *str*, it is encoded as UTF-8. | ||
| *zinfo_or_arcname* is either the name of the file in the archive or a :class:`ZipInfo` instance. |
There was a problem hiding this comment.
Please avoid unneeded rewrapping. Wrap only long lines that you have changed in any way.
| 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. | ||
| `ZipFile.write()` writes a file into archive. `ZipFile.writestr()` writes a bytes data or a string. |
There was a problem hiding this comment.
Oh, I didn't mean that you should include my words verbatim. ZipFile.write() is documented in the description of ZipFile.write().
The existing documentation is mostly good. The only problem is that the term "string" is used in wider meaning that includes byte strings, but this is not clear. Just document what actually does this method.
Updated the cpython/Doc/library/zipfile.rst documentation.
https://bugs.python.org/issue32035