Commit Graph

1008 Commits

Author SHA1 Message Date
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) 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
Miss Islington (bot) 14ddca726a
bpo-38206: Clarify tp_dealloc requirements for heap allocated types. (GH-16248)
As mentioned in the bpo ticket, this mistake came up on two reviews:
- https://github.com/python/cpython/pull/16127GH-pullrequestreview-288312751
- https://github.com/python/cpython/pull/16071GH-pullrequestreview-287819525

Would be nice to have it documented in a more permanent place than 3.8's whatsnew entry.

https://bugs.python.org/issue38206

Automerge-Triggered-By: @encukou
(cherry picked from commit 5faff977ad)

Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
2019-09-27 04:18:24 -07: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
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
Miss Islington (bot) b65be6cd3d bpo-38158: Removing nonexistant member "doc" from PyType_Spec documentation (GH-16142) (GH-16154)
(cherry picked from commit 8b31a11a69)

Co-authored-by: t k <tahia.khan@utoronto.ca>
2019-09-15 08:00:44 +01:00
Miss Islington (bot) 4556b1d35c
bpo-29986: Doc: Delete tip to raise TypeError from tp_richcompare. (GH-16095)
(cherry picked from commit 375a3e2bdb)

Co-authored-by: Julien Palard <julien@palard.fr>
2019-09-13 06:14:42 -07:00
Miss Islington (bot) 4145f62759
Emphasize the need to always call PySequence_Fast. (GH-11140)
(cherry picked from commit 57b7dbc46e)

Co-authored-by: Matti Picus <matti.picus@gmail.com>
2019-09-12 09:26:17 -07:00
Miss Islington (bot) 2f01cf6187
bpo-37363: Document internal audit events (GH-14663)
Three internal cpython events were not documented, yet.

Signed-off-by: Christian Heimes <christian@python.org>

https://bugs.python.org/issue37363
(cherry picked from commit ed4b3216e5)

Co-authored-by: Christian Heimes <christian@python.org>
2019-09-12 06:20:26 -07:00
Miss Islington (bot) 535863e3f5
bpo-26868: Fix example usage of PyModule_AddObject. (GH-15725)
* Add a note to the PyModule_AddObject docs.

* Correct example usages of PyModule_AddObject.

* Whitespace.

* Clean up wording.

* 📜🤖 Added by blurb_it.

* First code review.

* Add < 0 in the tests with PyModule_AddObject
(cherry picked from commit 224b8aaa7e)

Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
2019-09-12 05:26:46 -07:00
Stéphane Wirtel 965e53a9de
[3.8] bpo-37698: Update doc of PyBuffer_ToContiguous (GH-14992) (GH-15999)
https://bugs.python.org/issue37698
(cherry picked from commit 15f5a7527b)

Co-authored-by: Hai Shi <shihai1992@gmail.com>
2019-09-11 19:36:00 +02:00
Miss Islington (bot) 4cab7eb9e1 bpo-37750: Add doc of PyBuffer_FromContiguous (GH-15988) (GH-15990)
https://bugs.python.org/issue37750

Automerge-Triggered-By: @matrixise
(cherry picked from commit 5a56ce4a0e)

Co-authored-by: Hai Shi <shihai1992@gmail.com>
2019-09-11 19:09:57 +02:00
Miss Islington (bot) e0dd713370
bpo-38103: fix conflicting labels in the docs. (GH-15906)
(cherry picked from commit 2d8d597bb8)

Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
2019-09-11 05:28:06 -07:00
Miss Islington (bot) 78c3949407
Docs: Small tweaks to c-api/introGH-Include_Files (GH-14698)
(cherry picked from commit b6dafe5139)

Co-authored-by: Kyle Stanley <aeros167@gmail.com>
2019-09-10 09:38:07 -07: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
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
Miss Islington (bot) 9cbdce3917
bpo-36763, doc: Add links in the new C API init doc (GH-15433)
(cherry picked from commit 1beb7c3de9)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2019-08-23 10:05:59 -07: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
Miss Islington (bot) 375f35be06 bpo-36487: Make C-API docs clear about what the main interpreter is. (gh-15080)
(cherry picked from commit 854d0a4b98) (gh-12666)

Co-authored-by: Joannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com>
2019-08-02 11:49:38 -06:00
Miss Islington (bot) 29a3a33d99
bpo-34101: Add doc of PyBuffer_GetPointer (GH-14994)
(cherry picked from commit 1b29af83bc)

Co-authored-by: Hai Shi <shihai1992@gmail.com>
2019-07-31 08:04:31 -07:00
Miss Islington (bot) 69372eea08
Remove trailing .0 from version changed note (GH-14987)
(cherry picked from commit 17a058ed6f)

