Commit Graph

27307 Commits

Author SHA1 Message Date
Raymond Hettinger 62405c7867
gh-110150: Fix base case handling in quantiles() (gh-110151) 2023-09-30 23:35:54 -05:00
Victor Stinner a46e960768
gh-109649: Use os.process_cpu_count() (#110165)
Replace os.cpu_count() with os.process_cpu_count() in modules:

* compileall
* concurrent.futures
* multiprocessing

Replace os.cpu_count() with os.process_cpu_count() in programs:

* _decimal deccheck.py test
* freeze.py
* multissltests.py
* python -m test (regrtest)
* wasm_build.py

Other changes:

* test.pythoninfo logs os.process_cpu_count().
* regrtest gets os.process_cpu_count() / os.cpu_count() in headers.
2023-10-01 03:14:57 +02:00
Victor Stinner c81521020d
gh-109649: Add os.process_cpu_count() function (#109907)
* Refactor os_sched_getaffinity_impl(): move variable definitions to
  their first assignment.
* Fix test_posix.test_sched_getaffinity(): restore the old CPU mask
  when the test completes!
* Doc: Specify that os.cpu_count() counts *logicial* CPUs.
* Doc: Specify that os.sched_getaffinity(0) is related to the calling
  thread.
2023-10-01 00:12:51 +02:00
Victor Stinner 7513994c92
gh-110014: Include explicitly <unistd.h> header (#110155)
* Remove unused <locale.h> includes.
* Remove unused <fcntl.h> include in traceback.h.
* Remove redundant <assert.h> and <stddef.h> includes. They  are already
  included by "Python.h".
* Remove <object.h> include in faulthandler.c. Python.h already includes it.
* Add missing <stdbool.h> in pycore_pythread.h if HAVE_PTHREAD_STUBS
  is defined.
* Fix also warnings in pthread_stubs.h: don't redefine macros if they
  are already defined, like the __NEED_pthread_t macro.
2023-09-30 20:06:45 +00:00
Victor Stinner 74e425ec18
gh-110014: Fix _POSIX_THREADS and _POSIX_SEMAPHORES usage (#110139)
* pycore_pythread.h is now the central place to make sure that
  _POSIX_THREADS and _POSIX_SEMAPHORES macros are defined if
  available.
* Make sure that pycore_pythread.h is included when _POSIX_THREADS
  and _POSIX_SEMAPHORES macros are tested.
* PY_TIMEOUT_MAX is now defined as a constant, since its value
  depends on _POSIX_THREADS, instead of being defined as a macro.
* Prevent integer overflow in the preprocessor when computing
  PY_TIMEOUT_MAX_VALUE on Windows:
  replace "0xFFFFFFFELL * 1000 < LLONG_MAX"
  with "0xFFFFFFFELL < LLONG_MAX / 1000".
* Document the change and give hints how to fix affected code.
* Add an exception for PY_TIMEOUT_MAX  name to smelly.py
* Add PY_TIMEOUT_MAX to the stable ABI
2023-09-30 19:25:54 +02:00
Adam Turner 0449fe999d
GH-101100: Fix reference warnings for ``gettext`` (#110115) 2023-09-30 05:10:07 -06:00
Adam Turner cbdacc738a
GH-101100: Fix reference warnings for ``namedtuple`` (#110113) 2023-09-29 23:32:35 -07:00
Raymond Hettinger 613c0d4e86
Add example for linear_regression() with proportional=True. (gh-110133) 2023-09-29 23:18:12 -05:00
Donghee Na 501939c9c1
gh-105323: Update readline module to detect apple editline variant (gh-108665) 2023-09-29 21:18:18 +09:00
Jacob Coffee e27adc68cc
gh-109634: Fix `:samp:` syntax (GH-110073) 2023-09-29 14:21:34 +03:00
Yuki K bfd94ab9e9
gh-101100: Fix references to ``URLError`` and ``HTTPError`` in ``howto/urllib2.rst`` (#107966)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-29 08:35:29 +00:00
Maciej Olko 8898a8683b
gh-101100: Fix Sphinx warnings in `tutorial/controlflow.rst` (#109424)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-09-29 11:27:43 +03:00
Nikita Sobolev f1b1680a72
gh-109961: Use proper `module` for `copy` method docs (#110027)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-09-29 11:26:55 +03:00
Nikita Sobolev d102d39bbe
gh-101100: Fix sphinx warnings in `library/difflib.rst` (#110074) 2023-09-29 11:03:59 +03:00
Jelle Zijlstra 7dc2c5093e
gh-110045: Update symtable module for PEP 695 (#110066) 2023-09-29 02:08:04 +00:00
Davide Rizzo c4eda57345
Whitespace fix in asyncio-stream.rst (#110015) 2023-09-28 09:34:35 -07:00
Nikita Sobolev 0baf72696e
gh-109961: Docs: Fix incorrect rendering of `__replace__` in `copy.rst` (#109968) 2023-09-28 14:51:33 +03:00
Adam Turner 526380e286
GH-109190: Copyedit 3.12 What's New: Bytecode (#109821)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-28 04:40:59 +00:00
Jacob Coffee 99fba5f156
gh-109812: Fix phrasing for `collections.Counter` (gh-109813) 2023-09-27 21:29:39 -05:00
Jelle Zijlstra f49958c886
Enhance TypedDict docs around required/optional keys (#109547)
As discussed in comments to #109544, the semantics of this attribute
are somewhat confusing. Add a note explaining its limitations and
steering users towards __required_keys__ and __optional_keys__ instead.
2023-09-27 10:35:46 -07:00
Sam Gross 773614e03a
gh-109740: Use 't' in `--disable-gil` SOABI (#109922)
Shared libraries for CPython 3.13 are now marked with a 't' for
threading. For example, `binascii.cpython-313t-darwin.so`.
2023-09-27 15:24:12 +00:00
Adam Turner b35f0843fc
GH-109190: Copyedit 3.12 What's New: Release highlights (#109770) 2023-09-27 17:31:55 +03:00
Nikita Sobolev d9809e84fb
gh-101100: Fix sphinx warnings in `library/devmode.rst` (#109963)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-09-27 16:07:28 +03:00
Adam Turner 0e28d0f7a1
GH-109190: Copyedit 3.12 What's New: Deprecations (``os`` fix) (#109927)
Merge the two ``os`` entries
2023-09-27 07:59:42 +03:00
Victor Stinner 3538930d87
gh-101100: Fix Sphinx warnings in Doc/using/configure.rst (#109931) 2023-09-27 02:01:48 +02:00
Adam Turner 87ddfa74e2
GH-109190: Copyedit 3.12 What's New: Deprecations (#109766) 2023-09-27 00:24:44 +03:00
Victor Stinner b1e4f6e83e
gh-109276, gh-109508: Fix libregrtest stdout (#109903)
Remove replace_stdout(): call sys.stdout.reconfigure() instead of set
the error handler to backslashreplace.

display_header() logs an empty line and flush stdout.

Remove encoding workaround in display_header() since stdout error
handler is now set to backslashreplace earlier.
2023-09-26 21:34:50 +02:00
Barney Gale ecd813f054
GH-109187: Improve symlink loop handling in `pathlib.Path.resolve()` (GH-109192)
Treat symlink loops like other errors: in strict mode, raise `OSError`, and
in non-strict mode, do not raise any exception.
2023-09-26 17:57:17 +01:00
Victor Stinner 859618c8cd
gh-109566, regrtest: Add --fast-ci and --slow-ci options (#109570)
* Add --fast-ci and --slow-ci options to libregrtest:

  * --fast-ci uses a default timeout of 10 minutes and "-u all,-cpu"
    (skip slowest tests).
  * --slow-ci uses a default timeout of 20 minues and "-u all" (run
    all tests).

* regrtest header now lists test resources.
* Makefile changes:

  * "make test", "make hostrunnertest" and "make coverage-report" now
    use --fast-ci option and TESTTIMEOUT variable.
  * "make buildbottest" now uses "--slow-ci". Remove options which
    became redundant with "--slow-ci".
  * "make testall" and "make testuniversal" now use --slow-ci option
    and TESTTIMEOUT variable.
  * "make testall" now uses "find -exec rm ..." instead of
    "find ... -print|xargs rm ...", same as "make clean".

* GitHub Actions workflow:

  * Ubuntu and Address Sanitizer jobs now use "make test". Remove
    options which became redundant with "--fast-ci".
  * Windows jobs now use --fast-ci option.
  * Use -j0 to detect the number of CPUs.

* Set Makefile TESTTIMEOUT default to an empty string, since
  --slow-ci and --fast-ci use different default timeout. It's now
  accepted to pass "--timeout=" to regrtest: treated as not timeout.
* Tools/scripts/run_tests.py now uses --fast-ci option.
* Tools/buildbot/test.bat now uses --slow-ci option. Remove
  --timeout=1200 option, redundant with --slow-ci.
2023-09-26 17:22:50 +02:00
lohaswinner 8100612bac
no-issue: Fix a typo in the parameter name of random.expovariate. (gh-109902) 2023-09-26 22:12:32 +09:00
Nikita Sobolev 7c61a361fc
gh-101100: Fix Sphinx warnings in `Doc/library/weakref.rst` (#109881) 2023-09-26 10:46:09 +03:00
Antoine Pitrou 88a6137cdb
gh-109599: Add types.CapsuleType (#109600)
---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-09-25 19:50:39 +02:00
Adam Turner 86e7c611ac
GH-109190: Copyedit 3.12 What's New: Sort Other Language Changes (#109836) 2023-09-25 17:42:03 +03:00
Adam Turner 64ab9f7d5c
GH-109190: Copyedit 3.12 What's New: Synchronise C API deprecations with the 3.12 branch (#109844) 2023-09-25 17:04:36 +03:00
Adam Turner bccc1b7800
GH-109190: Copyedit 3.12 What's New: Improve the C-API deprecations section (#109751)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-09-25 12:38:07 +00:00
Adam Turner 4e478534d7
GH-109190: Copyedit 3.12 What's New: Use the present tense (#109754) 2023-09-25 15:18:22 +03:00
Adam Turner f08772cfd8
GH-109190: Copyedit 3.12 What's New: Trivia (#109760) 2023-09-25 15:11:37 +03:00
Adam Turner 7495a93e0f
GH-109190: Copyedit 3.12 What's New: Prefer GitHub issues links (#109753) 2023-09-25 15:11:06 +03:00
Nikita Sobolev f2eaa92b0c
gh-101100: Fix sphinx warnings in `Doc/library/__future__.rst` (#109814) 2023-09-25 00:31:56 -06:00
Adam Turner 7b8bfe1644
GH-109190: Copyedit 3.12 What's New: Update the ``imp`` porting guidance (#109755) 2023-09-25 00:24:02 -06:00
Adam Turner 09a73d50f6
GH-109190: Copyedit 3.12 What's New: Increase the prominence of the setuptools removal (#109768) 2023-09-25 00:22:00 -06:00
Gregory P. Smith e81bd3fa16
Sync whatsnew with the edit I made in the 3.12 backport PR. (#109807)
A post main merge edit to the text was added in the 3.12 backport PR.
  e38d7104b8

This includes that in main.  It's a minor edit over #109767 to resolve the comment there.
2023-09-24 17:27:24 +00:00
Adam Turner 8d365b60ba
GH-109190: Copyedit 3.12 What's New: Use the ``:file:`` role (#109756)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-24 16:05:57 +00:00
Nikita Sobolev 649768fb67
gh-101100: Fix sphinx warnings in `Doc/library/xml.etree.elementtree.rst` (#109799)
gh-101100: Fix shpinx warnings in `Doc/library/xml.etree.elementtree.rst`
2023-09-24 12:49:02 +03:00
Serhiy Storchaka 92af0cc580
gh-109634: Use :samp: role (GH-109635) 2023-09-23 09:31:20 +03:00
Gregory P. Smith 5e7ea95d9d
gh-100228: Document the os.fork threads DeprecationWarning. (#109767)
Document the `os.fork` posix threads detected `DeprecationWarning` in 3.12 What's New, os, multiprocessing, and concurrent.futures docs.

Many reviews and doc cleanup edits by Adam & Hugo. 🥳 

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-23 05:04:20 +00:00
Adam Turner b10de68c6c
GH-95913: Add the release date for Python 3.11 (#109750) 2023-09-22 21:07:06 -07:00
Jelle Zijlstra 612400d446
Fix indentation in 3.13 What's New (#109769)
The previous layout made it look like the other three deprecations are part of the first one, when in fact they are independent.

The new layout is consistent with that used for sqlite3 in 3.12 (https://docs.python.org/3.13/whatsnew/3.12.html#deprecated).
2023-09-22 20:45:26 -07:00
Hugo van Kemenade 8a82bff12c
Docs: Update Donghee Na's name (#109743) 2023-09-22 12:52:57 -06:00
Adam Turner c32abf1f21
GH-109190: Copyedit 3.12 What's New: asyncio (#109661)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Itamar Oren <itamarost@gmail.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-22 15:32:32 +02:00
Adam Turner 168c3a8a89
GH-109190: Copyedit 3.12 What's New: PEP 669 (#109658)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-22 15:31:49 +02:00
Łukasz Langa 46b63ced25
Remove outdated docstring from the `quantify` itertools recipe (#109726) 2023-09-22 15:09:32 +02:00
Adam Turner cade5960ae
GH-109190: Copyedit 3.12 What's New: Other Language Changes (#109660) 2023-09-22 15:05:39 +02:00
Adam Turner e94a2232ea
GH-109190: Copyedit 3.12 What's New: PEP 684 (#109657) 2023-09-22 14:53:53 +02:00
Adam Turner d9415f6a45
GH-109190: Copyedit 3.12 What's New: bytecode (LOAD_METHOD) (#109665)
bytecode: suppress reference to removed LOAD_METHOD
2023-09-22 14:50:20 +02:00
Adam Turner 34ddcc3fa1
GH-109190: Copyedit 3.12 What's New: calendar (#109662)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-22 06:29:48 +00:00
Adam Turner d3fe1a902f
GH-109190: Copyedit 3.12 What's New: tokenize (#109663) 2023-09-22 00:28:13 -06:00
Adam Turner 291401389b
GH-109190: Copyedit 3.12 What's New: Consistently show module names (#109664)
Consistently show module names
2023-09-22 08:37:44 +03:00
Adam Turner e47d12e222
GH-109190: Copyedit 3.12 What's New: PEP 701 (#109655) 2023-09-21 13:37:28 -06:00
Adam Turner 16c24023c1
GH-109190: Copyedit 3.12 What's New: Improved Error Messages (#109654) 2023-09-21 13:24:44 -06:00
Adam Turner 11636788da
GH-109190: Copyedit 3.12 What's New: Typing PEPs (#109659) 2023-09-21 13:05:54 -06:00
Adam Turner 22b70ca480
GH-109190: Copyedit 3.12 What's New: PEP 709 (#109656) 2023-09-21 12:50:33 -06:00
AN Long 869f177b5c
gh-74481: Add missing debug function docs and constants to msvcrt (GH-109650) 2023-09-21 16:44:24 +01:00
Adam Turner 712cb173f8
GH-109209: Bump the minimum Sphinx version to 4.2 (#109210) 2023-09-21 09:06:36 +03:00
Heinz-Alexander Fuetterer ef6d475db3
Fix typos in docs and comments (#109619) 2023-09-20 16:58:23 +00:00
Victor Stinner d41d2e69f6
gh-109054: Document configure variables (#109224) 2023-09-20 18:51:53 +02:00
Victor Stinner ced6924630
gh-108973: Fix asyncio test_subprocess_consistent_callbacks() (#109431)
SubprocessProtocol process_exited() method can be called before
pipe_data_received() and pipe_connection_lost() methods. Document it
and adapt the test for that.

Revert commit 282edd7b2a.
_child_watcher_callback() calls immediately _process_exited(): don't
add an additional delay with call_soon(). The reverted change didn't
make _process_exited() more determistic: it can still be called
before pipe_connection_lost() for example.

Co-authored-by: Davide Rizzo <sorcio@gmail.com>
2023-09-20 15:54:19 +02:00
James Gerity def828995a
fixes gh-109559: Update `unicodedata` for Unicode 15.1.0 (GH-109560)
---------

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2023-09-19 22:07:47 -07:00
Mateusz Nowak 5a740cd06e
gh-109109: Expose retrieving certificate chains in SSL module (#109113)
Adds APIs to get the TLS certificate chains, verified or full unverified, from SSLSocket and SSLObject.

Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
2023-09-20 01:20:54 +00:00
Raymond Hettinger f2636d2c45
Misc itertool recipe improvements, mostly docstrings and comments (gh-109555) 2023-09-19 07:39:44 -05:00
Victor Stinner 59f32a785f
gh-109435: Add Doc/library/cmdline.rst (#109436)
Document modules providing a command-line interface (CLI).
2023-09-19 13:57:28 +02:00
Xuehai Pan 74f315edd0
gh-102757: fix function signature mismatch for `functools.reduce` between code and documentation (#102759) 2023-09-18 10:42:58 -06:00
Hugo van Kemenade 2209d814ca
Docs: getopt is deprecated in Python 3.13 (#109438) 2023-09-18 13:45:59 +03:00
Anthony Sottile ce5b3e19e6
Fix extraneous backslashes in hashlib docs (#109468) 2023-09-18 00:25:33 -07:00
Serhiy Storchaka add16f1a5e
gh-108511: Add C API functions which do not silently ignore errors (GH-109025)
Add the following functions:

* PyObject_HasAttrWithError()
* PyObject_HasAttrStringWithError()
* PyMapping_HasKeyWithError()
* PyMapping_HasKeyStringWithError()
2023-09-17 14:23:31 +03:00
AlberLC 929cc4e4a0
gh-109451: Fix wrong format specifier in logging documentation (GH-109465) 2023-09-16 10:06:04 +01:00
Vinay Sajip a6846d45ff
gh-109414: Add some basic information about venvs in the introduction. (GH-109440)
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-16 09:49:02 +01:00
partev 0b38ce440b
gh-109474: Update two Unix packaging URLs (#109307)
update packaging URLs

fix a broken URL for fedora RPM packaging guide and fix a URL redirect for Slackware packaging guide.
2023-09-16 10:46:09 +03:00
Brett Cannon e218e5022e
GH-83417: Allow `venv` to add a `.gitignore` file to environments via a new `scm_ignore_file` parameter (GH-108125)
This feature is off by default via code but on by default via the CLI. The `.gitignore` file contains `*` which causes the entire directory to be ignored.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-15 22:38:08 +00:00
Gregory P. Smith 59073c9ab8
gh-109096: Deprecate `http.server.CGIHTTPRequestHandler` (#109387)
Deprecate `http.server.CGIHTTPRequestHandler`.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-09-15 14:26:45 -07:00
Egil Martinsson 3d881453d3
gh-109350: Fix outdated captured output in unittest.mock documentation (#109353) 2023-09-15 19:25:16 +01:00
Hugo van Kemenade b434dd7e36
Docs: Superseded modules: list only module names (#109439) 2023-09-15 15:56:23 +03:00
Nikita Sobolev 21e80f4c19
gh-101100: Fix sphinx warnings in `turtle.rst` (#109394) 2023-09-14 14:24:18 -04:00
Victor Stinner d7a27e527d
gh-107298: Document PyMODINIT_FUNC macro (#109236)
Document PyMODINIT_FUNC macro.

Remove links to PyAPI_FUNC() and PyAPI_DATA() macros since they are
not documented. These macros should only be used to define the Python
C API. They should not be used outside Python code base.
2023-09-14 14:56:43 +02:00
Brandt Bucher 22e65eecaa
GH-105848: Replace KW_NAMES + CALL with LOAD_CONST + CALL_KW (GH-109300) 2023-09-13 10:25:45 -07:00
Oleksandr Kravets a0c06a4f93
Fix variable name in dis documentation example (GH-109343)
BINARY_SUBSCR example erroneously uses two different names `key` and `index` to refer to the same variable. STORE_SUBSCR and DELETE_SUBSCR use only `key` in the same context. Changing `index` to `key` for consistency.
2023-09-13 08:07:56 +03:00
Thomas Grainger 6c0ddca409
gh-105189: fix importlib.resources.abc deprecation docs (#105232)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-09-13 07:42:26 +03:00
Adam Turner 90cf345ed4
GH-104395: Add a link in 'Meta Information' to the docs download page (#104443)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-12 20:32:13 +00:00
Irit Katriel b303d3ad3e
gh-109319: deprecate dis.HAVE_ARGUMENT (#109320) 2023-09-12 16:45:35 +01:00
Irit Katriel 0e76cc359b
gh-109184: update traceback module doc w.r.t notes (message is no longer always at the end) (#109201) 2023-09-12 14:54:04 +00:00
AN Long e121fca33b
gh-109266: Fix msvcrt.kbhit's documented return value (GH-109267) 2023-09-12 15:44:48 +01:00
Irit Katriel 8b55adfa8f
gh-109256: allocate opcode IDs for internal opcodes in their own range (#109269) 2023-09-12 10:36:17 +00:00
Raymond Hettinger f2a55fecd0
Fix iter_index() to work with lists which do not support stop=None. (gh-109306) 2023-09-12 04:04:28 +02:00
Carl Meyer 2b1e2f1cd1
gh-109292: add symtable impact of PEP 709 to What's New (#109293) 2023-09-11 18:03:04 -06:00
wim glenn 1ee50e2a78
gh-107322: zipapp: Remove the suggestion to remove .dist-info directories (#107296)
Removed zipapp suggestion to rm .dist-info subdirectories. This totally breaks importlib.metadata
2023-09-11 15:44:13 -04:00
Hugo van Kemenade 57b6205523
gh-109190: What's New in 3.12: Add subheadings to removals for easy linking (#109159)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-09-11 19:06:16 +03:00
Delgan 2dd6a86c4e
Fix "FSTRING_MIDDLE" typo in py312 "What's New" (#109222) 2023-09-10 10:55:56 +00:00
Serhiy Storchaka 92578919a6
gh-109174: Add support of SimpleNamespace in copy.replace() (GH-109175) 2023-09-10 08:09:25 +03:00
Raymond Hettinger d3ed9921cd
Improve the sieve() recipe in the itertools docs (gh-109199)
Lazier sieve
2023-09-09 17:50:04 -05:00
Shantanu 74fc96bc60
Add version directives to ast docs (#108788) 2023-09-07 11:34:18 -07:00
Christoph Anton Mitterer 403ab1306a
gh-107924: re-order os.sendfile() flag documentation (#107926)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-07 18:50:10 +03:00
Mark Dickinson b72251de93
gh-102823: Document return type of floor division on floats (#102824)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-07 14:20:33 +00:00
Nikita Sobolev ac31f714c3
gh-107544: Add docs about `json.dumps(..., default=)` (#108259) 2023-09-07 06:53:33 -07:00
Stanley 891236f482
gh-71770: Add more details on behavior of configparser's default_section (#31562)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-07 13:52:58 +00:00
Colin Watson 1294fcede0
GH-90915: Document that SystemExit doesn't trigger sys.excepthook (#31357)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-07 13:14:27 +00:00
Ori Hoch 6b15ff5235
socket documentation fix - rename triple to 3-tuple (#24722)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-07 10:33:02 +00:00
Karthikeyan Singaravelan e183a71eef
bpo-38157: Add example about per file output for mock_open. (#16090)
Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-07 09:19:13 +00:00
Adam Turner f0f96a9f40
GH-108202: Document ``calendar``'s command-line interface (#109020)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-06 21:19:54 +00:00
Serhiy Storchaka 6f3c138dfa
gh-108751: Add copy.replace() function (GH-108752)
It creates a modified copy of an object by calling the object's
__replace__() method.

It is a generalization of dataclasses.replace(), named tuple's _replace()
method and replace() methods in various classes, and supports all these
stdlib classes.
2023-09-06 23:55:42 +03:00
Shahriar Heidrich 9f0c0a46f0
gh-107732: Mention dir support in importlib.resources docs (#107734)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-06 20:53:32 +00:00
Anthony Shaw f9bd6e49ae
GH-90690: Mention removal of ``PRECALL`` in What's New (#103910)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-06 20:28:00 +00:00
Victor Stinner db1ee6a19a
gh-108740: Fix "make regen-all" race condition (#108741)
Fix a race condition in "make regen-all". The deepfreeze.c source and
files generated by Argument Clinic are now generated or updated
before generating "global objects". Previously, some identifiers may
miss depending on the order in which these files were generated.

* "make regen-global-objects": Make sure that deepfreeze.c is
  generated and up to date, and always run "make clinic".
* "make clinic" no longer runs generate_global_objects.py script.
* "make regen-deepfreeze" now only updates deepfreeze.c (C file).
  It doesn't build deepfreeze.o (object) anymore.
* Remove misleading messages in "make regen-global-objects" and
  "make clinic". They are now outdated, these commands are now
  safe to use.
* Document generates files in Doc/using/configure.rst.

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-09-06 20:09:21 +02:00
Victor Stinner a0773b89df
gh-108753: Enhance pystats (#108754)
Statistics gathering is now off by default. Use the "-X pystats"
command line option or set the new PYTHONSTATS environment variable
to 1 to turn statistics gathering on at Python startup.

Statistics are no longer dumped at exit if statistics gathering was
off or statistics have been cleared.

Changes:

* Add PYTHONSTATS environment variable.
* sys._stats_dump() now returns False if statistics are not dumped
  because they are all equal to zero.
* Add PyConfig._pystats member.
* Add tests on sys functions and on setting PyConfig._pystats to 1.
* Add Include/cpython/pystats.h and Include/internal/pycore_pystats.h
  header files.
* Rename '_py_stats' variable to '_Py_stats'.
* Exclude Include/cpython/pystats.h from the Py_LIMITED_API.
* Move pystats.h include from object.h to Python.h.
* Add _Py_StatsOn() and _Py_StatsOff() functions. Remove
  '_py_stats_struct' variable from the API: make it static in
  specialize.c.
* Document API in Include/pystats.h and Include/cpython/pystats.h.
* Complete pystats documentation in Doc/using/configure.rst.
* Don't write "all zeros" stats: if _stats_off() and _stats_clear()
  or _stats_dump() were called.
* _PyEval_Fini() now always call _Py_PrintSpecializationStats() which
  does nothing if stats are all zeros.

Co-authored-by: Michael Droettboom <mdboom@gmail.com>
2023-09-06 15:54:59 +00:00
nabin2004 6f8411cfd6
gh-108857: improve markup in inspect.Signature.replace() docs (#108862) 2023-09-05 17:27:59 -07:00
wim glenn 9bf350b066
gh-107755: Document the correct default value of slice step (GH-107756)
Document the correct default value of slice step.
2023-09-05 21:22:27 +02:00
Nikita Sobolev ad1d6a1c20
gh-108903: Remove unneeded `lambda`s from `asyncio` (GH-108904) 2023-09-05 18:11:12 +03:00
Mark Shannon 8b515f60ee
GH-103082: Document PEP-669: Low Impact Monitoring for CPython (GH-107772) 2023-09-05 12:35:52 +01:00
Tian Gao 6304d983a0
gh-108463: Make expressions/statements work as expected in pdb (#108464) 2023-09-04 21:44:40 +00:00
Hugo van Kemenade 7855d325e6
Link to PEP sections in What's New in 3.12 (#108878) 2023-09-04 15:02:25 -06:00
Victor Stinner 03c4080c71
gh-108765: Python.h no longer includes <ctype.h> (#108831)
Remove <ctype.h> in C files which don't use it; only sre.c and
_decimal.c still use it.

Remove _PY_PORT_CTYPE_UTF8_ISSUE code from pyport.h:

* Code added by commit b5047fd019
  in 2004 for MacOSX and FreeBSD.
* Test removed by commit 52ddaefb6b
  in 2007, since Python str type now uses locale independent
  functions like Py_ISALPHA() and Py_TOLOWER() and the Unicode
  database.

Modules/_sre/sre.c replaces _PY_PORT_CTYPE_UTF8_ISSUE with new
functions: sre_isalnum(), sre_tolower(), sre_toupper().

Remove unused includes:

* _localemodule.c: remove <stdio.h>.
* getargs.c: remove <float.h>.
* dynload_win.c: remove <direct.h>, it no longer calls _getcwd()
  since commit fb1f68ed7c (in 2001).
2023-09-03 18:54:27 +02:00
Raymond Hettinger f373c6b948
gh-107208: Fix iter_index() recipe to not swallow exceptions (gh-108835)
gh-107208: iter_index now supports "stop" and no longer swallows ValueError
2023-09-02 22:25:13 -05:00
Victor Stinner e7de0c5901
gh-108765: Python.h no longer includes <sys/time.h> (#108775)
Python.h no longer includes <time.h>, <sys/select.h> and <sys/time.h>
standard header files.

* Add <time.h> include to xxsubtype.c.
* Add <sys/time.h> include to posixmodule.c and semaphore.c.
* readline.c includes <sys/select.h> instead of <sys/time.h>.
* resource.c no longer includes <time.h> and <sys/time.h>.
2023-09-02 17:51:19 +02:00
Victor Stinner 594b00057e
gh-108765: Python.h no longer includes <unistd.h> (#108783) 2023-09-02 16:50:18 +02:00
Victor Stinner 4f9b706c6f
gh-108794: doctest counts skipped tests (#108795)
* Add 'skipped' attribute to TestResults.
* Add 'skips' attribute to DocTestRunner.
* Rename private DocTestRunner._name2ft attribute
  to DocTestRunner._stats.
* Use f-string for string formatting.
* Add some tests.
* Document DocTestRunner attributes and its API for statistics.
* Document TestResults class.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-09-02 16:42:07 +02:00
Victor Stinner 4ba18099b7
gh-108765: Python.h no longer includes <ieeefp.h> (#108781)
Remove also the HAVE_IEEEFP_H macro: remove ieeefp.h from the
AC_CHECK_HEADERS() check of configure.ac.
2023-09-02 15:48:32 +02:00
Nikita Sobolev 5141b1ebe0
gh-101100: Fix sphinx warnings in `unittest.mock-examples.rst` (#108810) 2023-09-02 13:05:44 +01:00
Nikita Sobolev dd05c2054f
Fix typo in `uuid.rst` (#108809) 2023-09-02 10:08:46 +00:00
Nikita Sobolev 21da4980f5
gh-101100: Fix sphinx warnings in `uuid.rst` (#108805)
* gh-101100: Fix sphinx warnings in `uuid.rst`

* Use anchors
2023-09-02 09:32:19 +00:00
TATHAGATA ROY 8f9ea43ee8
gh-105563: reference DateType in datetime's documentation (#105946) 2023-09-01 13:36:24 -07:00
Serhiy Storchaka 6f97eeec22
Improve some C API documentation (GH-108768)
* Express functions which take argument as a C string in terms of
  functions which take Python object.
* Use "note" directive for PyMapping_HasKey() and
  PyMapping_HasKeyString() notes.
2023-09-01 22:21:39 +03:00
Nikita Sobolev 3047f09490
gh-101100: Fix sphinx warnings in `tutorial/appendix.rst` (#108750)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-01 10:57:34 +00:00
Nikita Sobolev e775601ef1
gh-101100: Fix sphinx warnings in `tutorial/classes.rst` (#108746) 2023-09-01 13:44:43 +03:00
Alex Povel c1e2f3b2f7
`ast` docs: Fix incorrect link on `keyword` (#108728)
In two places, Sphinx was erroneously adding links to the `keyword` module instead of the `ast.keyword` class
2023-08-31 23:17:32 +01:00
Victor Stinner 2bd960b579
gh-108337: Add pyatomic.h header (#108701)
This adds a new header that provides atomic operations on common data
types. The intention is that this will be exposed through Python.h,
although that is not the case yet. The only immediate use is in
the test file.

Co-authored-by: Sam Gross <colesbury@gmail.com>
2023-08-31 21:41:18 +00:00
Ethan Furman d48760b2f1
gh-108682: [Enum] raise TypeError if super().__new__ called in custom __new__ (GH-108704)
When overriding the `__new__` method of an enum, the underlying data type should be created directly; i.e. .

    member = object.__new__(cls)
    member = int.__new__(cls, value)
    member = str.__new__(cls, value)

Calling `super().__new__()` finds the lookup version of `Enum.__new__`, and will now raise an exception when detected.
2023-08-31 12:45:12 -07:00
Victor Stinner 13a00078b8
gh-108634: Py_TRACE_REFS uses a hash table (#108663)
Python built with "configure --with-trace-refs" (tracing references)
is now ABI compatible with Python release build and debug build.
Moreover, it now also supports the Limited API.

Change Py_TRACE_REFS build:

* Remove _PyObject_EXTRA_INIT macro.
* The PyObject structure no longer has two extra members (_ob_prev
  and _ob_next).
* Use a hash table (_Py_hashtable_t) to trace references (all
  objects): PyInterpreterState.object_state.refchain.
* Py_TRACE_REFS build is now ABI compatible with release build and
  debug build.
* Limited C API extensions can now be built with Py_TRACE_REFS:
  xxlimited, xxlimited_35, _testclinic_limited.
* No longer rename PyModule_Create2() and PyModule_FromDefAndSpec2()
  functions to PyModule_Create2TraceRefs() and
  PyModule_FromDefAndSpec2TraceRefs().
* _Py_PrintReferenceAddresses() is now called before
  finalize_interp_delete() which deletes the refchain hash table.
* test_tracemalloc find_trace() now also filters by size to ignore
  the memory allocated by _PyRefchain_Trace().

Test changes for Py_TRACE_REFS:

* Add test.support.Py_TRACE_REFS constant.
* Add test_sys.test_getobjects() to test sys.getobjects() function.
* test_exceptions skips test_recursion_normalizing_with_no_memory()
  and test_memory_error_in_PyErr_PrintEx() if Python is built with
  Py_TRACE_REFS.
* test_repl skips test_no_memory().
* test_capi skisp test_set_nomemory().
2023-08-31 18:33:34 +02:00
Alex Waygood 013a99a47b
gh-97850: Note in py312 whatsnew that `importlib.util.set_loader` and `importlib.util.module_for_loader` have been removed (#108719)
Note in py312 whatsnew that `importlib.util.set_loader` and `importlib.util.module_for_loader` have been removed
2023-08-31 15:35:23 +01:00
Nikita Sobolev 991e4e76b5
gh-101100: Fix sphinx warnings in `threading.rst` (#108684)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-08-31 10:28:27 +03:00
Victor Stinner 2928e5dc65
gh-108494: Argument Clinic: Document how to generate code that uses the limited C API (#108584)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-08-30 16:02:48 +02:00
Victor Stinner e012cf771b
Document Python build requirements (#108646)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-30 15:28:58 +02:00
Hugo van Kemenade c7cef54631
gh-101100: Fix Sphinx warnings in the Logging Cookbook (#108678) 2023-08-30 14:37:45 +03:00
kato8966 38ab0dba80
Fix typo in multiprocessing docs (#108666) 2023-08-30 12:05:29 +01:00
Sebastian Rittau 6c484c39be
gh-108669: unittest: Fix documentation for TestResult.collectedDurations (#108670) 2023-08-30 09:36:59 +00:00
sterliakov 14ec0bb7c3
Mention Ellipsis pickling in the docs (#103660) 2023-08-30 01:11:31 +00:00
Erlend E. Aasland 0b0c1d046c
gh-108278: Deprecate passing the first param of sqlite3.Connection callback APIs by keyword (#108632)
Deprecate passing the callback callable by keyword for the following
sqlite3.Connection APIs:

- set_authorizer(authorizer_callback)
- set_progress_handler(progress_handler, ...)
- set_trace_callback(trace_callback)

The affected parameters will become positional-only in Python 3.15.
2023-08-29 22:02:12 +02:00
Erlend E. Aasland 8178a88bd8
gh-107801: Improve the accuracy of io.IOBase.seek docs (#108268)
- Add param docstrings
- Link to os.SEEK_* constants
- Mention the return value in the initial paragraph

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-08-29 19:13:38 +00:00
xzmeng 88f1c5b454
Fix misc doc typos (#108592) 2023-08-29 00:14:21 +00:00
Matthias Bussonnier f75cefd402
gh-106670: Allow Pdb to move between chained exceptions (#106676) 2023-08-28 18:31:03 +00:00
Erlend E. Aasland 4116592b6f
gh-108278: Deprecate passing the three first params as keyword args for sqlite3 UDF creation APIs (#108281)
Deprecate passing name, number of arguments, and the callable as keyword
arguments, for the following sqlite3.Connection APIs:

- create_function(name, nargs, callable, ...)
- create_aggregate(name, nargs, callable)

The affected parameters will become positional-only in Python 3.15.
2023-08-28 13:32:07 +00:00
Erlend E. Aasland 8db451ceb1
gh-64662: Fix NEWS entry and remove What's New entry (#108565) 2023-08-28 12:02:26 +00:00