Commit Graph

104277 Commits

Author SHA1 Message Date
Terry Jan Reedy 81bb97df61
bpo-37038: Make idlelib.run runnable; add test clause (GH-13560) 2019-05-24 21:59:53 -04:00
Jason R. Coombs 1bbf7b661f bpo-34632: Add importlib.metadata (GH-12547)
Add importlib.metadata module as forward port of the standalone importlib_metadata.
2019-05-24 16:59:01 -07:00
Victor Stinner 6dbbe748e1
bpo-36829: Document test.support.catch_unraisable_exception() (GH-13554)
catch_unraisable_exception() now also removes its 'unraisable'
attribute at the context manager exit.
2019-05-25 00:09:38 +02:00
Victor Stinner a9f05d69cc
bpo-37032: Add CodeType.replace() method (GH-13542) 2019-05-24 23:57:23 +02:00
Pablo Galindo 561612d845
bpo-37021: Port _randommodule to the argument clinic (GH-13532) 2019-05-24 22:09:23 +01:00
Victor Stinner 1c9debd236
bpo-35907: Fix typo in the NEWS entry (GH-13559) 2019-05-24 23:06:25 +02:00
Rémi Lapeyre 458560347f bpo-36969: Make PDB args command display positional only arguments (GH-13459) 2019-05-24 21:44:31 +01:00
Victor Stinner deffee5774
bpo-35907: Clarify the NEWS entry (GH-13523) 2019-05-24 22:06:32 +02:00
Steve Dower 6de4574c63
bpo-37023: Skip test_gdb under PGO (GH-13555) 2019-05-24 13:00:04 -07:00
Berker Peksag 14738ff83d
bpo-8138: Initialize wsgiref's SimpleServer as single-threaded (GH-12977) 2019-05-24 20:24:42 +03:00
E. M. Bray b1fc417841 bpo-21536: Fix configure.ac for LIBPYTHON on Android/Cygwin (GH-13552)
Add also missing AC_MSG_RESULT for AC_MSG_CHECKING(MACHDEP).
2019-05-24 18:39:38 +02:00
Victor Stinner bc66faccb8
bpo-36721: Fix pkg-config symbolic links on "make install" (GH-13551) 2019-05-24 18:27:13 +02:00
Paul Monson 51394b8c3d bpo-36511: Ensure error code propagates out of batch files (GH-13529) 2019-05-24 09:15:39 -07:00
E. M. Bray c994c8fc19 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.
2019-05-24 17:33:47 +02:00
Victor Stinner 438a12dd9d
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().
2019-05-24 17:01:38 +02:00
Nick Sung 13d4e6a4a0 Fix typos in Doc/library/email.generator.rst documentation (GH-13539) 2019-05-24 09:50:35 -04:00
Victor Stinner b49858b4b7
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().
2019-05-24 15:20:23 +02:00
Victor Stinner b3a9843cd1
Support Py_UNUSED() on clang (GH-13544) 2019-05-24 15:16:08 +02:00
Victor Stinner b4bdecd0fc
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).
2019-05-24 13:44:24 +02:00
Victor Stinner d8613dc86f
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.
2019-05-24 13:43:55 +02:00
Dan Rose 2a37f8f55b 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
2019-05-24 04:38:01 -07:00
Xtreak cf7d5ef49b Fix typo: decription -> description (GH-13543) 2019-05-24 04:17:47 -07:00
Cheryl Sabella c95c93d4eb
bpo-20285: Improve help docs for object (GH-4759) 2019-05-24 06:43:29 -04:00
Petr Viktorin f1e17e9f97
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.
2019-05-24 11:19:42 +02:00
Pablo Galindo cccc11b38e
Fix warning in _testembed.c (GH-13533) 2019-05-24 00:53:21 +01:00
Matěj Cepl 608876b6b1 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.
2019-05-23 22:30:00 +02:00
Steve Dower b82e17e626
bpo-36842: Implement PEP 578 (GH-12613)
Adds sys.audit, sys.addaudithook, io.open_code, and associated C APIs.
2019-05-23 08:45:22 -07:00
Nick Coghlan e788057a91
bpo-36797: Reduce levels of indirection in outdated distutils docs (#13462) 2019-05-24 00:06:39 +10:00
Damien Nadé 394119afc6 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
2019-05-23 03:03:25 -07:00
David Carlier 51aa35e9e1 bpo-33164: update blake2 implementation (GH-6286) 2019-05-23 13:32:44 +09:00
Victor Stinner 20e1e2582e
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.
2019-05-23 04:12:27 +02:00
Victor Stinner bc2aa81662
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.
2019-05-23 03:45:09 +02:00
Victor Stinner 0a8e57248b
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".
2019-05-23 03:30:23 +02:00
Batuhan Taşkaya ef5bb25e2d bpo-27737: Allow whitespace only headers encoding (#13478) 2019-05-22 21:13:16 -04:00
Alexey Izbyshev 6bc5917903 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
2019-05-22 17:01:08 -07:00
Victor Stinner df22c03b93
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.
2019-05-23 01:00:58 +02:00
Victor Stinner 5edcf26358
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.
2019-05-23 00:57:57 +02:00
Paul Monson cfb241bd29 bpo-36941: Project file fixups for Windows ARM64 (GH-13477) 2019-05-22 15:16:21 -07:00
Victor Stinner 022be02dcf
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.
2019-05-22 23:58:50 +02:00
Victor Stinner e4d300e07c
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.
2019-05-22 23:44:02 +02:00
Sean 904e34d4e6 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
2019-05-22 23:29:58 +02:00
Sam Martin 2a3a2ece50 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.
2019-05-22 23:29:02 +02:00
Michael J. Sullivan d8a82e2897 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
2019-05-22 13:43:36 -07:00
Victor Stinner 0c2b6a3943
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>
2019-05-22 22:15:01 +02:00
Matthias Bussonnier 2ddbd21aec bpo-34616: Document top level async in whatsnew/3.8. (GH-13484)
https://bugs.python.org/issue34616
2019-05-22 12:07:45 -07:00
Jake Tesler b121f63155 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).
2019-05-22 17:43:16 +02:00
Jelle Zijlstra b3be407288 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
2019-05-22 08:18:26 -07:00
Michael J. Sullivan 933e1509ec 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.
2019-05-22 15:54:20 +01:00
Paul Dagnelie 4c7a46eb3c 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.
2019-05-22 15:23:01 +01:00
Marcel Plch 33e71e01e9 bpo-31862: Port binascii to PEP 489 multiphase initialization (GH-4108) 2019-05-22 13:51:25 +02:00