Commit Graph

3328 Commits

Author SHA1 Message Date
Victor Stinner 6f7346bb39
[3.9] bpo-40826: Fix GIL usage in PyOS_Readline() (GH-20613) (GH-20616)
* bpo-40826: Fix GIL usage in PyOS_Readline() (GH-20579)

Fix GIL usage in PyOS_Readline(): lock the GIL to set an exception.

Pass tstate to my_fgets() and _PyOS_WindowsConsoleReadline(). Cleanup
these functions.

(cherry picked from commit c353764fd5)

* bpo-40826: Add _PyOS_InterruptOccurred(tstate) function (GH-20599)

my_fgets() now calls _PyOS_InterruptOccurred(tstate) to check for
pending signals, rather calling PyOS_InterruptOccurred().

my_fgets() is called with the GIL released, whereas
PyOS_InterruptOccurred() must be called with the GIL held.

test_repl: use text=True and avoid SuppressCrashReport in
test_multiline_string_parsing().

Fix my_fgets() on Windows: fgets(fp) does crash if fileno(fp) is closed.

(cherry picked from commit fa7ab6aa0f)
2020-06-03 18:28:18 +02:00
Łukasz Langa 35b8a4da74
Post 3.8.3 2020-05-13 23:42:31 +02:00
Łukasz Langa 6f8c8320e9
Python 3.8.3 2020-05-13 19:31:54 +02:00
Pablo Galindo 5055c274c6
[3.8] bpo-39562: Prevent collision of future and compiler flags (GH-19230) (GH-19835)
The constant values of future flags in the __future__ module
is updated in order to prevent collision with compiler flags.
Previously PyCF_ALLOW_TOP_LEVEL_AWAIT was clashing
with CO_FUTURE_DIVISION..
(cherry picked from commit 4454057269)

