Skip to content

bpo-32035: Update zipfile doc#4698

Closed
srcecde wants to merge 42 commits into
python:masterfrom
srcecde:fix-issue-32035
Closed

bpo-32035: Update zipfile doc#4698
srcecde wants to merge 42 commits into
python:masterfrom
srcecde:fix-issue-32035

Conversation

@srcecde

@srcecde srcecde commented Dec 4, 2017

Copy link
Copy Markdown

Updated the cpython/Doc/library/zipfile.rst documentation.

https://bugs.python.org/issue32035

@the-knights-who-say-ni

Copy link
Copy Markdown

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!

@srcecde srcecde changed the title issue #32035: Update zipfile doc bpo-32035: Update zipfile doc Dec 4, 2017
@srcecde srcecde changed the title bpo-32035: Update zipfile doc bpo-32035: Update zipfile doc skip news Dec 4, 2017
@srcecde srcecde changed the title bpo-32035: Update zipfile doc skip news bpo-32035: Update zipfile doc Dec 4, 2017
terryjreedy and others added 4 commits December 4, 2017 14:48
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.
Comment thread Doc/library/zipfile.rst
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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Mariatta and others added 5 commits December 4, 2017 21:04
…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.
ned-deily and others added 15 commits December 5, 2017 21:06
Remove also the initstr variable, unused since the commit
e69f0df pushed in 2012: "bpo-13959:
Re-implement imp.find_module() in Lib/imp.py"
* 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()
Comment thread Doc/library/zipfile.rst Outdated
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;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this line too long?

ZipFile.write() writes a file into archive. ZipFile.writestr() writes a bytes data or a string.

Comment thread Doc/library/zipfile.rst Outdated
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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. Thanks for the update.

Comment thread Doc/library/zipfile.rst
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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid unneeded rewrapping. Wrap only long lines that you have changed in any way.

Comment thread Doc/library/zipfile.rst Outdated
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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@srcecde srcecde requested a review from a team December 8, 2017 09:57
@srcecde srcecde requested a review from a team as a code owner December 8, 2017 09:57
@srcecde srcecde closed this Dec 8, 2017
@srcecde srcecde deleted the fix-issue-32035 branch December 8, 2017 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.