Co-authored-by: Nick Coghlan <ncoghlan@gmail.com>
2019-07-28 04:48:26 -07:00
Miss Islington (bot) 35d36dacd4
Docs: Correct formatting of a multiline code block (GH-13806)
(cherry picked from commit bd26a4466b)

Co-authored-by: Joseph Fox-Rabinovitz <madphysicist@users.noreply.github.com>
2019-07-17 01:32:53 -07:00
Miss Islington (bot) 7a430109b9 bpo-37590: Remove redundant docs of PyEval_EvalFrameEx (GH-14765)
(cherry picked from commit 40d2226a69)

Co-authored-by: Hai Shi <shihai1992@gmail.com>
2019-07-14 10:53:18 +02:00
Miss Islington (bot) ad3720359f bpo-37487: Fix PyList_GetItem index description. (GH-14623) (GH-14624)
0 is a legal index.
(cherry picked from commit f8709e804d)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2019-07-06 17:54:56 -04:00
Miss Islington (bot) cf294c48e4
closes bpo-37508: Fix name of type in memory.rst. (GH-14604)
(cherry picked from commit 39a5d17a7f)

Co-authored-by: Hai Shi <shihai1992@gmail.com>
2019-07-05 21:09:57 -07:00
Miss Islington (bot) b8e198a5d0
bpo-37441: Fix wrong PyErr_SetImportErrorSubclass signature in doc (GH-14453)
(cherry picked from commit aeecf38066)