Co-authored-by: Batuhan Taşkaya <batuhanosmantaskaya@gmail.com>
2020-05-01 07:18:27 -07:00
Łukasz Langa e07fb669e9
Post 3.8.3rc1 2020-04-30 00:43:53 +02:00
Łukasz Langa 802eb676ba
Python 3.8.3rc1 2020-04-29 19:21:55 +02:00
Miss Islington (bot) 10dabbf8d2
Remove extraneous ')' in abstract.h (GH-19146) (#19451)
(cherry picked from commit ac2cfe6631)

Co-authored-by: Jimmy Yang <codingExpert123@gmail.com>
2020-04-09 14:55:00 -04:00
Victor Stinner e97c8b0688
bpo-20526: Fix PyThreadState_Clear(): don't decref frame (GH-19120) (GH-19136)
PyThreadState.frame is a borrowed reference, not a strong reference:
PyThreadState_Clear() must not call Py_CLEAR(tstate->frame).

Remove test_threading.test_warnings_at_exit(): we cannot warranty
that the Python thread state of daemon threads is cleared in a
reliable way during Python shutdown.

(cherry picked from commit 5804f878e7)
2020-03-24 17:12:19 +01:00
Łukasz Langa eb4a3dfbb9
Post 3.8.2 2020-02-25 12:45:02 +01:00
Łukasz Langa 7b3ab5921f
Python 3.8.2 2020-02-24 22:36:25 +01:00
Łukasz Langa 9d83984085
Post 3.8.2rc2 2020-02-18 13:01:01 +01:00
Łukasz Langa 777ba072d6
Python 3.8.2rc2 2020-02-17 23:45:14 +01:00
Łukasz Langa 40ef4fc07e
Post 3.8.2rc1 2020-02-11 13:38:43 +01:00
Łukasz Langa 8623e68ea8
Python 3.8.2rc1 2020-02-10 20:08:24 +01:00
Łukasz Langa f89c86511a
Post 3.8.1 2019-12-19 09:01:48 +01:00
Łukasz Langa 1b293b6006
Python 3.8.1 2019-12-18 18:21:23 +01:00
Łukasz Langa 7c543f4023
Post 3.8.1rc1 2019-12-10 09:13:16 +01:00
Łukasz Langa b00a2b5b76
Python 3.8.1rc1 2019-12-09 18:47:55 +01:00
Serhiy Storchaka f2ba17be2a
[3.8] bpo-38600: Change the mark up of NULL in the C API documentation. (GH-16950) (GH-16999)
Replace all *NULL* with ``NULL``.
(cherry picked from commit 25fc088607)
2019-10-30 21:36:33 +02:00
Victor Stinner f82ce5b1b1
[3.8] bpo-36389: Backport debug enhancements from master (GH-16796)
* bpo-36389: _PyObject_CheckConsistency() available in release mode (GH-16612)

bpo-36389, bpo-38376: The _PyObject_CheckConsistency() function is
now also available in release mode. For example, it can be used to
debug a crash in the visit_decref() function of the GC.

Modify the following functions to also work in release mode:

* _PyDict_CheckConsistency()
* _PyObject_CheckConsistency()
* _PyType_CheckConsistency()
* _PyUnicode_CheckConsistency()

Other changes:

* _PyMem_IsPtrFreed(ptr) now also returns 1 if ptr is NULL
  (equals to 0).
* _PyBytesWriter_CheckConsistency() now returns 1 and is only used
  with assert().
* Reorder _PyObject_Dump() to write safe fields first, and only
  attempt to render repr() at the end.

(cherry picked from commit 6876257eaa)

* bpo-36389: Fix _PyBytesWriter in release mode (GH-16624)

Fix _PyBytesWriter API when Python is built in release mode with
assertions.

(cherry picked from commit 60ec6efd96)

* bpo-38070: Enhance visit_decref() debug trace (GH-16631)

subtract_refs() now pass the parent object to visit_decref() which
pass it to _PyObject_ASSERT(). So if the "is freed" assertion fails,
the parent is used in debug trace, rather than the freed object. The
parent object is more likely to contain useful information. Freed
objects cannot be inspected are are displayed as "<object at xxx is
freed>" with no other detail.

(cherry picked from commit 4d5f94b8cd)

* Fix also a typo in PYMEM_DEADBYTE macro comment

* bpo-36389: Add newline to _PyObject_AssertFailed() (GH-16629)

Add a newline between the verbose object dump and the Py_FatalError()
logs for readability.

(cherry picked from commit 7775349895)
2019-10-15 03:06:16 +02:00
Łukasz Langa cc06217d9d
Post v3.8.0 2019-10-14 22:02:48 +02:00
Łukasz Langa fa919fdf25
v3.8.0 2019-10-14 15:34:47 +02:00
Victor Stinner 435b2eeb7b
bpo-38376: Fix _PyUnicode_CheckConsistency() definition (GH-16623)
Always define _PyUnicode_CheckConsistency() in the CPython C API.
2019-10-07 21:12:05 +02:00
Łukasz Langa 3b2f4e9790
Post v3.8.0rc1 2019-10-01 22:49:40 +02:00
Łukasz Langa 34214de6ab
v3.8.0rc1 2019-10-01 14:58:26 +02:00
Miss Islington (bot) d49f096cc4
bpo-38304: PyConfig_InitPythonConfig() cannot fail anymore (GH-16509)
PyConfig_InitPythonConfig() and PyConfig_InitIsolatedConfig() no
longer return PyStatus: they cannot fail anymore.
(cherry picked from commit 8462a4936b)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2019-10-01 03:26:04 -07:00
Victor Stinner bdace21b76 bpo-38304: Remove PyConfig.struct_size (GH-16500)
For now, we'll rely on the fact that the config structures aren't covered by the stable ABI.

We may revisit this in the future if we further explore the idea of offering a stable embedding API.
2019-10-01 08:46:42 +10:00
Miss Islington (bot) 2f87a7dc5a bpo-30773: Fix ag_running; prohibit running athrow/asend/aclose in parallel (GH-7468) (#16486)
(cherry picked from commit fc4a044a3c)

Co-authored-by: Yury Selivanov <yury@magic.io>
2019-09-29 23:19:02 -07:00
Miss Islington (bot) c9ed9e6fc7
bpo-38317: Fix PyConfig.warnoptions priority (GH-16478)
Fix warnings options priority: PyConfig.warnoptions has the highest
priority, as stated in the PEP 587.

* Document options order in PyConfig.warnoptions documentation.
* Make PyWideStringList_INIT macro private: replace "Py" prefix
  with "_Py".
* test_embed: add test_init_warnoptions().
(cherry picked from commit fb4ae152a9)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2019-09-29 16:58:57 -07:00
Victor Stinner 6e128382b3
bpo-38304: Add PyConfig.struct_size (GH-16451) (GH-16453)
Add a new struct_size field to PyPreConfig and PyConfig structures to
allow to modify these structures in the future without breaking the
backward compatibility.

* Replace private _config_version field with public struct_size field
  in PyPreConfig and PyConfig.
* Public PyPreConfig_InitIsolatedConfig() and
  PyPreConfig_InitPythonConfig()
  return type becomes PyStatus, instead of void.
* Internal _PyConfig_InitCompatConfig(),
  _PyPreConfig_InitCompatConfig(), _PyPreConfig_InitFromConfig(),
  _PyPreConfig_InitFromPreConfig() return type becomes PyStatus,
  instead of void.
* Remove _Py_CONFIG_VERSION
* Update the Initialization Configuration documentation.

(cherry picked from commit 441b10cf28)
2019-09-28 04:50:43 +02:00
Victor Stinner 96c8475362
[3.8] bpo-38234: Backport init path config changes from master (GH-16423)
* bpo-38234: Py_SetPath() uses the program full path (GH-16357)

Py_SetPath() now sets sys.executable to the program full path
(Py_GetProgramFullPath()), rather than to the program name
(Py_GetProgramName()).

Fix also memory leaks in pathconfig_set_from_config().

(cherry picked from commit 1ce152a42e)

* bpo-38234: Add tests for Python init path config (GH-16358)


(cherry picked from commit bb6bf7d342)

* bpo-38234: test_embed: test pyvenv.cfg and pybuilddir.txt (GH-16366)

Add test_init_pybuilddir() and test_init_pyvenv_cfg() to test_embed
to test pyvenv.cfg and pybuilddir.txt configuration files.

Fix sysconfig._generate_posix_vars(): pybuilddir.txt uses UTF-8
encoding, not ASCII.

(cherry picked from commit 52ad33abbf)

* bpo-38234: Cleanup getpath.c (GH-16367)

* search_for_prefix() directly calls reduce() if found is greater
  than 0.
* Add calculate_pybuilddir() subfunction.
* search_for_prefix(): add path string buffer for readability.
* Fix some error handling code paths: release resources on error.
* calculate_read_pyenv(): rename tmpbuffer to filename.
* test.pythoninfo now also logs windows.dll_path

(cherry picked from commit 221fd84703)

* bpo-38234: Fix test_embed pathconfig tests (GH-16390)

bpo-38234: On macOS and FreeBSD, the temporary directory can be
symbolic link. For example, /tmp can be a symbolic link to /var/tmp.
Call realpath() to resolve all symbolic links.

(cherry picked from commit 00508a7407)

* bpo-38234: Add test_init_setpath_config() to test_embed (GH-16402)

* Add test_embed.test_init_setpath_config(): test Py_SetPath()
  with PyConfig.
* test_init_setpath() and test_init_setpythonhome() no longer call
  Py_SetProgramName(), but use the default program name.
* _PyPathConfig: isolated, site_import  and base_executable
  fields are now only available on Windows.
* If executable is set explicitly in the configuration, ignore
  calculated base_executable: _PyConfig_InitPathConfig() copies
  executable to base_executable.
* Complete path config documentation.

(cherry picked from commit 8bf39b606e)

* bpo-38234: Complete init config documentation (GH-16404)


(cherry picked from commit 88feaecd46)

* bpo-38234: Fix test_embed.test_init_setpath_config() on FreeBSD (GH-16406)

Explicitly preinitializes with a Python preconfiguration to avoid
Py_SetPath() implicit preinitialization with a compat
preconfiguration.

Fix also test_init_setpath() and test_init_setpythonhome() on macOS:
use self.test_exe as the executable (and base_executable), rather
than shutil.which('python3').

(cherry picked from commit 49d99f01e6)

* bpo-38234: Py_Initialize() sets global path configuration (GH-16421)

* Py_InitializeFromConfig() now writes PyConfig path configuration to
  the global path configuration (_Py_path_config).
* Add test_embed.test_get_pathconfig().
* Fix typo in _PyWideStringList_Join().

(cherry picked from commit 12f2f177fc)
2019-09-26 16:17:34 +02:00
Miss Islington (bot) a7c73a0094
closes bpo-38253: Fix typo of Py_SET_ERANGE_IF_OVERFLOW in pyport.h. (GH-16230)
(cherry picked from commit 4346bad332)

Co-authored-by: Hai Shi <shihai1992@gmail.com>
2019-09-23 19:41:06 -07:00
Victor Stinner c5c642565e
bpo-38236: Dump path config at first import error (GH-16300) (GH-16332)
Python now dumps path configuration if it fails to import the Python
codecs of the filesystem and stdio encodings.

(cherry picked from commit fcdb027234)
2019-09-23 15:59:00 +02:00
Victor Stinner 9f3dcf802e
[3.8] bpo-38234: Fix PyConfig_Read() when Py_SetPath() was called (GH-16298) (GH-16313)
* bpo-38234: Remove _PyPathConfig.dll_path (GH-16307)

The DLL path is not computed from any user configuration and cannot
be configured by PyConfig. Instead, add a new _Py_dll_path global variable.

Remove _PyConfig_SetPathConfig(): replaced with _PyPathConfig_Init().

Py_Initialize() now longer sets the "global path configuration",
but only initialize _Py_dll_path.

(cherry picked from commit c422167749)

* bpo-38234: Fix PyConfig_Read() when Py_SetPath() was called (GH-16298)

* If Py_SetPath() has been called, _PyConfig_InitPathConfig() now
  uses its value.
* Py_Initialize() now longer copies path configuration from PyConfig
  to the global path configuration (_Py_path_config).

(cherry picked from commit e267793aa4)
2019-09-21 02:13:14 +02:00
Victor Stinner 245d439320
bpo-38205: Py_UNREACHABLE() calls Py_FatalError() (GH-16290) (GH-16306)
(cherry picked from commit b1542583be)
2019-09-20 23:36:32 +02:00
Miss Islington (bot) 8d9efc4a27 Fix _PyTraceMalloc_Fini() definition (GH-16259) (GH-16278)
The function return type is void, not int.
(cherry picked from commit d299b8b47d)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2019-09-19 08:41:35 +02:00
Victor Stinner 47bbab9f76
[3.8] bpo-38070: Py_FatalError() logs runtime state (GH-16258)
* bpo-38070: _Py_DumpTraceback() writes <no Python frame> (GH-16244)

When a Python thread has no frame, _Py_DumpTraceback() and
_Py_DumpTracebackThreads() now write "<no Python frame>", rather than
writing nothing.

(cherry picked from commit 8fa3e1740b)

* bpo-38070: Enhance _PyObject_Dump() (GH-16243)

_PyObject_Dump() now dumps the object address for freed objects and
objects with ob_type=NULL.

(cherry picked from commit b39afb7876)

* bpo-38070: Add _PyRuntimeState.preinitializing (GH-16245)

Add _PyRuntimeState.preinitializing field: set to 1 while
Py_PreInitialize() is running.

_PyRuntimeState: rename also pre_initialized field to preinitialized.

(cherry picked from commit d3b904144e)

* bpo-38070: Py_FatalError() logs runtime state (GH-16246)


(cherry picked from commit 1ce16fb097)
2019-09-18 14:10:16 +02:00
Serhiy Storchaka f37a983102
[3.8] bpo-38005: Fixed comparing and creating of InterpreterID and ChannelID. (GH-15652) (GH-16145)
* Fix a crash in comparing with float (and maybe other crashes).
* They are now never equal to strings and non-integer numbers.
* Comparison with a large number no longer raises OverflowError.
* Arbitrary exceptions no longer silenced in constructors and comparisons.
* TypeError raised in the constructor contains now the name of the type.
* Accept only ChannelID and int-like objects in channel functions.
* Accept only InterpreterId, int-like objects and str in the InterpreterId constructor.
* Accept int-like objects, not just int in interpreter related functions.
(cherry picked from commit bf169915ec)
2019-09-14 19:36:19 +03:00
Miss Islington (bot) 4bd1d05ee2
Fix typos mostly in comments, docs and test names (GH-15209)
(cherry picked from commit 39d87b5471)

Co-authored-by: Min ho Kim <minho42@gmail.com>
2019-08-30 13:42:54 -07:00
Łukasz Langa 1553e3b5fc
Post v3.8.0b4 2019-08-30 11:01:34 +02:00
Łukasz Langa d93605de72
Python 3.8.0b4 2019-08-29 23:59:20 +02:00
Serhiy Storchaka 96631dcb11
[3.8] bpo-37034: Display argument name on errors with keyword arguments with Argument Clinic. (GH-13593). (GH-15599)
(cherry picked from commit 4901fe274b)

Co-authored-by: Rémi Lapeyre <remi.lapeyre@henki.fr>
2019-08-29 18:29:59 +03:00
Miss Islington (bot) 1d4285a042
bpo-36763: Make Py_BytesMain() public (GH-15532)
Declare Py_BytesMain() in Include/pylifecycle.h, rather in
Include/internal/pycore_pylifecycle.h.
(cherry picked from commit 9a943b4ce1)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2019-08-26 16:17:56 -07:00
Nick Coghlan 6ca030765d
[3.8] bpo-37757: Disallow PEP 572 cases that expose implementation details (GH-15491)
- drop TargetScopeError in favour of raising SyntaxError directly
  as per the updated PEP 572
- comprehension iteration variables are explicitly local, but
  named expression targets in comprehensions are nonlocal or
  global. Raise SyntaxError as specified in PEP 572
- named expression targets in the outermost iterable of a
  comprehension have an ambiguous target scope. Avoid resolving
  that question now by raising SyntaxError. PEP 572
  originally required this only for cases where the bound name
  conflicts with the iteration variable in the comprehension,
  but CPython can't easily restrict the exception to that case
  (as it doesn't know the target variable names when visiting
  the outermost iterator expression)

(cherry picked from commit 5dbe0f59b7)
2019-08-26 00:41:47 +10:00
Victor Stinner af84a88ef8
bpo-36763: PyConfig_Read() handles PySys_AddXOption() (GH-15431) (GH-15435)
PyConfig_Read() is now responsible to handle early calls to
PySys_AddXOption() and PySys_AddWarnOption().

Options added by PySys_AddXOption() are now handled the same way than
PyConfig.xoptions and command line -X options.

For example, PySys_AddXOption(L"faulthandler") enables faulthandler
as expected.

(cherry picked from commit 120b707a6d)
2019-08-23 21:16:51 +02:00
Miss Islington (bot) a6427cb2a2
bpo-36763: Implement PyWideStringList_Insert() of PEP 587 (GH-15423)
(cherry picked from commit 3842f2997f)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2019-08-23 09:24:42 -07:00
Victor Stinner 944aa01a81
Fix _PyTime_MIN/MAX values (GH-15384) (GH-15426)
_PyTime_t type is defined as int64_t, and so min/max are INT64_MIN/INT64_MAX,
not PY_LLONG_MIN/PY_LLONG_MAX.

(cherry picked from commit 8e76c45622)
2019-08-23 17:17:52 +01:00
Steve Dower 9eb3d54639
bpo-37834: Normalise handling of reparse points on Windows (GH-15370)
bpo-37834: Normalise handling of reparse points on Windows
* ntpath.realpath() and nt.stat() will traverse all supported reparse points (previously was mixed)
* nt.lstat() will let the OS traverse reparse points that are not name surrogates (previously would not traverse any reparse point)
* nt.[l]stat() will only set S_IFLNK for symlinks (previous behaviour)
* nt.readlink() will read destinations for symlinks and junction points only

bpo-1311: os.path.exists('nul') now returns True on Windows
* nt.stat('nul').st_mode is now S_IFCHR (previously was an error)
2019-08-21 15:52:42 -07:00
Łukasz Langa adc0e313ca
Post v3.8.0b3 2019-07-29 22:54:13 +02:00
Łukasz Langa 4336222407
Python 3.8.0b3 2019-07-29 15:26:01 +02:00