]> granicus.if.org Git - python/log
python
7 years agobpo-30579: Allow TracebackType creation and tb_next mutation from Python (GH-4793)
Nathaniel J. Smith [Sun, 7 Jan 2018 13:30:18 +0000 (05:30 -0800)]
bpo-30579: Allow TracebackType creation and tb_next mutation from Python (GH-4793)

Third party projects may wish to hide their own internal machinery in
order to present more comprehensible tracebacks to end users
(e.g. Jinja2 and Trio both do this).

Previously such projects have had to rely on ctypes to do so:

  https://github.com/pallets/jinja/blob/fe3dadacdf4cf411d0a5b6bbd4d5234697a28af2/jinja2/debug.py#L345
  https://github.com/python-trio/trio/blob/1e86b1aee8c0c759f6f239ae53a05d0d3963c629/trio/_core/_multierror.py#L296

This provides a Python level API for creating and modifying real
Traceback objects, allowing tracebacks to be edited at runtime.

Patch by Nathaniel Smith.

7 years agoFix dataclasses docstring typo. (gh-5118)
Eric V. Smith [Sun, 7 Jan 2018 13:19:45 +0000 (08:19 -0500)]
Fix dataclasses docstring typo. (gh-5118)

7 years agoKill the AppVeyor file whitelist (GH-5121)
Zachary Ware [Sun, 7 Jan 2018 02:41:17 +0000 (20:41 -0600)]
Kill the AppVeyor file whitelist (GH-5121)

It's more trouble than it's worth, since AppVeyor only checks the HEAD commit of a PR rather than the full diff against the base branch to decide which files changed.

7 years agobpo-32282: Remove unnecessary check for `VersionHelpers.h` in `socketmodule.c` on...
Max Bélanger [Sun, 7 Jan 2018 02:05:18 +0000 (18:05 -0800)]
bpo-32282: Remove unnecessary check for `VersionHelpers.h` in `socketmodule.c` on Windows

7 years ago bpo-32279: Add additional params to make_dataclass(), pass through to dataclass...
Eric V. Smith [Sat, 6 Jan 2018 22:09:58 +0000 (17:09 -0500)]
 bpo-32279: Add additional params to make_dataclass(), pass through to dataclass(). (gh-5117)

7 years agobpo-32278: Allow dataclasses.make_dataclass() to omit type information. (gh-5115)
Eric V. Smith [Sat, 6 Jan 2018 21:14:03 +0000 (16:14 -0500)]
bpo-32278: Allow dataclasses.make_dataclass() to omit type information. (gh-5115)