Co-authored-by: Hai Shi <shihai1992@gmail.com>
2019-07-02 19:04:29 -07:00
Miss Islington (bot) 96f581cf9d
bpo-36763: Add PyConfig_SetWideStringList() (GH-14444)
(cherry picked from commit 36242fd871)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2019-07-01 10:39:58 -07:00
Miss Islington (bot) cb083f7cdf bpo-37221: Add PyCode_NewWithPosOnlyArgs to be used internally and set PyCode_New as a compatibility wrapper (GH-13959) (#14505)
Add PyCode_NewEx to be used internally and set PyCode_New as a compatibility wrapper
(cherry picked from commit 4a2edc34a4)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2019-07-01 13:29:14 +02:00
Miss Islington (bot) ad00640f93
bpo-37432: Doc: Fix signature of PyObject_Del() (GH-14430)
(cherry picked from commit b4bee03087)

Co-authored-by: Hai Shi <shihai1992@gmail.com>
2019-06-28 02:16:36 -07:00
Miss Islington (bot) 4fee28aa42
bpo-37390: Add audit event table to documentations (GH-14406)
Also updates some (unreleased) event names to be consistent with the others.
(cherry picked from commit 44f91c388a)

Co-authored-by: Steve Dower <steve.dower@python.org>
2019-06-27 11:07:16 -07:00
Miss Islington (bot) 6258c1f716
bpo-37342: Fix the incorrect nb_index's type in typeobj documentation (GH-14241)
It was listed as `binaryfunc`. It should be `unaryfunc`.
(cherry picked from commit bc5caf88ca)

Co-authored-by: Hai Shi <shihai1992@gmail.com>
2019-06-19 20:41:41 -07:00
Victor Stinner 71031cf4ed
bpo-37194: Complete PyObject_CallXXX() docs (GH-14156) (GH-14157)
Mention explicitly that PyObject_CallXXX() functions raise an
exception an failure.

(cherry picked from commit 1ce2656f13)
2019-06-17 15:23:59 +02:00
Miss Islington (bot) e784f9f1c3
bpo-28805: document METH_FASTCALL (GH-14079)
(cherry picked from commit 5600b5e1b2)

Co-authored-by: Jeroen Demeyer <J.Demeyer@UGent.be>
2019-06-16 16:25:37 -07:00
Victor Stinner f9445a391e
[3.8] bpo-37253: Document PyCompilerFlags.cf_feature_version (GH-14019) (GH-14038)
* Update PyCompilerFlags structure documentation.
* Document the new cf_feature_version field in the Changes in the C
  API section of the What's New in Python 3.8 doc.

(cherry picked from commit 2c9b498759)
2019-06-13 02:40:41 +02:00
Zackery Spytz dd492d9c35 [3.8] bpo-37170: Fix the cast on error in PyLong_AsUnsignedLongLongMask() (GH-13860) (GH-13891)
(cherry picked from commit dc2476500d)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2019-06-07 16:22:58 +02:00
Jeroen Demeyer 9e3e06e582 bpo-36974: document PEP 590 (GH-13450) 2019-06-03 01:43:13 +02:00
Serhiy Storchaka bdbad71b9d
bpo-20092. Use __index__ in constructors of int, float and complex. (GH-13108) 2019-06-02 00:05:48 +03:00
Pablo Galindo 3b57f50efc
bpo-36842: Pass positional only parameters to code_new audit hook (GH-13707) 2019-06-01 21:18:48 +01:00
Pablo Galindo cd74e66a8c
bpo-37122: Make co->co_argcount represent the total number of positonal arguments in the code object (GH-13726) 2019-06-01 18:08:04 +01:00
Pablo Galindo 545a3b8814
Document changes for PyCode_New regarding PEP570 (GH-13706) 2019-05-31 19:33:41 +01:00
Antoine Pitrou ada319bb6d
bpo-32388: Remove cross-version binary compatibility requirement in tp_flags (GH-4944)
It is now allowed to add new fields at the end of the PyTypeObject struct without having to allocate a dedicated compatibility flag in tp_flags.

This will reduce the risk of running out of bits in the 32-bit tp_flags value.
2019-05-29 22:12:38 +02:00
Pablo Galindo b76302ddd0 bpo-36540: Documentation for PEP570 - Python positional only arguments (#13202)
* bpo-36540: Documentation for PEP570 - Python positional only arguments

* fixup! bpo-36540: Documentation for PEP570 - Python positional only arguments

* Update reference for compound statements

* Apply suggestions from Carol

Co-Authored-By: Carol Willing <carolcode@willingconsulting.com>

* Update Doc/tutorial/controlflow.rst

Co-Authored-By: Carol Willing <carolcode@willingconsulting.com>

* Add extra bullet point and minor edits
2019-05-28 16:45:32 -07:00
Zackery Spytz 3c8724fc60 bpo-33407: Implement Py_DEPRECATED() on MSVC (GH-8980) 2019-05-28 17:16:33 +02:00
Jeroen Demeyer eb65e2443a bpo-36922: implement PEP-590 Py_TPFLAGS_METHOD_DESCRIPTOR (GH-13338)
Co-authored-by: Mark Shannon <mark@hotpy.org>
2019-05-28 14:42:53 +02:00
Victor Stinner 331a6a56e9
bpo-36763: Implement the PEP 587 (GH-13592)
* Add a whole new documentation page:
  "Python Initialization Configuration"
* PyWideStringList_Append() return type is now PyStatus,
  instead of int
* PyInterpreterState_New() now calls PyConfig_Clear() if
  PyConfig_InitPythonConfig() fails.
* Rename files:

  * Python/coreconfig.c => Python/initconfig.c
  * Include/cpython/coreconfig.h => Include/cpython/initconfig.h
  * Include/internal/: pycore_coreconfig.h => pycore_initconfig.h

* Rename structures

  * _PyCoreConfig => PyConfig
  * _PyPreConfig => PyPreConfig
  * _PyInitError => PyStatus
  * _PyWstrList => PyWideStringList

* Rename PyConfig fields:

  * use_module_search_paths => module_search_paths_set
  * module_search_path_env => pythonpath_env

* Rename PyStatus field: _func => func
* PyInterpreterState: rename core_config field to config
* Rename macros and functions:

  * _PyCoreConfig_SetArgv() => PyConfig_SetBytesArgv()
  * _PyCoreConfig_SetWideArgv() => PyConfig_SetArgv()
  * _PyCoreConfig_DecodeLocale() => PyConfig_SetBytesString()
  * _PyInitError_Failed() => PyStatus_Exception()
  * _Py_INIT_ERROR_TYPE_xxx enums => _PyStatus_TYPE_xxx
  * _Py_UnixMain() => Py_BytesMain()
  * _Py_ExitInitError() => Py_ExitStatusException()
  * _Py_PreInitializeFromArgs() => Py_PreInitializeFromBytesArgs()
  * _Py_PreInitializeFromWideArgs() => Py_PreInitializeFromArgs()
  * _Py_PreInitialize() => Py_PreInitialize()
  * _Py_RunMain() => Py_RunMain()
  * _Py_InitializeFromConfig() => Py_InitializeFromConfig()
  * _Py_INIT_XXX() => _PyStatus_XXX()
  * _Py_INIT_FAILED() => _PyStatus_EXCEPTION()

* Rename 'err' PyStatus variables to 'status'
* Convert RUN_CODE() macro to config_run_code() static inline function
* Remove functions:

  * _Py_InitializeFromArgs()
  * _Py_InitializeFromWideArgs()
  * _PyInterpreterState_GetCoreConfig()
2019-05-27 16:39:22 +02:00
Victor Stinner b3a9843cd1
Support Py_UNUSED() on clang (GH-13544) 2019-05-24 15:16:08 +02:00
Xtreak cf7d5ef49b Fix typo: decription -> description (GH-13543) 2019-05-24 04:17:47 -07: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