]> granicus.if.org Git - python/log
python
5 years agobpo-37035: Don't log OSError (GH-13548)
Andrew Svetlov [Mon, 27 May 2019 13:28:34 +0000 (16:28 +0300)]
bpo-37035: Don't log OSError (GH-13548)

https://bugs.python.org/issue37035

5 years agobpo-37047: Refactor AsyncMock setup logic for autospeccing (GH-13574)
Xtreak [Mon, 27 May 2019 12:56:23 +0000 (18:26 +0530)]
bpo-37047: Refactor AsyncMock setup logic for autospeccing (GH-13574)

Handle late binding and attribute access in unittest.mock.AsyncMock
setup for autospeccing.

5 years agobpo-32528: Make asyncio.CancelledError a BaseException. (GH-13528)
Yury Selivanov [Mon, 27 May 2019 12:45:12 +0000 (14:45 +0200)]
bpo-32528: Make asyncio.CancelledError a BaseException. (GH-13528)

This will address the common mistake many asyncio users make:
an "except Exception" clause breaking Tasks cancellation.

In addition to this change, we stop inheriting asyncio.TimeoutError
and asyncio.InvalidStateError from their concurrent.futures.*
counterparts.  There's no point for these exceptions to share the
inheritance chain.

In 3.9 we'll focus on implementing supervisors and cancel scopes,
which should allow better handling of all exceptions, including
SystemExit and KeyboardInterrupt

5 years agobpo-37028: asyncio REPL; activated via 'python -m asyncio'. (GH-13472)
Yury Selivanov [Mon, 27 May 2019 11:42:29 +0000 (13:42 +0200)]
bpo-37028: asyncio REPL; activated via 'python -m asyncio'. (GH-13472)

This makes it easy to play with asyncio APIs with simply
using async/await in the REPL.

5 years agobpo-36829: Add _PyErr_WriteUnraisableMsg() (GH-13488)
Victor Stinner [Mon, 27 May 2019 06:57:14 +0000 (08:57 +0200)]
bpo-36829: Add _PyErr_WriteUnraisableMsg() (GH-13488)

* sys.unraisablehook: add 'err_msg' field to UnraisableHookArgs.
* Use _PyErr_WriteUnraisableMsg() in _ctypes _DictRemover_call()
  and gc delete_garbage().

5 years agoAdd one more test for typing.Final (GH-13588)
Ivan Levkivskyi [Sun, 26 May 2019 23:54:13 +0000 (00:54 +0100)]
Add one more test for typing.Final (GH-13588)

5 years agobpo-36772 Allow lru_cache to be used as decorator without making a function call...
Raymond Hettinger [Sun, 26 May 2019 18:27:35 +0000 (11:27 -0700)]
bpo-36772 Allow lru_cache to be used as decorator without making a function call (GH-13048)

5 years agobpo-37053: handle strings like u"bar" correctly in Tools/parser/unparse.py (GH-13583)
Chih-Hsuan Yen [Sun, 26 May 2019 17:08:20 +0000 (01:08 +0800)]
bpo-37053: handle strings like u"bar" correctly in Tools/parser/unparse.py (GH-13583)

Constant.kind is added in https://bugs.python.org/issue36280.
Current possible values for Constant.kind are "u" or None.

For r'bar' and b'bar', Constant.kind value is None, so there's no need
for special handling.

https://bugs.python.org/issue37053

5 years agobpo-36785: PEP 574 implementation (GH-7076)
Antoine Pitrou [Sun, 26 May 2019 15:10:09 +0000 (17:10 +0200)]
bpo-36785: PEP 574 implementation (GH-7076)

5 years agoFix highlighting in importlib.metadata docs (GH-13575)
Anthony Sottile [Sun, 26 May 2019 14:30:52 +0000 (07:30 -0700)]
Fix highlighting in importlib.metadata docs (GH-13575)

