Commit graph

105246 commits

Author SHA1 Message Date
Greg Price 455122a009 bpo-37936: Systematically distinguish rooted vs. unrooted in .gitignore (GH-15823)
A root cause of bpo-37936 is that it's easy to write a .gitignore
rule that's intended to apply to a specific file (e.g., the
`pyconfig.h` generated by `./configure`) but actually applies to all
similarly-named files in the tree (e.g., `PC/pyconfig.h`.)

Specifically, any rule with no non-trailing slashes is applied in an
"unrooted" way, to files anywhere in the tree.  This means that if we
write the rules in the most obvious-looking way, then

 * for specific files we want to ignore that happen to be in
   subdirectories (like `Modules/config.c`), the rule will work
   as intended, staying "rooted" to the top of the tree; but

 * when a specific file we want to ignore happens to be at the root of
   the repo (like `platform`), then the obvious rule (`platform`) will
   apply much more broadly than intended: if someone tries to add a
   file or directory named `platform` somewhere else in the tree, it
   will unexpectedly get ignored.

That's surprising behavior that can make the .gitignore file's
behavior feel finicky and unpredictable.

To avoid it, we can simply always give a rule "rooted" behavior when
that's what's intended, by systematically using leading slashes.

Further, to help make the pattern obvious when looking at the file and
minimize any need for thinking about the syntax when adding new rules:
separate the rules into one group for each type, with brief comments
identifying them.