7 years agobpo-32499: Add dataclasses.is_dataclass(obj), which returns True if obj is a dataclas...
Eric V. Smith [Sat, 6 Jan 2018 17:41:53 +0000 (12:41 -0500)]
bpo-32499: Add dataclasses.is_dataclass(obj), which returns True if obj is a dataclass or an instance of one. (#5113)

7 years agobpo-31993: Do not allocate large temporary buffers in pickle dump. (#4353)
Olivier Grisel [Sat, 6 Jan 2018 15:18:54 +0000 (16:18 +0100)]
bpo-31993: Do not allocate large temporary buffers in pickle dump. (#4353)

The picklers do no longer allocate temporary memory when dumping large
bytes and str objects into a file object. Instead the data is
directly streamed into the underlying file object.

Previously the C implementation would buffer all content and issue a
single call to file.write() at the end of the dump. With protocol 4
this behavior has changed to issue one call to file.write() per frame.

The Python pickler with protocol 4 now dumps each frame content as a
memoryview to an IOBytes instance that is never reused and the
memoryview is no longer released after the call to write. This makes it
possible for the file object to delay access to the memoryview of
previous frames without forcing any additional memory copy as was
already possible with the C pickler.

7 years agoCleanup grammar in unittest.mock.seal documentation (#5107)
Paul Ganssle [Sat, 6 Jan 2018 13:25:34 +0000 (08:25 -0500)]
Cleanup grammar in unittest.mock.seal documentation (#5107)

7 years agobpo-32206: Pdb can now run modules (GH-4752)
Mario Corchero [Sat, 6 Jan 2018 07:53:05 +0000 (07:53 +0000)]
bpo-32206: Pdb can now run modules (GH-4752)

Add a new argument "-m" to the pdb module to allow
users to run `python -m pdb -m my_module_name`.

This relies on private APIs in the runpy module to work,
but we can get away with that since they're both part of
the standard library and can be updated together if
the runpy internals get refactored.

7 years agobpo-29137: Remove fpectl module (#4789)
Nathaniel J. Smith [Sat, 6 Jan 2018 07:15:34 +0000 (23:15 -0800)]
bpo-29137: Remove fpectl module (#4789)

This module has never been enabled by default, never worked correctly
on x86-64, and caused ABI problems that caused C extension
compatibility. See bpo-29137 for details/discussion.

7 years agobpo-32390: Fix compilation failure on AIX after f_fsid was added to os.statvfs()...
Michael Felt [Fri, 5 Jan 2018 12:01:58 +0000 (13:01 +0100)]
bpo-32390: Fix compilation failure on AIX after f_fsid was added to os.statvfs() (#4972)

7 years agobpo-31699 Deadlocks in `concurrent.futures.ProcessPoolExecutor` with pickling error...
Thomas Moreau [Fri, 5 Jan 2018 10:15:54 +0000 (11:15 +0100)]
bpo-31699 Deadlocks in `concurrent.futures.ProcessPoolExecutor` with pickling error (#3895)

Fix deadlocks in :class:`concurrent.futures.ProcessPoolExecutor` when task arguments or results cause pickling or unpickling errors.
This should make sure that calls to the :class:`ProcessPoolExecutor` API always eventually return.

7 years agoadvance copyright years to 2018 (#5094)
Benjamin Peterson [Fri, 5 Jan 2018 06:34:19 +0000 (22:34 -0800)]
advance copyright years to 2018 (#5094)

7 years agobpo-32226: Make __class_getitem__ an automatic class method. (#5098)
Serhiy Storchaka [Thu, 4 Jan 2018 22:21:41 +0000 (00:21 +0200)]
bpo-32226: Make __class_getitem__ an automatic class method. (#5098)

7 years agobpo-31672: Restore the former behavior when override flags in Template. (#5099)
Serhiy Storchaka [Thu, 4 Jan 2018 17:20:11 +0000 (19:20 +0200)]
bpo-31672: Restore the former behavior when override flags in Template. (#5099)

Overriding flags to 0 will make the default pattern matching only
lower case letters.

7 years agoFix outdated comment in typeobject.c (GH-5090)
Berker Peksag [Thu, 4 Jan 2018 10:24:45 +0000 (13:24 +0300)]
Fix outdated comment in typeobject.c (GH-5090)

The comment was added in 3abca127fe1565ec80f6b0a1ae48d65186ad887d.
In d78448e912126410117723c7d240bbdfff06df16, it was changed to
use PyArg_ParseTuple instead.

7 years agobpo-31778: Make ast.literal_eval() more strict. (#4035)
Serhiy Storchaka [Thu, 4 Jan 2018 09:15:39 +0000 (11:15 +0200)]
bpo-31778: Make ast.literal_eval() more strict. (#4035)

Addition and subtraction of arbitrary numbers no longer allowed.

7 years agobpo-32308: Replace empty matches adjacent to a previous non-empty match in re.sub...
Serhiy Storchaka [Thu, 4 Jan 2018 09:06:13 +0000 (11:06 +0200)]
bpo-32308: Replace empty matches adjacent to a previous non-empty match in re.sub(). (#4846)

7 years agobpo-32482: Fix suspicious code in tests for syntax and grammar. (#5086)
Serhiy Storchaka [Thu, 4 Jan 2018 08:36:35 +0000 (10:36 +0200)]
bpo-32482: Fix suspicious code in tests for syntax and grammar. (#5086)

7 years agoIgnore importlib.h for automatic review requests from the import team. (GH-5087)
Brett Cannon [Wed, 3 Jan 2018 19:32:22 +0000 (11:32 -0800)]
Ignore importlib.h for automatic review requests from the import team. (GH-5087)

Otherwise the import team gets flagged for reviews any time the bytecode for
importlib.h changes (e.g new bytecode, optimizations, etc.).

7 years agobpo-32452: clarify term 'brackets' in generator tutorial (#5079)
Emily Morehouse [Tue, 2 Jan 2018 01:34:53 +0000 (18:34 -0700)]
bpo-32452: clarify term 'brackets' in generator tutorial (#5079)

Updates documentation for generator expressions in classes tutorial: Clarify usage of ambiguous term "brackets" by replacing with "square brackets". Updated subsequent lines to respect line breaks. (#5079)

7 years agobpo-32478: Add tests for 'break' and 'return' inside 'finally' clause. (#5078)
Serhiy Storchaka [Tue, 2 Jan 2018 00:38:35 +0000 (02:38 +0200)]
bpo-32478: Add tests for 'break' and 'return' inside 'finally' clause. (#5078)

7 years agobpo-32416: Add two new tests in test_sys_settrace. (#5072)
Serhiy Storchaka [Mon, 1 Jan 2018 17:39:38 +0000 (19:39 +0200)]
bpo-32416: Add two new tests in test_sys_settrace. (#5072)

Move other test to more proper place.

7 years agobpo-32468: Better frame repr() (#5067)
Antoine Pitrou [Sun, 31 Dec 2017 21:35:22 +0000 (22:35 +0100)]
bpo-32468: Better frame repr() (#5067)

bpo-32468: Better frame repr()

7 years agocloses bpo-32460: ensure all non-static globals have initializers (#5061)
Benjamin Peterson [Sun, 31 Dec 2017 18:04:13 +0000 (10:04 -0800)]
closes bpo-32460: ensure all non-static globals have initializers (#5061)

7 years agoAdd missing backslashes in PCbuild bat files (GH-5056)
Zachary Ware [Sat, 30 Dec 2017 23:17:36 +0000 (17:17 -0600)]
Add missing backslashes in PCbuild bat files (GH-5056)

7 years agobpo-32399: Starting with AIX6.1 there is support in libc.a for uuid (RFC4122) (#4974)
Michael Felt [Sat, 30 Dec 2017 21:39:20 +0000 (22:39 +0100)]
bpo-32399: Starting with AIX6.1 there is support in libc.a for uuid (RFC4122) (#4974)

Starting with AIX6.1 there is support in libc.a for uuid (RFC4122)
This patch provides the changes needed for this integration with the OS.

On AIX the base function is uuid_create() rather than uuid_generate_time()
The AIX uuid_t typedef is more aligned to the UUID field based definition
while the Linux typedef that is more aligned with UUID bytes
(or perhaps UUID bytes_le) definitions.

7 years agobpo-32458: Temporarily mask start-tls proactor test on Windows (#5054)
Yury Selivanov [Sat, 30 Dec 2017 20:40:20 +0000 (15:40 -0500)]
bpo-32458: Temporarily mask start-tls proactor test on Windows (#5054)

7 years agobpo-32248 - Implement importlib.resources (#4911)
Barry Warsaw [Sat, 30 Dec 2017 20:18:06 +0000 (15:18 -0500)]
bpo-32248 - Implement importlib.resources (#4911)

Port importlib_resources to importlib.resources

7 years agobpo-32418: Postfix, raise NotImplementdError and close resources in tests (#5052)
Andrew Svetlov [Sat, 30 Dec 2017 16:52:56 +0000 (18:52 +0200)]
bpo-32418: Postfix, raise NotImplementdError and close resources in tests (#5052)

7 years agobpo-32418: Add get_loop() method on Server, AbstractServer classes (#4997)
Srinivas Reddy Thatiparthy (శ్రీనివాస్ రెడ్డి తాటిపర్తి) [Sat, 30 Dec 2017 15:09:32 +0000 (20:39 +0530)]
bpo-32418: Add get_loop() method on Server, AbstractServer classes (#4997)

* Add abstract get_loop() method to Server, AbstractServer classes.
* Add test cases for get_loop() method in Server, AbstractServer classes
* Add documentation for get_loop() method

7 years agoFix typo (#5049)
Andrew Svetlov [Sat, 30 Dec 2017 13:40:27 +0000 (15:40 +0200)]
Fix typo (#5049)

7 years agobpo-32439: Clean up the code for compiling comparison expressions. (#5029)
Serhiy Storchaka [Sat, 30 Dec 2017 07:47:42 +0000 (09:47 +0200)]
bpo-32439: Clean up the code for compiling comparison expressions. (#5029)

7 years agobpo-23749: Implement loop.start_tls() (#5039)
Yury Selivanov [Sat, 30 Dec 2017 05:35:36 +0000 (00:35 -0500)]
bpo-23749: Implement loop.start_tls() (#5039)

7 years agoreturn the new file descriptor from os.dup2 (closes bpo-32441) (#5041)
Benjamin Peterson [Fri, 29 Dec 2017 21:13:06 +0000 (13:13 -0800)]
return the new file descriptor from os.dup2 (closes bpo-32441) (#5041)

7 years agobpo-32427: Expose dataclasses.MISSING object. (#5045)
Eric V. Smith [Fri, 29 Dec 2017 18:59:58 +0000 (13:59 -0500)]
bpo-32427: Expose dataclasses.MISSING object. (#5045)

7 years agoremove unused import (#5040)
Benjamin Peterson [Fri, 29 Dec 2017 07:24:40 +0000 (23:24 -0800)]
remove unused import (#5040)

7 years agomake PatternCompiler use the packaged grammar if possible (more bpo-24960) (#5034)
Benjamin Peterson [Fri, 29 Dec 2017 01:54:12 +0000 (17:54 -0800)]
make PatternCompiler use the packaged grammar if possible (more bpo-24960) (#5034)

7 years agobpo-32440: Update the docs URL to https in help() (GH-5030)
oldk [Thu, 28 Dec 2017 14:37:46 +0000 (22:37 +0800)]
bpo-32440: Update the docs URL to https in help() (GH-5030)

In pydoc.py, the reference to Python' documentation was in http.
The link has been updated to use https.

7 years agoFix minor spelling error in test_sys_settrace.py. (#5025)
gfyoung [Thu, 28 Dec 2017 08:28:25 +0000 (00:28 -0800)]
Fix minor spelling error in test_sys_settrace.py. (#5025)

7 years agobpo-32416: Refactor tests for the f_lineno setter and add new tests. (#4991)
Serhiy Storchaka [Tue, 26 Dec 2017 22:38:56 +0000 (00:38 +0200)]
bpo-32416: Refactor tests for the f_lineno setter and add new tests. (#4991)

7 years agobpo-32259: Make a TypeError message when unpack non-iterable more specific. (#4903)
Serhiy Storchaka [Tue, 26 Dec 2017 10:30:41 +0000 (12:30 +0200)]
bpo-32259: Make a TypeError message when unpack non-iterable more specific. (#4903)

7 years agobpo-26133: Fix typos (#5010)
Andrew Svetlov [Tue, 26 Dec 2017 09:53:38 +0000 (11:53 +0200)]
bpo-26133: Fix typos (#5010)

* Fix typos
* Change warning text
* Add test

7 years agobpo-31721: Allow Future._log_traceback to only be set to False (#5009)
Yury Selivanov [Mon, 25 Dec 2017 21:16:10 +0000 (16:16 -0500)]
bpo-31721: Allow Future._log_traceback to only be set to False (#5009)

7 years agobpo-32422: Reduce lru_cache memory usage (GH-5008)
INADA Naoki [Mon, 25 Dec 2017 17:03:24 +0000 (02:03 +0900)]
bpo-32422: Reduce lru_cache memory usage (GH-5008)

7 years agobpo-32363: Disable Task.set_exception() and Task.set_result() (#4923)
Yury Selivanov [Mon, 25 Dec 2017 15:48:15 +0000 (10:48 -0500)]
bpo-32363: Disable Task.set_exception() and Task.set_result() (#4923)

7 years agobpo-32372: Move __debug__ optimization to the AST level. (#4925)
Serhiy Storchaka [Mon, 25 Dec 2017 10:47:50 +0000 (12:47 +0200)]
bpo-32372: Move __debug__ optimization to the AST level. (#4925)

7 years agobpo-29084: Exclude C API for OrderedDict from the limited C API. (#4900)
Serhiy Storchaka [Mon, 25 Dec 2017 00:08:42 +0000 (02:08 +0200)]
bpo-29084: Exclude C API for OrderedDict from the limited C API. (#4900)

7 years agobpo-26133: Clear signals list on interpreter finalizing (#5002)
Andrew Svetlov [Sun, 24 Dec 2017 11:50:03 +0000 (13:50 +0200)]
bpo-26133: Clear signals list on interpreter finalizing (#5002)

7 years agobpo-32402: io: Add missing NULL check. (GH-4971)
INADA Naoki [Sun, 24 Dec 2017 01:29:19 +0000 (10:29 +0900)]
bpo-32402: io: Add missing NULL check. (GH-4971)

_PyUnicode_FromId() may return NULL.

Reported by coverity scan: CID 14268681426867.

7 years agobpo-32415: Fix "error is already set" (#4999)
Yury Selivanov [Sat, 23 Dec 2017 21:29:26 +0000 (16:29 -0500)]
bpo-32415: Fix "error is already set" (#4999)

7 years agoFix check for run_in_executor on closed loop. (#4996)
Andrew Svetlov [Sat, 23 Dec 2017 21:03:27 +0000 (23:03 +0200)]
Fix check for run_in_executor on closed loop. (#4996)

7 years agobpo-32415: Add more tests (#4995)
Yury Selivanov [Sat, 23 Dec 2017 20:42:27 +0000 (15:42 -0500)]
bpo-32415: Add more tests (#4995)

7 years agobpo-32357: Use PySet_GET_SIZE macro in _is_coroutine() from _asynciomodule.c (#4990)
Andrew Svetlov [Sat, 23 Dec 2017 20:06:46 +0000 (22:06 +0200)]
bpo-32357: Use PySet_GET_SIZE macro in _is_coroutine() from _asynciomodule.c  (#4990)

7 years agobpo-32415: Add asyncio.Task.get_loop() and Future.get_loop() (#4992)
Yury Selivanov [Sat, 23 Dec 2017 20:04:15 +0000 (15:04 -0500)]
bpo-32415: Add asyncio.Task.get_loop() and Future.get_loop() (#4992)

7 years agobpo-32357: Fix tests in refleak mode (#4989)
Yury Selivanov [Sat, 23 Dec 2017 17:44:29 +0000 (12:44 -0500)]
bpo-32357: Fix tests in refleak mode (#4989)

7 years agobpo-26439: Convert %s in Lib/ctypes/_aix.py to f-strings. (GH-4986)
Mariatta [Sat, 23 Dec 2017 07:39:03 +0000 (23:39 -0800)]
bpo-26439: Convert %s in Lib/ctypes/_aix.py to f-strings. (GH-4986)

7 years agocorrect wording (#4983)
Benjamin Peterson [Sat, 23 Dec 2017 04:48:13 +0000 (20:48 -0800)]
correct wording (#4983)

7 years agobpo-24960: use pkgutil.get_data in lib2to3 to read pickled grammar files (#4977)
Benjamin Peterson [Fri, 22 Dec 2017 20:18:33 +0000 (12:18 -0800)]
bpo-24960: use pkgutil.get_data in lib2to3 to read pickled grammar files (#4977)

This is more complicated than it should be because we need to preserve the
useful mtime-based regeneration feature that lib2to3.pgen2.driver.load_grammar
has. We only look for the pickled grammar file with pkgutil.get_data and only if
the source file does not exist.

7 years agoremove the dynload_next.c file (closes bpo-32386) (#4957)
Benjamin Peterson [Fri, 22 Dec 2017 05:43:09 +0000 (21:43 -0800)]
remove the dynload_next.c file (closes bpo-32386) (#4957)

7 years agobpo-29240: Skip test_readline.test_nonascii() (#4968)
Victor Stinner [Thu, 21 Dec 2017 23:09:26 +0000 (00:09 +0100)]
bpo-29240: Skip test_readline.test_nonascii() (#4968)

Skip the test which fails on FreeBSD with POSIX locale.

Skip the test to fix FreeBSD buildbots, until a fix can be found, so
the buildbots can catch other regressions.

7 years agobpo-20891: Skip test_embed.test_bpo20891() (#4967)
Victor Stinner [Thu, 21 Dec 2017 23:05:05 +0000 (00:05 +0100)]
bpo-20891: Skip test_embed.test_bpo20891() (#4967)

Skip the test failing randomly because of known race condition.

Skip the test to fix macOS buildbots until a decision is made on the
proper fix for the race condition.

7 years agobpo-32030: Add _Py_FindEnvConfigValue() (#4963)
Victor Stinner [Thu, 21 Dec 2017 15:49:13 +0000 (16:49 +0100)]
bpo-32030: Add _Py_FindEnvConfigValue() (#4963)

Add a new _Py_FindEnvConfigValue() function: code shared between
Windows and Unix implementations of _PyPathConfig_Calculate() to read
the pyenv.cfg file.

_Py_FindEnvConfigValue() now uses _Py_DecodeUTF8_surrogateescape()
instead of using a Python Unicode string, the Python API must not be
used early during Python initialization. Same change in Unix
search_for_exec_prefix(): use _Py_DecodeUTF8_surrogateescape().

Cleanup also encode_current_locale(): PyMem_RawFree/PyMem_Free can be
called with NULL.

Fix also "NUL byte" => "NULL byte" typo.

7 years agobpo-32030: Add _Py_EncodeLocaleRaw() (#4961)
Victor Stinner [Thu, 21 Dec 2017 15:20:32 +0000 (16:20 +0100)]
bpo-32030: Add _Py_EncodeLocaleRaw() (#4961)

Replace Py_EncodeLocale() with _Py_EncodeLocaleRaw() in:

* _Py_wfopen()
* _Py_wreadlink()
* _Py_wrealpath()
* _Py_wstat()
* pymain_open_filename()

These functions are called early during Python intialization, only
the RAW memory allocator must be used.

7 years agobpo-26133: Dont unsubscribe signals in UNIX even loop on interpreter shutdown (#4956)
Andrew Svetlov [Thu, 21 Dec 2017 15:06:46 +0000 (17:06 +0200)]
bpo-26133: Dont unsubscribe signals in UNIX even loop on interpreter shutdown (#4956)

7 years agobpo-32030: Add _Py_EncodeUTF8_surrogateescape() (#4960)
Victor Stinner [Thu, 21 Dec 2017 14:45:16 +0000 (15:45 +0100)]
bpo-32030: Add _Py_EncodeUTF8_surrogateescape() (#4960)

Py_EncodeLocale() now uses _Py_EncodeUTF8_surrogateescape(), instead
of using temporary unicode and bytes objects. So Py_EncodeLocale()
doesn't use the Python C API anymore.

7 years agobpo-32323: urllib.parse.urlsplit() must not lowercase() IPv6 scope value (#4867)
Коренберг Марк [Thu, 21 Dec 2017 12:16:17 +0000 (17:16 +0500)]
bpo-32323: urllib.parse.urlsplit() must not lowercase() IPv6 scope value (#4867)

7 years agoFix trivial typo in pickle.rst (#4955)
Sebastian Pucilowski [Thu, 21 Dec 2017 09:00:49 +0000 (20:00 +1100)]
Fix trivial typo in pickle.rst (#4955)

7 years agobpo-15873: Implement [date][time].fromisoformat (#4699)
Paul Ganssle [Thu, 21 Dec 2017 05:33:49 +0000 (00:33 -0500)]
bpo-15873: Implement [date][time].fromisoformat (#4699)

Closes bpo-15873.

7 years agobpo-15216: io: TextIOWrapper.reconfigure() accepts encoding, errors and newline ...
INADA Naoki [Thu, 21 Dec 2017 00:59:53 +0000 (09:59 +0900)]
bpo-15216: io: TextIOWrapper.reconfigure() accepts encoding, errors and newline (GH-2343)

7 years agobpo-32030: Fix usage of memory allocators (#4953)
Victor Stinner [Wed, 20 Dec 2017 22:41:38 +0000 (23:41 +0100)]
bpo-32030: Fix usage of memory allocators (#4953)

* _Py_InitializeCore() doesn't call _PyMem_SetupAllocators() anymore
  if the PYTHONMALLOC environment variable is not set.
* pymain_cmdline() now sets the allocator to the default, instead of
  setting the allocator in subfunctions.
* Py_SetStandardStreamEncoding() now calls
  _PyMem_SetDefaultAllocator() to get a known allocator, to be able
  to release the memory with the same allocator.

7 years agocorrect the typos (#4950)
Srinivas Reddy Thatiparthy (శ్రీనివాస్ రెడ్డి తాటిపర్తి) [Wed, 20 Dec 2017 21:36:10 +0000 (03:06 +0530)]
correct the typos (#4950)

7 years agobpo-32030: Complete _PyCoreConfig_Read() (#4946)
Victor Stinner [Wed, 20 Dec 2017 18:36:46 +0000 (19:36 +0100)]
bpo-32030: Complete _PyCoreConfig_Read() (#4946)

* Add _PyCoreConfig.install_signal_handlers
* Remove _PyMain.config: _PyMainInterpreterConfig usage is now
  restricted to pymain_init_python_main().
* Rename _PyMain.core_config to _PyMain.config
* _PyMainInterpreterConfig_Read() now creates the xoptions dictionary
   from the core config
* Fix _PyMainInterpreterConfig_Read(): don't replace xoptions and
  argv if they are already set.

7 years agobpo-29970: Make ssh_handshake_timeout None by default (#4939)
Andrew Svetlov [Wed, 20 Dec 2017 18:24:43 +0000 (20:24 +0200)]
bpo-29970: Make ssh_handshake_timeout None by default (#4939)

* Make ssh_handshake_timeout None by default.
* Raise ValueError if ssl_handshake_timeout is used without ssl.
* Raise ValueError if ssl_handshake_timeout is not positive.

7 years agobpo-32306: Clarify c.f.Executor.map() documentation (#4947)
Antoine Pitrou [Wed, 20 Dec 2017 18:06:20 +0000 (19:06 +0100)]
bpo-32306: Clarify c.f.Executor.map() documentation (#4947)

The built-in map() function collects function arguments lazily, but concurrent.futures.Executor.map() does so eagerly.

7 years agobpo-32385: Clean up the C3 MRO algorithm implementation. (#4942)
Serhiy Storchaka [Wed, 20 Dec 2017 17:21:02 +0000 (19:21 +0200)]
bpo-32385: Clean up the C3 MRO algorithm implementation. (#4942)

Use tuples and raw arrays instead of lists.

7 years agobpo-32030: Add _PyCoreConfig.warnoptions (#4936)
Victor Stinner [Wed, 20 Dec 2017 17:00:19 +0000 (18:00 +0100)]
bpo-32030: Add _PyCoreConfig.warnoptions (#4936)

Merge _PyCoreConfig_ReadEnv() into _PyCoreConfig_Read(), and
_Py_CommandLineDetails usage is now restricted to pymain_cmdline().

Changes:

* _PyCoreConfig: Add nxoption, xoptions, nwarnoption and warnoptions
* Add _PyCoreConfig.program: argv[0] or ""
* Move filename, command, module and xoptions from
  _Py_CommandLineDetails to _PyMain. xoptions _Py_OptList becomes
  (int, wchar_t**) list.
* Add pymain_cmdline() function
* Rename copy_argv() to copy_wstrlist(). Rename clear_argv() to
  clear_wstrlist(). Remove _Py_OptList structure: use (int,
  wchar_t**) list instead.
* Rename pymain_set_flag_from_env() to pymain_get_env_flag()
* Rename pymain_set_flags_from_env() to pymain_get_env_flags()
* _PyMainInterpreterConfig_Read() now creates the warnoptions from
  _PyCoreConfig.warnoptions
* Inline pymain_add_warning_dev_mode() and
  pymain_add_warning_bytes_flag() into config_init_warnoptions()
* Inline pymain_get_program_name() into _PyCoreConfig_Read()
* _Py_CommandLineDetails: Replace warning_options with nwarnoption
  and warnoptions. Replace env_warning_options with nenv_warnoption
  and env_warnoptions.
* pymain_warnings_envvar() now has a single implementation for
  Windows and Unix: use config_get_env_var_dup() to also get the
  variable as wchar_t* on Unix.

7 years agobpo-32379: Faster MRO computation for single inheritance (#4932)
Antoine Pitrou [Wed, 20 Dec 2017 14:58:21 +0000 (15:58 +0100)]
bpo-32379: Faster MRO computation for single inheritance (#4932)

* bpo-32379: Faster MRO computation for single inheritance

7 years agobpo-31901: atexit callbacks should be run at subinterpreter shutdown (#4611)
Marcel Plch [Wed, 20 Dec 2017 10:17:58 +0000 (11:17 +0100)]
bpo-31901: atexit callbacks should be run at subinterpreter shutdown (#4611)

Change atexit behavior and PEP-489 multiphase init support.

7 years agobpo-32030: Cleanup pymain_main() (#4935)
Victor Stinner [Wed, 20 Dec 2017 00:41:59 +0000 (01:41 +0100)]
bpo-32030: Cleanup pymain_main() (#4935)

* Reorganize pymain_main() to make the code more flat
* Clear configurations before pymain_update_sys_path()
* Mark Py_FatalError() and _Py_FatalInitError() with _Py_NO_RETURN
* Replace _PyMain.run_code variable with a new RUN_CODE() macro
* Move _PyMain.cf into a local variable in pymain_run_python()

7 years agobpo-32030: Add _PyCoreConfig.argv (#4934)
Victor Stinner [Tue, 19 Dec 2017 22:48:17 +0000 (23:48 +0100)]
bpo-32030: Add _PyCoreConfig.argv (#4934)

* Add argc and argv to _PyCoreConfig
* _PyMainInterpreterConfig_Read() now builds its argv from
  _PyCoreConfig.arg
* Move _PyMain.env_warning_options into _Py_CommandLineDetails
* Reorder pymain_free()

7 years agoImprove the F-strings and format specifier documentation (GH-4931)
KatherineMichel [Tue, 19 Dec 2017 21:03:09 +0000 (15:03 -0600)]
Improve the F-strings and format specifier documentation (GH-4931)

Mention that the format-specifier mini language in f-strings
is the same one used by str.format.

7 years agobpo-29970: Add timeout for SSL handshake in asyncio
Neil Aspinall [Tue, 19 Dec 2017 19:45:42 +0000 (19:45 +0000)]
bpo-29970: Add timeout for SSL handshake in asyncio

10 seconds by default.

7 years agobpo-32377: improve __del__ docs and fix mention about resurrection (#4927)
Antoine Pitrou [Tue, 19 Dec 2017 18:48:45 +0000 (19:48 +0100)]
bpo-32377: improve __del__ docs and fix mention about resurrection (#4927)

* Fix #32377: improve __del__ docs and fix mention about resurrection

* Mention that CPython only calls __del__ once.

7 years agoFix GCC warning in _asynciomodule.c (#4928)
Zackery Spytz [Tue, 19 Dec 2017 18:48:13 +0000 (11:48 -0700)]
Fix GCC warning in _asynciomodule.c (#4928)

7 years agobpo-26439 Fix ctypes.util.find_library failure on AIX (#4507)
Michael Felt [Tue, 19 Dec 2017 12:58:49 +0000 (13:58 +0100)]
bpo-26439 Fix ctypes.util.find_library failure on AIX (#4507)

Implement find_library() support in ctypes/util for AIX.

Add some AIX specific tests.

7 years agobpo-29711: Fix stop_serving in proactor loop kill all listening servers (#431)
Julien Duponchelle [Tue, 19 Dec 2017 12:23:17 +0000 (13:23 +0100)]
bpo-29711: Fix stop_serving in proactor loop kill all listening servers (#431)

7 years agobpo-32355: Optimize asyncio.gather() (#4913)
Yury Selivanov [Tue, 19 Dec 2017 12:19:53 +0000 (07:19 -0500)]
bpo-32355: Optimize asyncio.gather() (#4913)

7 years agobpo-32357: Optimize asyncio.iscoroutine() for non-native coroutines (#4915)
Yury Selivanov [Tue, 19 Dec 2017 12:18:45 +0000 (07:18 -0500)]
bpo-32357: Optimize asyncio.iscoroutine() for non-native coroutines (#4915)

7 years agobpo-27456: Simplify sock type checks (#4922)
Yury Selivanov [Tue, 19 Dec 2017 11:44:37 +0000 (06:44 -0500)]
bpo-27456: Simplify sock type checks (#4922)

Recent sock.type fix (see bug 32331) makes sock.type checks simpler
in asyncio.

7 years agobpo-32030: Fix compiler warnings (#4921)
Victor Stinner [Tue, 19 Dec 2017 10:35:58 +0000 (11:35 +0100)]
bpo-32030: Fix compiler warnings (#4921)

Fix compiler warnings in Py_FinalizeEx(): only define variables if
they are needed, add #ifdef.

Other cleanup changes:

* _PyWarnings_InitWithConfig() is no more needed: call
  _PyWarnings_Init() instead.
* Inline pymain_init_main_interpreter() in its caller. This
  subfunction is no more justifed.

7 years agoImprove test coverage (#4924)
Andrew Svetlov [Tue, 19 Dec 2017 06:51:16 +0000 (08:51 +0200)]
Improve test coverage (#4924)

7 years agobpo-32331: Fix socket.type when SOCK_NONBLOCK is available (#4877)
Yury Selivanov [Tue, 19 Dec 2017 01:02:54 +0000 (20:02 -0500)]
bpo-32331: Fix socket.type when SOCK_NONBLOCK is available (#4877)

7 years agobpo-32030: Fix compilation on FreeBSD, #include <fenv.h> (#4919)
Victor Stinner [Mon, 18 Dec 2017 22:42:55 +0000 (23:42 +0100)]
bpo-32030: Fix compilation on FreeBSD, #include <fenv.h> (#4919)

* main.c: add missing #include <fenv.h> on FreeBSD
* indent also other #ifdef in main.c
* cleanup Programs/python.c

7 years agobpo-32356: idempotent pause_/resume_reading; new is_reading method. (#4914)
Yury Selivanov [Mon, 18 Dec 2017 22:03:23 +0000 (17:03 -0500)]
bpo-32356: idempotent pause_/resume_reading; new is_reading method. (#4914)

7 years agobpo-32369: test_subprocess: Fix pass_fds check in test_close_fds() (#4920)
izbyshev [Mon, 18 Dec 2017 20:26:49 +0000 (03:26 +0700)]
bpo-32369: test_subprocess: Fix pass_fds check in test_close_fds() (#4920)

The last part of test_close_fds() doesn't match its own comment.
The following assertion always holds because fds_to_keep and open_fds
are disjoint by construction.

self.assertFalse(remaining_fds & fds_to_keep & open_fds,
                 "Some fds not in pass_fds were left open")

Fix the code to match the message in the assertion.

7 years agoAdd @asvetlov to asyncio codeowners (#4917)
Andrew Svetlov [Mon, 18 Dec 2017 16:20:42 +0000 (18:20 +0200)]
Add @asvetlov to asyncio codeowners (#4917)

7 years agobpo-32365: Fix a reference leak when compile __debug__. (#4916)
Serhiy Storchaka [Mon, 18 Dec 2017 12:29:12 +0000 (14:29 +0200)]
bpo-32365: Fix a reference leak when compile __debug__. (#4916)

It was introduced in bpo-27169.

7 years agobpo-19764: Implemented support for subprocess.Popen(close_fds=True) on Windows (...
Segev Finer [Mon, 18 Dec 2017 09:28:19 +0000 (11:28 +0200)]
bpo-19764: Implemented support for subprocess.Popen(close_fds=True) on Windows (#1218)

Even though Python marks any handles it opens as non-inheritable there
is still a race when using `subprocess.Popen` since creating a process
with redirected stdio requires temporarily creating inheritable handles.
By implementing support for `subprocess.Popen(close_fds=True)` we fix
this race.

In order to implement this we use PROC_THREAD_ATTRIBUTE_HANDLE_LIST
which is available since Windows Vista. Which allows to pass an explicit
list of handles to inherit when creating a process.

This commit also adds `STARTUPINFO.lpAttributeList["handle_list"]`
which can be used to control PROC_THREAD_ATTRIBUTE_HANDLE_LIST
directly.