5 years agobpo-28866: No type cache for types with specialized mro, invalidation is hard. (...
Julien Palard [Sun, 26 May 2019 14:25:47 +0000 (16:25 +0200)]
bpo-28866: No type cache for types with specialized mro, invalidation is hard. (#13157)

* No type cache for types with specialized mro, invalidation is hard.

* FIX: Don't disable method cache custom types that do not implement mro().

* fixing implem.

* Avoid storing error flags, also decref.

* news entry

* Clear as soon as we're getting an error.

* FIX: Reference leak.

5 years agobpo-37049: PEP 589: Add TypedDict to typing module (GH-13573)
Ivan Levkivskyi [Sun, 26 May 2019 08:39:24 +0000 (09:39 +0100)]
bpo-37049: PEP 589: Add TypedDict to typing module (GH-13573)

The implementation is straightforward and essentially is just copied from `typing_extensions`.

5 years agobpo-37046: PEP 586: Add Literal to typing module (#13572)
Ivan Levkivskyi [Sun, 26 May 2019 08:37:48 +0000 (09:37 +0100)]
bpo-37046: PEP 586: Add Literal to typing module (#13572)

The implementation is straightforward and essentially is just copied from `typing_extensions`.

5 years agobpo-37045: PEP 591: Add final qualifiers to typing module (GH-13571)
Ivan Levkivskyi [Sun, 26 May 2019 08:37:07 +0000 (09:37 +0100)]
bpo-37045: PEP 591: Add final qualifiers to typing module (GH-13571)

The implementation is straightforward, it just mimics `ClassVar` (since the latter is also a name/access qualifier, not really a type). Also it is essentially copied from `typing_extensions`.

5 years agobpo-37017: PyObject_CallMethodObjArgs uses LOAD_METHOD optimization (GH-13516)
Michael J. Sullivan [Sun, 26 May 2019 07:23:34 +0000 (00:23 -0700)]
bpo-37017: PyObject_CallMethodObjArgs uses LOAD_METHOD optimization (GH-13516)

Update PyObject_CallMethodObjArgs and _PyObject_CallMethodIdObjArgs
to use _PyObject_GetMethod to avoid creating a bound method object
in many cases.

On a microbenchmark of PyObject_CallMethodObjArgs calling a method on
an interpreted Python class, this optimization resulted in a 1.7x
speedup.

5 years agoDocs: FIX broken links. (GH-13491)
Julien Palard [Sat, 25 May 2019 18:02:24 +0000 (20:02 +0200)]
Docs: FIX broken links. (GH-13491)

5 years agobpo-34632 fix buildbots and remove artifact (GH-13566)
Jason R. Coombs [Sat, 25 May 2019 14:00:21 +0000 (10:00 -0400)]
bpo-34632 fix buildbots and remove artifact (GH-13566)

* bpo-34632: Also include the test data directory.

* bpo-34632: remove the framework resources artifacts, accidentally added in 1bbf7b661f (ccbccce)

5 years ago📝 Add a GitHub-specific security page (GH-13526)
Sviatoslav Sydorenko [Sat, 25 May 2019 10:03:45 +0000 (12:03 +0200)]
📝 Add a GitHub-specific security page (GH-13526)

* 📝 Add a GitHub-specific security page

It will show up @
https://github.com/python/cpython/security/policy
allowing to navigate users who get there from "Security" tab in the
GitHub repo to the full article explaining the security vulnerability
reporting practices.

Co-Authored-By: Hugo <hugovk@users.noreply.github.com>
5 years agobpo-34632: fix installation of importlib.metadata (#13563)
Chih-Hsuan Yen [Sat, 25 May 2019 08:09:35 +0000 (16:09 +0800)]
bpo-34632: fix installation of importlib.metadata (#13563)

5 years agobpo-37038: Make idlelib.run runnable; add test clause (GH-13560)
Terry Jan Reedy [Sat, 25 May 2019 01:59:53 +0000 (21:59 -0400)]
bpo-37038: Make idlelib.run runnable; add test clause (GH-13560)

5 years agobpo-34632: Add importlib.metadata (GH-12547)
Jason R. Coombs [Fri, 24 May 2019 23:59:01 +0000 (19:59 -0400)]
bpo-34632: Add importlib.metadata (GH-12547)

Add importlib.metadata module as forward port of the standalone importlib_metadata.

5 years agobpo-36829: Document test.support.catch_unraisable_exception() (GH-13554)
Victor Stinner [Fri, 24 May 2019 22:09:38 +0000 (00:09 +0200)]
bpo-36829: Document test.support.catch_unraisable_exception() (GH-13554)

catch_unraisable_exception() now also removes its 'unraisable'
attribute at the context manager exit.

5 years agobpo-37032: Add CodeType.replace() method (GH-13542)
Victor Stinner [Fri, 24 May 2019 21:57:23 +0000 (23:57 +0200)]
bpo-37032: Add CodeType.replace() method (GH-13542)

5 years agobpo-37021: Port _randommodule to the argument clinic (GH-13532)
Pablo Galindo [Fri, 24 May 2019 21:09:23 +0000 (22:09 +0100)]
bpo-37021: Port _randommodule to the argument clinic (GH-13532)

5 years agobpo-35907: Fix typo in the NEWS entry (GH-13559)
Victor Stinner [Fri, 24 May 2019 21:06:25 +0000 (23:06 +0200)]
bpo-35907: Fix typo in the NEWS entry (GH-13559)

5 years agobpo-36969: Make PDB args command display positional only arguments (GH-13459)
Rémi Lapeyre [Fri, 24 May 2019 20:44:31 +0000 (22:44 +0200)]
bpo-36969: Make PDB args command display positional only arguments (GH-13459)

5 years agobpo-35907: Clarify the NEWS entry (GH-13523)
Victor Stinner [Fri, 24 May 2019 20:06:32 +0000 (22:06 +0200)]
bpo-35907: Clarify the NEWS entry (GH-13523)

5 years agobpo-37023: Skip test_gdb under PGO (GH-13555)
Steve Dower [Fri, 24 May 2019 20:00:04 +0000 (13:00 -0700)]
bpo-37023: Skip test_gdb under PGO (GH-13555)

5 years agobpo-8138: Initialize wsgiref's SimpleServer as single-threaded (GH-12977)
Berker Peksag [Fri, 24 May 2019 17:24:42 +0000 (20:24 +0300)]
bpo-8138: Initialize wsgiref's SimpleServer as single-threaded (GH-12977)

5 years agobpo-21536: Fix configure.ac for LIBPYTHON on Android/Cygwin (GH-13552)
E. M. Bray [Fri, 24 May 2019 16:39:39 +0000 (18:39 +0200)]
bpo-21536: Fix configure.ac for LIBPYTHON on Android/Cygwin (GH-13552)

Add also missing AC_MSG_RESULT for AC_MSG_CHECKING(MACHDEP).

5 years agobpo-36721: Fix pkg-config symbolic links on "make install" (GH-13551)
Victor Stinner [Fri, 24 May 2019 16:27:13 +0000 (18:27 +0200)]
bpo-36721: Fix pkg-config symbolic links on "make install" (GH-13551)

5 years agobpo-36511: Ensure error code propagates out of batch files (GH-13529)
Paul Monson [Fri, 24 May 2019 16:15:39 +0000 (09:15 -0700)]
bpo-36511: Ensure error code propagates out of batch files (GH-13529)

5 years agobpo-21536: On Cygwin, C extensions must be linked with libpython (GH-13549)
E. M. Bray [Fri, 24 May 2019 15:33:47 +0000 (17:33 +0200)]
bpo-21536: On Cygwin, C extensions must be linked with libpython (GH-13549)

It is also possible to link against a library or executable with a
statically linked libpython, but not both with the same DLL.  In fact
building a statically linked python is currently broken on Cygwin
for other (related) reasons.

The same problem applies to other POSIX-like layers over Windows
(MinGW, MSYS) but Python's build system does not seem to attempt
to support those platforms at the moment.

5 years agobpo-36710: Add tstate parameter in ceval.c (GH-13547)
Victor Stinner [Fri, 24 May 2019 15:01:38 +0000 (17:01 +0200)]
bpo-36710: Add tstate parameter in ceval.c (GH-13547)

* Fix a possible reference leak in _PyErr_Print() if exception
  is NULL.
* PyErr_BadInternalCall(): replace PyErr_Format() with _PyErr_SetString().
* Add pycore_pyerrors.h header file.
* New functions:

  * _PyErr_Clear()
  * _PyErr_Fetch()
  * _PyErr_Print()
  * _PyErr_Restore()
  * _PyErr_SetObject()
  * _PyErr_SetString()

* Add 'tstate' parameter to _PyEval_AddPendingCall().

5 years agoFix typos in Doc/library/email.generator.rst documentation (GH-13539)
Nick Sung [Fri, 24 May 2019 13:50:35 +0000 (21:50 +0800)]
Fix typos in Doc/library/email.generator.rst documentation (GH-13539)

5 years agobpo-37031: Fix PyOS_AfterFork_Child() (GH-13537)
Victor Stinner [Fri, 24 May 2019 13:20:23 +0000 (15:20 +0200)]
bpo-37031: Fix PyOS_AfterFork_Child() (GH-13537)

PyOS_AfterFork_Child(): _PyInterpreterState_DeleteExceptMain() must
be called after _PyRuntimeState_ReInitThreads().

_PyRuntimeState_ReInitThreads() resets interpreters mutex after fork,
mutex used by _PyInterpreterState_DeleteExceptMain().

5 years agoSupport Py_UNUSED() on clang (GH-13544)
Victor Stinner [Fri, 24 May 2019 13:16:08 +0000 (15:16 +0200)]
Support Py_UNUSED() on clang (GH-13544)

5 years agobpo-36710: Add tstate parameter in errors.c (GH-13540)
Victor Stinner [Fri, 24 May 2019 11:44:24 +0000 (13:44 +0200)]
bpo-36710: Add tstate parameter in errors.c (GH-13540)

Add 'PyThreadState *tstate' parameter to errors.c functions to avoid
relying on global variables (indirectly on _PyRuntime).

5 years agobpo-37031: Reuse _PyRuntime.main_thread in signalmodule.c (GH-13538)
Victor Stinner [Fri, 24 May 2019 11:43:55 +0000 (13:43 +0200)]
bpo-37031: Reuse _PyRuntime.main_thread in signalmodule.c (GH-13538)

Remove main_thread and main_interp variables from signalmodule.c:
reuse _PyRuntime which already track the main thread and the main
interpreter.

* Remove #include <sys/types.h> which became useless: getpid() call
  has been removed.
* Add runtime argument to is_main()
* is_main() now gets the interpreter from runtime.

5 years agobpo-36045: builtins.help() now prefixes `async` for async functions (GH-12010)
Dan Rose [Fri, 24 May 2019 11:38:01 +0000 (06:38 -0500)]
bpo-36045: builtins.help() now prefixes `async` for async functions (GH-12010)

Previously, it was hard to tell whether a function should be awaited. It was also incorrect (per PEP 484) to put this in the type hint for coroutine functions. Added this info to the output of builtins.help and pydoc.

https://bugs.python.org/issue36045

5 years agoFix typo: decription -> description (GH-13543)
Xtreak [Fri, 24 May 2019 11:17:48 +0000 (16:47 +0530)]
Fix typo: decription -> description (GH-13543)

5 years agobpo-20285: Improve help docs for object (GH-4759)
Cheryl Sabella [Fri, 24 May 2019 10:43:29 +0000 (06:43 -0400)]
bpo-20285: Improve help docs for object (GH-4759)

5 years agobpo-34626: Document creating heap types from the C-API (GH-9154)
Petr Viktorin [Fri, 24 May 2019 09:19:42 +0000 (11:19 +0200)]
bpo-34626: Document creating heap types from the C-API (GH-9154)

bpo-34626: Document creating heap types from the C-API

Add missing descriptions of PEP384's PyType_Spec and PyType_Slot,
along with some introductory prose.

5 years agoFix warning in _testembed.c (GH-13533)
Pablo Galindo [Thu, 23 May 2019 23:53:21 +0000 (00:53 +0100)]
Fix warning in _testembed.c (GH-13533)

5 years agobpo-23395: Fix PyErr_SetInterrupt if the SIGINT signal is ignored or not handled...
Matěj Cepl [Thu, 23 May 2019 20:30:00 +0000 (22:30 +0200)]
bpo-23395: Fix PyErr_SetInterrupt if the SIGINT signal is ignored or not handled (GH-7778)

``_thread.interrupt_main()`` now avoids setting the Python error status if the ``SIGINT`` signal is ignored or not handled by Python.

5 years agobpo-36842: Implement PEP 578 (GH-12613)
Steve Dower [Thu, 23 May 2019 15:45:22 +0000 (08:45 -0700)]
bpo-36842: Implement PEP 578 (GH-12613)

Adds sys.audit, sys.addaudithook, io.open_code, and associated C APIs.

5 years agobpo-36797: Reduce levels of indirection in outdated distutils docs (#13462)
Nick Coghlan [Thu, 23 May 2019 14:06:39 +0000 (00:06 +1000)]
bpo-36797: Reduce levels of indirection in outdated distutils docs (#13462)

5 years agobpo-37008: make mock_open handle able to honor next() (GH-13492)
Damien Nadé [Thu, 23 May 2019 10:03:25 +0000 (12:03 +0200)]
bpo-37008: make mock_open handle able to honor next() (GH-13492)

I've reported the issue on https://bugs.python.org/issue37008 and now I'm trying to bring a solution to this minor issue.

I think it could be trivially backported to 3.7 branch.

https://bugs.python.org/issue37008

5 years agobpo-33164: update blake2 implementation (GH-6286)
David Carlier [Thu, 23 May 2019 04:32:44 +0000 (04:32 +0000)]
bpo-33164: update blake2 implementation (GH-6286)

5 years agobpo-36763: Fix _PyPreConfig_InitCompatConfig() utf8_mode (GH-13518)
Victor Stinner [Thu, 23 May 2019 02:12:27 +0000 (04:12 +0200)]
bpo-36763: Fix _PyPreConfig_InitCompatConfig() utf8_mode (GH-13518)

* _PyPreConfig_InitCompatConfig() sets utf8_mode to 0.
* Change Py_UTF8Mode default value to 0.
* Fix _PyPreConfig_Copy(): copy also _config_init attrbibute.
* _PyPreConfig_AsDict() exports _config_init
* Fix _PyPreConfig_GetGlobalConfig(): use Py_UTF8Mode if it's greater
  than 0, even if utf8_mode >= 0.
* Add unit tests on environment variables using Python API.

5 years agobpo-18748: _pyio.IOBase emits unraisable exception (GH-13512)
Victor Stinner [Thu, 23 May 2019 01:45:09 +0000 (03:45 +0200)]
bpo-18748: _pyio.IOBase emits unraisable exception (GH-13512)

In development (-X dev) mode and in a debug build, IOBase finalizer
of the _pyio module now logs the exception if the close() method
fails. The exception is ignored silently by default in release build.

test_io: test_error_through_destructor() now uses
support.catch_unraisable_exception() rather than capturing stderr.

5 years agobpo-36721: Add --embed option to python-config (GH-13500)
Victor Stinner [Thu, 23 May 2019 01:30:23 +0000 (03:30 +0200)]
bpo-36721: Add --embed option to python-config (GH-13500)

To embed Python into an application, a new --embed option must be
passed to "python3-config --libs --embed" to get "-lpython3.8" (link
the application to libpython). To support both 3.8 and older, try
"python3-config --libs --embed" first and fallback to "python3-config
--libs" (without --embed) if the previous command fails.

Add a pkg-config "python-3.8-embed" module to embed Python into an
application: "pkg-config python-3.8-embed --libs" includes
"-lpython3.8".  To support both 3.8 and older, try "pkg-config
python-X.Y-embed --libs" first and fallback to "pkg-config python-X.Y
--libs" (without --embed) if the previous command fails (replace
"X.Y" with the Python version).

On the other hand, "pkg-config python3.8 --libs" no longer contains
"-lpython3.8". C extensions must not be linked to libpython (except
on Android, case handled by the script); this change is backward
incompatible on purpose.

"make install" now also installs "python-3.8-embed.pc".

5 years agobpo-27737: Allow whitespace only headers encoding (#13478)
Batuhan Taşkaya [Thu, 23 May 2019 01:13:16 +0000 (04:13 +0300)]
bpo-27737: Allow whitespace only headers encoding (#13478)

5 years agobpo-35091: Objects/listobject.c: Replace overflow checks in gallop fu… (GH-10202)
Alexey Izbyshev [Thu, 23 May 2019 00:01:08 +0000 (03:01 +0300)]
bpo-35091: Objects/listobject.c: Replace overflow checks in gallop fu… (GH-10202)

…nctions with asserts

The actual overflow can never happen because of the following:
* The size of a list can't be greater than PY_SSIZE_T_MAX / sizeof(PyObject*).
* The size of a pointer on all supported plaftorms is at least 4 bytes.
* ofs is positive and less than the list size at the beginning of each iteration.

https://bugs.python.org/issue35091

5 years agobpo-36829: PyErr_WriteUnraisable() normalizes exception (GH-13507)
Victor Stinner [Wed, 22 May 2019 23:00:58 +0000 (01:00 +0200)]
bpo-36829: PyErr_WriteUnraisable() normalizes exception (GH-13507)

PyErr_WriteUnraisable() now creates a traceback object if there is no
current traceback. Moreover, call PyErr_NormalizeException() and
PyException_SetTraceback() to normalize the exception value. Ignore
silently any error.

5 years agobpo-36763: Rename private Python initialization functions (GH-13511)
Victor Stinner [Wed, 22 May 2019 22:57:57 +0000 (00:57 +0200)]
bpo-36763: Rename private Python initialization functions (GH-13511)

* Rename private C functions:

  * _Py_Initialize_ReconfigureCore => pyinit_core_reconfigure
  * _Py_InitializeCore_impl => pyinit_core_config
  * _Py_InitializeCore = > pyinit_core
  * _Py_InitializeMainInterpreter => pyinit_main
  * init_python => pyinit_python

* Rename _testembed.c commands: add "test_" prefix.

5 years agobpo-36941: Project file fixups for Windows ARM64 (GH-13477)
Paul Monson [Wed, 22 May 2019 22:16:21 +0000 (15:16 -0700)]
bpo-36941: Project file fixups for Windows ARM64 (GH-13477)

5 years agobpo-36763: Add _PyPreConfig._config_init (GH-13481)
Victor Stinner [Wed, 22 May 2019 21:58:50 +0000 (23:58 +0200)]
bpo-36763: Add _PyPreConfig._config_init (GH-13481)

* _PyPreConfig_GetGlobalConfig() and  _PyCoreConfig_GetGlobalConfig()
  now do nothing if the configuration was not initialized with
  _PyPreConfig_InitCompatConfig() and _PyCoreConfig_InitCompatConfig()
* Remove utf8_mode=-2 special case: use utf8_mode=-1 instead.
* Fix _PyPreConfig_InitPythonConfig():

  * isolated = 0 instead of -1
  * use_environment = 1 instead of -1

* Rename _PyConfig_INIT to  _PyConfig_INIT_COMPAT
* Rename _PyPreConfig_Init() to _PyPreConfig_InitCompatConfig()
* Rename _PyCoreConfig_Init() to _PyCoreConfig_InitCompatConfig()
* PyInterpreterState_New() now uses _PyCoreConfig_InitPythonConfig()
  as default configuration, but it's very quickly overriden anyway.
* _freeze_importlib.c uses _PyCoreConfig_SetString() to set
  program_name.
* Cleanup preconfig_init_utf8_mode(): cmdline is always non-NULL.

5 years agobpo-36829: Add test.support.catch_unraisable_exception() (GH-13490)
Victor Stinner [Wed, 22 May 2019 21:44:02 +0000 (23:44 +0200)]
bpo-36829: Add test.support.catch_unraisable_exception() (GH-13490)

* Copy test_exceptions.test_unraisable() to
  test_sys.UnraisableHookTest().
* Use catch_unraisable_exception() in test_coroutines,
  test_exceptions, test_generators.

5 years agobpo-24882: Let ThreadPoolExecutor reuse idle threads before creating new thread ...
Sean [Wed, 22 May 2019 21:29:58 +0000 (14:29 -0700)]
bpo-24882: Let ThreadPoolExecutor reuse idle threads before creating new thread (#6375)

* Fixes issue 24882

* Add news file entry for change.

* Change test_concurrent_futures.ThreadPoolShutdownTest

Adjust the shutdown test so that, after submitting three jobs
to the executor, the test checks for less than three threads,
instead of looking for exactly three threads.

If idle threads are being recycled properly, then we should have
less than three threads.

* Switched idle count to semaphor, Updated tests

As suggested by reviewer tomMoral, swapped lock-protected counter
with a semaphore to track the number of unused threads.

Adjusted test_threads_terminate to wait for completiton of the
previous future before submitting a new one (and checking the
number of threads used).

Also added a new test to confirm the thread pool can be saturated.

* Updates tests as requested by pitrou.

* Correct minor whitespace error.

* Make test_saturation faster

5 years agobpo-33110: Catch errors raised when running add_done_callback on already completed...
Sam Martin [Wed, 22 May 2019 21:29:02 +0000 (22:29 +0100)]
bpo-33110: Catch errors raised when running add_done_callback on already completed futures (GH-13141)

Wrap the callback call within the `add_done_callback` function within concurrent.futures, in order to behave in an identical manner to callbacks added to a running future are triggered once it has completed.

5 years agobpo-36878: Only allow text after `# type: ignore` if first character ASCII (GH-13504)
Michael J. Sullivan [Wed, 22 May 2019 20:43:37 +0000 (13:43 -0700)]
bpo-36878: Only allow text after `# type: ignore` if first character ASCII (GH-13504)

This disallows things like `# type: ignoreé`, which seems wrong.

Also switch to using Py_ISALNUM for the alnum check, for consistency
with other code (and maybe correctness re: locale issues?).

https://bugs.python.org/issue36878

5 years agobpo-35907, CVE-2019-9948: urllib rejects local_file:// scheme (GH-13474)
Victor Stinner [Wed, 22 May 2019 20:15:01 +0000 (22:15 +0200)]
bpo-35907, CVE-2019-9948: urllib rejects local_file:// scheme (GH-13474)

CVE-2019-9948: Avoid file reading as disallowing the unnecessary URL
scheme in URLopener().open() and URLopener().retrieve()
of urllib.request.

Co-Authored-By: SH <push0ebp@gmail.com>
5 years agobpo-34616: Document top level async in whatsnew/3.8. (GH-13484)
Matthias Bussonnier [Wed, 22 May 2019 19:07:45 +0000 (12:07 -0700)]
bpo-34616: Document top level async in whatsnew/3.8. (GH-13484)

https://bugs.python.org/issue34616

5 years agobpo-36084: Add native thread ID (TID) to threading.Thread (GH-13463)
Jake Tesler [Wed, 22 May 2019 15:43:17 +0000 (08:43 -0700)]
bpo-36084: Add native thread ID (TID) to threading.Thread (GH-13463)

Add native thread ID (TID) to threading.Thread objects
(supported platforms: Windows, FreeBSD, Linux, macOS).

5 years agobpo-33482: fix codecs.StreamRecoder.writelines (GH-6779)
Jelle Zijlstra [Wed, 22 May 2019 15:18:26 +0000 (08:18 -0700)]
bpo-33482: fix codecs.StreamRecoder.writelines (GH-6779)

A very simple fix. I found this while writing typeshed stubs for StreamRecoder.

https://bugs.python.org/issue33482

5 years agobpo-36878: Track extra text added to 'type: ignore' in the AST (GH-13479)
Michael J. Sullivan [Wed, 22 May 2019 14:54:20 +0000 (07:54 -0700)]
bpo-36878: Track extra text added to 'type: ignore' in the AST (GH-13479)

GH-13238 made extra text after a # type: ignore accepted by the parser.
This finishes the job and actually plumbs the extra text through the
parser and makes it available in the AST.

5 years agobpo-36972: Add SupportsIndex (GH-13448)
Paul Dagnelie [Wed, 22 May 2019 14:23:01 +0000 (07:23 -0700)]
bpo-36972: Add SupportsIndex (GH-13448)

In order to support typing checks calling hex(), oct() and bin() on user-defined classes, a SupportIndex protocol is required. The ability to check these at runtime would be good to add for completeness sake. This is pretty much just a copy of SupportsInt with the names tweaked.

5 years agobpo-31862: Port binascii to PEP 489 multiphase initialization (GH-4108)
Marcel Plch [Wed, 22 May 2019 11:51:26 +0000 (13:51 +0200)]
bpo-31862: Port binascii to PEP 489 multiphase initialization (GH-4108)

5 years agobpo-36907: fix refcount bug in _PyStack_UnpackDict() (GH-13381)
Jeroen Demeyer [Wed, 22 May 2019 11:09:35 +0000 (13:09 +0200)]
bpo-36907: fix refcount bug in _PyStack_UnpackDict() (GH-13381)

5 years agobpo-36994: add test for profiling method_descriptor with **kwargs (GH-13461)
Jeroen Demeyer [Wed, 22 May 2019 10:05:02 +0000 (12:05 +0200)]
bpo-36994: add test for profiling method_descriptor with **kwargs (GH-13461)

It adds a missing testcase for bpo-34125. This is testing code which is
affected by PEP 590, so missing this test might accidentally break
CPython if we screw up with implementing PEP 590.

5 years agobpo-36829: Add sys.unraisablehook() (GH-13187)
Victor Stinner [Wed, 22 May 2019 09:28:22 +0000 (11:28 +0200)]
bpo-36829: Add sys.unraisablehook() (GH-13187)

Add new sys.unraisablehook() function which can be overridden to
control how "unraisable exceptions" are handled. It is called when an
exception has occurred but there is no way for Python to handle it.
For example, when a destructor raises an exception or during garbage
collection (gc.collect()).

Changes:

* Add an internal UnraisableHookArgs type used to pass arguments to
  sys.unraisablehook.
* Add _PyErr_WriteUnraisableDefaultHook().
* The default hook now ignores exception on writing the traceback.
* test_sys now uses unittest.main() to automatically discover tests:
  remove test_main().
* Add _PyErr_Init().
* Fix PyErr_WriteUnraisable(): hold a strong reference to sys.stderr
  while using it

5 years agobpo-36948: Fix test_urlopener_retrieve_file on Windows (GH-13476)
Berker Peksag [Tue, 21 May 2019 23:00:35 +0000 (02:00 +0300)]
bpo-36948: Fix test_urlopener_retrieve_file on Windows (GH-13476)

5 years agobpo-34616: Fix code style and unbreak buildbots (GH-13473)
Yury Selivanov [Tue, 21 May 2019 21:20:21 +0000 (17:20 -0400)]
bpo-34616: Fix code style and unbreak buildbots (GH-13473)

See also PR GH-13148.

5 years agobpo-25652: Fix __rmod__ of UserString (GH-13326)
Batuhan Taşkaya [Tue, 21 May 2019 20:27:36 +0000 (23:27 +0300)]
bpo-25652: Fix __rmod__ of UserString (GH-13326)

The ``__rmod__`` method of ``collections.UserString`` class had a bug that made it unusable.

https://bugs.python.org/issue25652

5 years agobpo-34616: Add PyCF_ALLOW_TOP_LEVEL_AWAIT to allow top-level await (GH-13148)
Matthias Bussonnier [Tue, 21 May 2019 20:12:03 +0000 (13:12 -0700)]
bpo-34616: Add PyCF_ALLOW_TOP_LEVEL_AWAIT to allow top-level await (GH-13148)

Co-Authored-By: Yury Selivanov <yury@magic.io>
5 years agobpo-23378: Add an extend action to argparse (GH-13305)
Batuhan Taşkaya [Tue, 21 May 2019 17:47:42 +0000 (20:47 +0300)]
bpo-23378: Add an extend action to argparse (GH-13305)

Add an extend action to argparse

https://bugs.python.org/issue23378

5 years agobpo-36035: fix Path.rglob for broken links (GH-11988)
Jörg Stucke [Tue, 21 May 2019 17:44:40 +0000 (19:44 +0200)]
bpo-36035: fix Path.rglob for broken links (GH-11988)

Links creating an infinite symlink loop would raise an exception.

5 years agobpo-36929: Modify io/re tests to allow for missing mod name (#13392)
Max Bernstein [Tue, 21 May 2019 17:09:21 +0000 (10:09 -0700)]
bpo-36929: Modify io/re tests to allow for missing mod name (#13392)

* bpo-36929: Modify io/re tests to allow for missing mod name

For a vanishingly small number of internal types, CPython sets the
tp_name slot to mod_name.type_name, either in the PyTypeObject or the
PyType_Spec. There are a few minor places where this surfaces:

* Custom repr functions for those types (some of which ignore the
  tp_name in favor of using a string literal, such as _io.TextIOWrapper)
* Pickling error messages

The test suite only tests the former. This commit modifies the test
suite to allow Python implementations to omit the module prefix.

https://bugs.python.org/issue36929

5 years agoAnnotate the unexplained assignment in exception unbinding (GH-11448)
Chris Angelico [Tue, 21 May 2019 13:34:19 +0000 (23:34 +1000)]
Annotate the unexplained assignment in exception unbinding (GH-11448)

5 years agobpo-36648: fix mmap issue for VxWorks (GH-12394)
Lihua Zhao [Tue, 21 May 2019 10:50:14 +0000 (18:50 +0800)]
bpo-36648: fix mmap issue for VxWorks (GH-12394)

The mmap module set MAP_SHARED flag when map anonymous memory, however VxWorks
only support MAP_PRIVATE when map anonymous memory, this commit clear MAP_SHARED
and set MAP_PRIVATE.

5 years agobpo-31904: Add posix module support for VxWorks (GH-12118)
pxinwr [Tue, 21 May 2019 10:46:37 +0000 (18:46 +0800)]
bpo-31904: Add posix module support for VxWorks (GH-12118)

5 years agoRevert "bpo-36084: Add native thread ID to threading.Thread objects (GH-11993)" ...
Victor Stinner [Tue, 21 May 2019 10:44:57 +0000 (12:44 +0200)]
Revert "bpo-36084: Add native thread ID to threading.Thread objects (GH-11993)" (GH-13458)

This reverts commit 4959c33d2555b89b494c678d99be81a65ee864b0.

5 years agobpo-36965: Fix includes in main.c on Windows with non-MSC compilers (GH-13421)
Erik Janssens [Tue, 21 May 2019 10:11:11 +0000 (12:11 +0200)]
bpo-36965: Fix includes in main.c on Windows with non-MSC compilers (GH-13421)

Include windows.h rather than crtdbg.h to get STATUS_CONTROL_C_EXIT constant.
Moreover, include windows.h on Windows, not only when MSC is used.

5 years agoFix RuntimeWarning in unittest.mock asyncio example (GH-13449)
Xtreak [Tue, 21 May 2019 08:47:17 +0000 (14:17 +0530)]
Fix RuntimeWarning in unittest.mock asyncio example (GH-13449)

* This PR fixes the `RuntimeWarning` in `inspect.isawaitable(mock())` where `mock()` was not awaited.
* Fix typo in asynctest project.

5 years agobpo-36932: use proper deprecation-removed directive (GH-13349)
Matthias Bussonnier [Tue, 21 May 2019 06:20:10 +0000 (23:20 -0700)]
bpo-36932: use proper deprecation-removed directive (GH-13349)

.. And update some deprecation warnings with version numbers.

https://bugs.python.org/issue36932

5 years agoRemove workaround for defaults in namedtuple now that we have the defaults parameter...
Andre Delfino [Tue, 21 May 2019 00:52:17 +0000 (21:52 -0300)]
Remove workaround for defaults in namedtuple now that we have the defaults parameter (GH-13263)

5 years agobpo-35563: Add reference links to warnings.rst (GH-11289)
Cheryl Sabella [Mon, 20 May 2019 22:45:05 +0000 (18:45 -0400)]
bpo-35563: Add reference links to warnings.rst (GH-11289)

5 years agobpo-36969: Make PDB args command display keyword only arguments (GH-13452)
Rémi Lapeyre [Mon, 20 May 2019 22:17:30 +0000 (00:17 +0200)]
bpo-36969: Make PDB args command display keyword only arguments (GH-13452)

5 years agobpo-36952: Remove the bufsize parameter in fileinput.input(). (GH-13400)
Matthias Bussonnier [Mon, 20 May 2019 20:44:11 +0000 (13:44 -0700)]
bpo-36952: Remove the bufsize parameter in fileinput.input(). (GH-13400)

This parameter is marked as deprecated since 3.6 and for removal in 3.8.
It already had no effects.

5 years agobpo-23896: Add a grammar where exec isn't a stmt (#13272)
Batuhan Taşkaya [Mon, 20 May 2019 20:27:10 +0000 (23:27 +0300)]
bpo-23896: Add a grammar where exec isn't a stmt (#13272)

https://bugs.python.org/issue23896

5 years agobpo-36888: Add multiprocessing.parent_process() (GH-13247)
Thomas Moreau [Mon, 20 May 2019 19:37:05 +0000 (21:37 +0200)]
bpo-36888: Add multiprocessing.parent_process() (GH-13247)

5 years agobpo-36949: Implement __repr__ on WeakSet (GH-13415)
Batuhan Taşkaya [Mon, 20 May 2019 17:01:07 +0000 (20:01 +0300)]
bpo-36949: Implement __repr__ on WeakSet (GH-13415)

5 years agobpo-26467: Adds AsyncMock for asyncio Mock library support (GH-9296)
Lisa Roach [Mon, 20 May 2019 16:19:53 +0000 (09:19 -0700)]
bpo-26467: Adds AsyncMock for asyncio Mock library support (GH-9296)

5 years agobpo-36763: Fix _PyRuntime.preconfig.coerce_c_locale (GH-13444)
Victor Stinner [Mon, 20 May 2019 15:16:38 +0000 (17:16 +0200)]
bpo-36763: Fix _PyRuntime.preconfig.coerce_c_locale (GH-13444)

_PyRuntime.preconfig.coerce_c_locale can now be used to
check if the C locale has been coerced.

* Fix _Py_LegacyLocaleDetected(): don't attempt to coerce the
  C locale if LC_ALL environment variable is set. Add 'warn'
  parameter: emit_stderr_warning_for_legacy_locale() must not
  the LC_ALL env var.
* _PyPreConfig_Write() sets coerce_c_locale to 0 if
  _Py_CoerceLegacyLocale() fails.

5 years agobpo-22865: Expand on documentation for the pty.spawn function (GH-11980)
Geoff Shannon [Mon, 20 May 2019 15:06:16 +0000 (08:06 -0700)]
bpo-22865: Expand on documentation for the pty.spawn function (GH-11980)

5 years agoPass _asyncio_internal=True into stream tests on windows (#13442)
Andrew Svetlov [Mon, 20 May 2019 14:38:57 +0000 (17:38 +0300)]
Pass _asyncio_internal=True into stream tests on windows (#13442)

5 years agobpo-36763: Fix encoding/locale tests in test_embed (GH-13443)
Victor Stinner [Mon, 20 May 2019 14:38:48 +0000 (16:38 +0200)]
bpo-36763: Fix encoding/locale tests in test_embed (GH-13443)

* Fix encoding and locale tests in test_embed.InitConfigTests.
* InitConfigTests now only computes EXPECTED_CONFIG once.
* Add tests for PYTHONWARNINGS and PYTHONPATH env vars

5 years agobpo-35721: Close socket pair if Popen in _UnixSubprocessTransport fails (GH-11553)
Niklas Fiekas [Mon, 20 May 2019 12:02:17 +0000 (14:02 +0200)]
bpo-35721: Close socket pair if Popen in _UnixSubprocessTransport fails (GH-11553)

This slightly expands an existing test case `test_popen_error` to trigger a `ResourceWarning` and fixes it.

https://bugs.python.org/issue35721

5 years agobpo-36763: Fix Python preinitialization (GH-13432)
Victor Stinner [Mon, 20 May 2019 09:02:00 +0000 (11:02 +0200)]
bpo-36763: Fix Python preinitialization (GH-13432)

* Add _PyPreConfig.parse_argv
* Add _PyCoreConfig._config_init field and _PyCoreConfigInitEnum enum
  type
* Initialization functions: reject preconfig=NULL and config=NULL
* Add config parameter to _PyCoreConfig_DecodeLocaleErr(): pass
  config->argv to _Py_PreInitializeFromPyArgv(), to parse config
  command line arguments in preinitialization.
* Add config parameter to _PyCoreConfig_SetString(). It now
  preinitializes Python.
* _PyCoreConfig_SetPyArgv() now also preinitializes Python for wide
  argv
* Fix _Py_PreInitializeFromCoreConfig(): don't pass args to
  _Py_PreInitializeFromPyArgv() if config.parse_argv=0.
* Use "char * const *" and "wchar_t * const *" types for 'argv'
  parameters and _PyArgv.argv.
* Add unit test on preinitialization from argv.
* _PyPreConfig.allocator type becomes int
* Add _PyPreConfig_InitFromPreConfig() and
  _PyPreConfig_InitFromCoreConfig() helper functions