For most of these rules it's clear whether they're meant to be rooted
or unrooted, but in a handful of cases I've only guessed.  In that
case the safer default (the choice that won't hide information) is the
narrower, rooted meaning, with a leading slash.  If for some of these
the unrooted meaning is desired after all, it'll be easy to move them
to the unrooted section at the top.
2019-09-11 10:25:26 +01:00
Gregory P. Smith 580d2782f7 bpo-37424: Avoid a hang in subprocess.run timeout output capture (GH-14490)
Fixes a possible hang when using a timeout on subprocess.run() while
capturing output. If the child process spawned its own children or otherwise
connected its stdout or stderr handles with another process, we could hang
after the timeout was reached and our child was killed when attempting to read
final output from the pipes.
2019-09-11 02:23:05 -07:00
Brad 3fb1363fe8 Overhaul datetime documentation (GH-13410)
This is a restructuring of the datetime documentation to hopefully make
them more user-friendly and approachable to new users without losing any
of the detail.

Changes include:
 - Creating dedicated subsections for some concepts such as:
    - "Constants"
    - "Naive vs Aware"
    - "Determining if an Object is Aware"
 - Give 'naive vs aware' its own subsection
 - Give 'constants' their own subsection
 - Overhauling the strftime-strptime section by:
    - Breaking it into logical, linkable, and digestable parts
    - Adding a high-level comparison table
    - Moving the technical detail to bottom: readers come to this
      section primarily to remind themselves to things:
      - How do I write the format code for X?
      - strptime/strftime: which one is which again?
 - Touching up fromisoformat + isoformat sections by:
    - Revising fromisoformat + isoformat for date, time, and
      datetime
    - Adding basic examples
    - Enforcing consistency about putting formats (i.e. ``HH:MM``)
      in double backticks.  This was previously done in some places
      but not all
    - Putting long 'supported formats', on their own line to improve
      readability
 - Moving the 'seealso' section to the top and add a link to dateutil
    Rationale: This doesn't really belong nested under the
    'constants' section.  Let readers know right away that
    datetime is one of several related tools.
 - Moving common features of several types into one place:
    Previously, each type went out of its way to note separately
    that it was hashable and picklable.  These can be brought
    into one single place that is more prominent.
 - Reducing some verbose explanations to improve readability
 - Breaking up long paragraphs into digestable chunks
 - Displaying longer "equivalent to" examples, as short code blocks
 - Using the dot notation for datetime/time classes:
    Use :class:`.time` and :class:`.datetime` rather than :class:`time` and
    :class:`datetime`; otherwise, the generated links will route to the
    respective modules, not classes.
 - Rewording the tzinfo class description
    The top paragraph should get straight to the point of telling the reader
    what subclasses of tzinfo _do_.  Previously, that was hidden in a later
    paragraph.
 - Adding a note on .today() versus .now()
 - Rearranging and expanding example blocks, including:
    - Moved long, multiline inline examples to standalone examples
    - Simplified the example block for timedelta arithmetic:
        - Broke the example into two logical sections:
          1. normalization/parameter 'merging'
          2. timedelta arithmetic
        - Reduced the complexity of the some of the examples.  Show
          reasonable, real-world uses cases that are easy to follow
          along with and progres in difficult slightly.
    - Broke up the example sections for date and datetime sections by putting
      the easy examples first, progressing to more esoteric situations and
      breaking it up into logical sections based on what the methods are
      doing at a high level.
    - Simplified the KabulTz example:
        - Put the class definition itself into a non-REPL block since there is
          no interactive output involved there
        - Briefly explained what's happening before launching into the code
        - Broke the example section into visually separate chunks
 - Various whitespace, formatting, style and grammar fixes including:
    - Consistently using backctics for 'date_string' formats
    - Consistently using one space after periods.
    - Consistently using bold for vocab terms
    - Consistently using italics when referring to params:
      See https://devguide.python.org/documenting/#id4
    - Using '::' to lead into code blocks
        Per https://devguide.python.org/documenting/#source-code, this will
        let the reader use the 'expand/collapse' top-right button for REPL
        blocks to hide or show the prompt.
    - Using consistent captialization schemes
    - Removing use of the default role
    - Put 'example' blocks in Markdown subsections

This is a combination of 66 commits.

See bpo-36960: https://bugs.python.org/issue36960
2019-09-11 10:19:05 +01:00
Eddie Elizondo ff023ed36e bpo-37879: Suppress subtype_dealloc decref when base type is a C heap type (GH-15323)
The instance destructor for a type is responsible for preparing
an instance for deallocation by decrementing the reference counts
of its referents.

If an instance belongs to a heap type, the type object of an instance
has its reference count decremented while for static types, which
are permanently allocated, the type object is unaffected by the
instance destructor.

Previously, the default instance destructor searched the class
hierarchy for an inherited instance destructor and, if present,
would invoke it.

Then, if the instance type is a heap type, it would decrement the
reference count of that heap type.  However, this could result in the
premature destruction of a type because the inherited instance
destructor should have already decremented the reference count
of the type object.

This change avoids the premature destruction of the type object
by suppressing the decrement of its reference count when an
inherited, non-default instance destructor has been invoked.

Finally, an assertion on the Py_SIZE of a type was deleted.  Heap
types have a non zero size, making this into an incorrect assertion.

https://github.com/python/cpython/pull/15323
2019-09-11 10:17:13 +01:00
Andrew Svetlov 7264e92b71 bpo-36373: Fix deprecation warnings (GH-15889)
https://bugs.python.org/issue36373
2019-09-11 01:20:24 -07:00
wwuck efd5741ae9 bpo-38034: Fix typo in logging.handlers.rst (GH-15708) 2019-09-11 07:44:37 +01:00
Gregory P. Smith 3f4db4a0ba bpo-28494: Test existing zipfile working behavior. (GH-15853)
Add unittests for executables with a zipfile appended to test_zipfile, as zipfile.is_zipfile and zipfile.ZipFile work properly on these today.
2019-09-10 09:14:11 -07:00
Sergey Fedoseev afdeb189e9 Remove unneeded assignment in PyBytes_Concat() (GH-15274)
The `wb.len = -1` assignment is unneeded since its introduction in 161d695fb0 as `PyObject_GetBuffer` always fills it in.
2019-09-10 17:11:10 +01:00
jdkandersson 9cbb97b29e bpo-37574: Mention helper functions for find_spec documentation (GH-14739) 2019-09-10 17:06:22 +01:00
Jordon Xu 2ec7010206 bpo-37752: Delete redundant Py_CHARMASK in normalizestring() (GH-15095) 2019-09-10 17:04:08 +01:00
Steve Dower 801f925998 bpo-38089: Move Azure Pipelines to latest VM versions and make macOS tests optional (GH-15851) 2019-09-10 16:53:03 +01:00
Gordon P. Hemsley 7d952ded68 bpo-32424: Deprecate xml.etree.ElementTree.Element.copy() in favor of copy.copy() (GH-12995) 2019-09-10 16:22:01 +01:00
Ben Harper a9b6033179 bpo-36253: Remove use after free reference in ctypes test suite (GH-12257) 2019-09-10 08:20:15 -07:00
Andre Delfino 912108891d bpo-33602: Doc: Remove set and queue references from Data Types (GH-7055) 2019-09-10 17:11:16 +02:00
Kyle Stanley b6dafe5139 Docs: Small tweaks to c-api/intro#Include_Files (GH-14698) 2019-09-10 16:09:34 +01:00
William Andrea faff81c05f Correct info about "f.read(size)". (GH13852)
In text mode, the "size" parameter indicates the number of characters, not bytes.
2019-09-10 15:50:26 +01:00
Andre Delfino 05184515f9 Correct minor grammatical mistake in open docs (GH-15865) 2019-09-10 15:48:05 +01:00
Dmitry Shachnev c3d679fd39 bpo-37504: Fix documentation build with texinfo builder (GH-14606)
In the table model used by docutils, the `cols` attribute of `tgroup`
nodes is mandatory, see [1]. It is used in texinfo builder in [2].

[1]: https://www.oasis-open.org/specs/tm9901.htm#AEN348
[2]: https://github.com/sphinx-doc/sphinx/blob/v2.1.2/sphinx/writers/texinfo.py#L1129

* Doc: Add texinfo support to the Makefile
2019-09-10 15:40:50 +01:00
Steve Dower a39a4c7439
bpo-37913: Link to NotImplemented from new docs (GH-15860) 2019-09-10 15:25:12 +01:00
Jeroen Demeyer 009ef2955d bpo-37913: document that __length_hint__ can return NotImplemented (GH-15383) 2019-09-10 15:01:13 +01:00
Jason R. Coombs 17499d8270 bpo-38086: Sync importlib.metadata with importlib_metadata 0.21. (GH-15840)
https://gitlab.com/python-devs/importlib_metadata/-/tags/0.21
2019-09-10 14:53:31 +01:00
Steve Dower 97d7906e30 bpo-38087: Fix case sensitivity in test_pathlib and test_ntpath (GH-15850) 2019-09-10 14:52:48 +01:00
Steve Dower cd8221152d bpo-38088: Fixes distutils not finding vcruntime140.dll with only v142 toolset installed (GH-15849) 2019-09-10 14:52:23 +01:00
Matthias 182e1d1f84 Fix subprocess docstring typo (GH-15812) 2019-09-10 14:51:09 +01:00
Zach Thompson c2f056be82 Fix typo in ssl.RAND_bytes documentation (GH-14791)
It looks like "cryptographically strong" is the preferred phrase from the surrounding documentation.

Automerge-Triggered-By: @tiran
2019-09-10 06:40:14 -07:00
Pablo Galindo a511c7a496 bpo-38090: Fix reference leak in ceval.c (GH-15848) 2019-09-10 14:32:54 +01:00
Serhiy Storchaka 88bdb9280b bpo-36781: Optimize sum() for bools. (#13074)
* Optimize sum() for bools.

* Fix sum([], False).

* Add a NEWS entry.
2019-09-10 14:31:01 +01:00
Andre Delfino c1d8c1cb8e Note regarding + mode truncation applies to both text and binary mode (#11314)
* Improve doc on open's mode +

* Improve wording

* Address comment from Rémi
2019-09-10 14:04:22 +01:00
Dino Viehland b7f8e52433 bpo-38073: Make pwd module PEP-384 compatible (GH-15790)
Makes the pwd module PEP-384 compatible


https://bugs.python.org/issue38073



Automerge-Triggered-By: @tiran
2019-09-10 05:59:43 -07:00
Andrew Svetlov 12c122ae95 bpo-38066: Hide internal Stream methods (GH-15762)
feed_eof(), feed_data(), set_exception(), and set_transport() are prefixed with underscore now.


https://bugs.python.org/issue38066
2019-09-10 05:56:14 -07:00
Arun Persaud 9a94093189 bpo-21018: added missing documentation about escaping characters for configparser (GH-6137)
Document how $ and % can be escaped in configparser.
2019-09-10 14:51:09 +02:00
Bernt Røskar Brenna 734f1202a5 closes bpo-25461: Update os.walk() docstring to match the online docs. (GH-11836) 2019-09-10 13:43:58 +01:00
Emmanuel Arias 9008be303a bpo-36373: Deprecate explicit loop parameter in all public asyncio APIs [queue] (GH-13950)
This PR deprecate explicit loop parameters in all public asyncio APIs

This issues is split to be easier to review.

fourth step: queue.py





https://bugs.python.org/issue36373
2019-09-10 04:46:12 -07:00
Jeroen Demeyer 57ea335606 bpo-37619: update_one_slot() should not ignore wrapper descriptors for wrong type (GH-14836) 2019-09-10 04:21:57 -07:00
Petr Viktorin f958377b67 bpo-37499: Test various C calling conventions (GH-15776)
Add functions with various calling conventions to `_testcapi`, expose them as module-level functions, bound methods, class methods, and static methods, and test calling them and introspecting them through GDB.


https://bugs.python.org/issue37499


Co-authored-by: Jeroen Demeyer <J.Demeyer@UGent.be>
Automerge-Triggered-By: @pganssle
2019-09-10 04:21:09 -07:00
Lisa Roach f1a297acb6
bpo-37251: Removes __code__ check from _is_async_obj. (GH-15830) 2019-09-10 12:18:40 +01:00
Dino Viehland 5a7d2e11aa bpo-38069: Convert _posixsubprocess to PEP-384 (GH-15780)
Summary:
Eliminate uses of `_Py_IDENTIFIER` from `_posixsubprocess`, replacing them with interned strings.

Also tries to find an existing version of the module, which will allow subinterpreters.



https://bugs.python.org/issue38069
2019-09-10 04:01:20 -07:00
Emmanuel Arias 537877d85d bpo-36373: Deprecate explicit loop parameter in all public asyncio APIs [locks] (GH-13920)
This PR deprecate explicit loop parameters in all public asyncio APIs

This issues is split to be easier to review.

Third step: locks.py





https://bugs.python.org/issue36373
2019-09-10 03:55:07 -07:00
Jeroen Demeyer 9669931e5e bpo-36971: add subsections in C API "Common Object Structures" page (#13446) 2019-09-10 11:41:59 +01:00
Benjamin Peterson f1c19031fd bpo-38068: Clean up gettimeofday configure logic. (GH-15775)
Assume gettimeofday exists and takes two arguments.
2019-09-10 03:37:59 -07:00
Xtreak c8dfa7333d bpo-37052: Add examples for mocking async iterators and context managers (GH-14660)
Add examples for mocking asynchronous iterators and asynchronous context managers.


https://bugs.python.org/issue37052
2019-09-10 03:37:17 -07:00
Dino Viehland bd0c7a12d9 bpo-38071: Make termios PEP-384 compatible (GH-15785)
Make the termios module PEP-384 compatible.
2019-09-10 03:33:30 -07:00
Dino Viehland 40a5313edf bpo-38072: PEP-384 grpmodule (GH-15788)
Make the grp module PEP-384 compliant.
2019-09-10 03:30:36 -07:00
Kenta Murata 9e61066355 Fix calling order of PyEval_InitThreads. (GH-4602)
As described in Doc/c-api/init.rst, PyEval_InitThreads() cannot be called
before Py_Initialize() function.
2019-09-10 11:29:56 +01:00
Benjamin Peterson e45b217ae0
Remove macOS tests from Travis. (GH-15809)
Azure runs macOS, so we don't need Travis to do it.
2019-09-10 11:28:29 +01:00
hliu0 8e7ff6aba3 Skip zoneinfo tests on VxWorks (#13535) 2019-09-10 11:28:11 +01:00
Dino Viehland a1ffad0719 bpo-38074: Make zlib extension module PEP-384 compatible (GH-15792)
Updated zlibmodule.c to be PEP 384 compliant.
2019-09-10 03:27:03 -07:00
Dino Viehland 4f384af067 bpo-38076: Make struct module PEP-384 compatible (#15805)
* PEP-384 _struct

* More PEP-384 fixes for _struct

Summary: Add a couple of more fixes for `_struct` that were previously missed such as removing `tp_*` accessors and using `PyBytesWriter` instead of calling `PyBytes_FromStringAndSize` with `NULL`. Also added a test to confirm that `iter_unpack` type is still uninstantiable.

* 📜🤖 Added by blurb_it.
2019-09-10 03:18:37 -07:00
Serhiy Storchaka 43c9731334 bpo-38083: Minor improvements in asdl_c.py and Python-ast.c. (GH-15824)
* Use the const qualifier for constant C strings.
* Intern field and attribute names.
* Temporary incref a borrowed reference to a list item.
2019-09-10 03:02:30 -07:00
dalgarno 359143c686 Fix typo in dict object comment (#15814) 2019-09-10 10:45:07 +01:00