Commit graph

56 commits

Author SHA1 Message Date
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
Eric Snow 5dc825d504
gh-98154: Clarify Usage of "Reference Count" In the Docs (gh-107552)
PEP 683 (immortal objects) revealed some ways in which the Python documentation has been unnecessarily coupled to the implementation details of reference counts.  In the end users should focus on reference ownership, including taking references and releasing them, rather than on how many reference counts an object has.

This change updates the documentation to reflect that perspective.  It also updates the docs relative to immortal objects in a handful of places.
2023-08-07 15:40:59 -06:00
Serhiy Storchaka 983305268e
gh-107298: Fix yet more Sphinx warnings in the C API doc (GH-107345) 2023-07-27 18:44:32 +03:00
Victor Stinner 424049cc11
gh-105145: Remove old functions to config Python init (#105154)
Remove the following old functions to configure the Python
initialization, deprecated in Python 3.11:

* PySys_AddWarnOptionUnicode()
* PySys_AddWarnOption()
* PySys_AddXOption()
* PySys_HasWarnOptions()
* PySys_SetArgvEx()
* PySys_SetArgv()
* PySys_SetPath()
* Py_SetPath()
* Py_SetProgramName()
* Py_SetPythonHome()
* Py_SetStandardStreamEncoding()
* _Py_SetProgramFullPath()

Most of these functions are kept in the stable ABI, except:

* Py_SetStandardStreamEncoding()
* _Py_SetProgramFullPath()

Update Doc/extending/embedding.rst and Doc/extending/extending.rst to
use the new PyConfig API.

_testembed.c:

* check_stdio_details() now sets stdio_encoding and stdio_errors
  of PyConfig.
* Add definitions of functions removed from the API but kept in the
  stable ABI.
* test_init_from_config() and test_init_read_set() now use
  PyConfig_SetString() instead of PyConfig_SetBytesString().

Remove _Py_ClearStandardStreamEncoding() internal function.
2023-06-01 09:14:02 +02:00
Adam Turner 6ab463684b
GH-97950: Use new-style index directive ('object') (#104158)
* Uncomment object removal in pairindextypes

* Use new-style index directive ('object') - C API

* Use new-style index directive ('object') - Library

* Use new-style index directive ('object') - Reference

* Use new-style index directive ('object') - Tutorial
2023-05-04 13:04:41 +03:00
Adam Turner d0122372f2
GH-97950: Use new-style index directive ('module') (#103996)
* Use new-style index directive ('module') - C API

* Use new-style index directive ('module') - Library

* Use new-style index directive ('module') - Reference

* Use new-style index directive ('module') - Tutorial

* Uncomment module removal in pairindextypes

* Use new-style index directive ('module') - C API

* Use new-style index directive ('module') - Library

* Use new-style index directive ('module') - Reference
2023-05-04 10:17:12 +02:00
Julien Palard 61b9ff35cb
gh-101100: Documenting --prefix and --exec-prefix. (GH-102695)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-03-15 16:10:03 +01:00
Adam Turner 0031e62973
gh-93738: Documentation C syntax (:c:type:<C type> -> :c:expr:<C type>) (#97768)
:c:type:`<C type>` -> :c:expr:`<C type>`

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-10-05 11:01:14 -07:00
Adam Turner 0bf6a617ed
gh-93738: Documentation C syntax (:c:type:PyObject -> :c:expr:PyObject) (#97776)
:c:type:`PyObject` -> :c:expr:`PyObject`
2022-10-04 16:13:03 -07:00
Victor Stinner cfaa79aac0
gh-93103: Doc uses PyConfig rather than deprecated vars (#96070)
The C API documentation now uses the new PyConfig API, rather than
deprecated global configuration variables.
2022-08-18 16:58:38 +02:00
Ned Batchelder 3440d197a5
Docs: remove redundant "adverb-adjective" hyphens from compound modifiers (GH-94551)
Discussion: https://discuss.python.org/t/slight-grammar-fix-throughout-adverbs-dont-need-hyphen/17021
2022-07-05 11:16:10 +02:00
Julien Palard 664aa94b57
Document Py_ssize_t. (GH-92512)
It fixes 252 errors from a Sphinx nitpicky run (sphinx-build -n). But
there's 8182 errors left.

Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
2022-05-13 14:10:16 +02:00
Victor Stinner 299692afd8
gh-88279: Deprecate PySys_SetArgvEx() (#92363)
Deprecate the following C functions:

* PySys_SetArgv()
* PySys_SetArgvEx()
* PySys_SetPath()
2022-05-06 05:24:29 +02:00
Victor Stinner e4044e9f89
bpo-45116: Py_DEBUG ignores Py_ALWAYS_INLINE (GH-28419)
If the Py_DEBUG macro is defined, the Py_ALWAYS_INLINE macro does
nothing.
2021-09-17 22:46:38 +02:00
Victor Stinner 6b41355128
bpo-45116: Add the Py_ALWAYS_INLINE macro (GH-28390)
Add the Py_ALWAYS_INLINE macro to ask the compiler to always inline a
static inline function. The compiler can ignore it and decides to not
inline the function.
2021-09-17 14:09:14 +02:00
Victor Stinner 7974c30b9f
bpo-45094: Add Py_NO_INLINE macro (GH-28140)
* Rename _Py_NO_INLINE macro to Py_NO_INLINE: make it public and
  document it.
* Sort macros in the C API documentation.
2021-09-03 16:44:02 +02:00
Victor Stinner abfd6388cd
bpo-43774: Enhance debug build documentation (GH-25712)
* Add also references to --with-trace-refs option.
* Move _ob_next and _ob_prev at the end, since they don't exist by
  default and are related to debug.
2021-04-29 13:06:59 +02:00
Victor Stinner a41782cc84
bpo-43774: Document configure options (GH-25283)
Add Doc/using/configure.rst documentation to document configure,
preprocessor, compiler and linker options.

Add a new section about the "Python debug build".
2021-04-08 22:32:21 +02:00
Victor Stinner 23c5f93b83
bpo-42294: Add borrowed/strong reference to doc glossary (GH-23206)
Add "borrowed reference" and "strong reference" to the documentation
glossary.

Enhance also Py_INCREF() and Py_NewRef() documentation.
2020-11-09 13:40:47 +01:00
Victor Stinner 474652fe93
bpo-40204, doc: Fix syntax of C variables (GH-21846)
For example, fix the following Sphinx 3 errors:

Doc/c-api/buffer.rst:102: WARNING: Error in declarator or parameters
Invalid C declaration: Expected identifier in nested name. [error at 5]
  void \*obj
  -----^

Doc/c-api/arg.rst:130: WARNING: Unparseable C cross-reference: 'PyObject*'
Invalid C declaration: Expected end of definition. [error at 8]
  PyObject*
  --------^

The modified documentation is compatible with Sphinx 2 and Sphinx 3.
2020-08-13 22:11:50 +02:00
Brad Solomon b54e46cb57
bpo-38387: Formally document PyDoc_STRVAR and PyDoc_STR macros (GH-16607)
Adds a short description of `PyDoc_STRVAR` and `PyDoc_STR` to "Useful macros" section of C-API docs.

Currently, there is [one lone mention](https://docs.python.org/3/c-api/module.html?highlight=pydoc_strvar#c.PyModuleDef) in the C-API reference, despite the fact that `PyDoc_STRVAR` is ubiquitous to `Modules/`.

Additionally, this properly uses `c:macro` within `Doc/c-api/module.rst` to link.
2020-04-26 21:31:44 -05:00
Serhiy Storchaka eebaa9bfc5
bpo-38249: Expand Py_UNREACHABLE() to __builtin_unreachable() in the release mode. (GH-16329)
Co-authored-by: Victor Stinner <vstinner@python.org>
2020-03-09 20:49:52 +02:00
Serhiy Storchaka 25fc088607
bpo-38600: Change the mark up of NULL in the C API documentation. (GH-16950)
Replace all *NULL* with ``NULL``.
2019-10-30 12:03:20 +02:00
Kyle Stanley b6dafe5139 Docs: Small tweaks to c-api/intro#Include_Files (GH-14698) 2019-09-10 16:09:34 +01:00
Zackery Spytz 3c8724fc60 bpo-33407: Implement Py_DEPRECATED() on MSVC (GH-8980) 2019-05-28 17:16:33 +02:00
Victor Stinner b3a9843cd1
Support Py_UNUSED() on clang (GH-13544) 2019-05-24 15:16:08 +02:00
Stéphane Wirtel cbb6484573 Doc: Replace the deprecated highlightlang directive by highlight. (#13377)
highlightlang is deprecated since April 2018 in Sphinx.
See https://github.com/sphinx-doc/sphinx/pull/4845
2019-05-17 15:25:34 +05:30
Inada Naoki c88feceb44
Doc: define PY_SSIZE_T_CLEAN always (GH-12794) 2019-04-13 10:46:21 +09:00
Beomsoo Kim 05c1b387f1 Fixed a few obvious mistakes in c-api docs (GH-11184)
I thought these simple changes doesn't need bpo number(Am I right..?).

Please refer to the commit message for detail.
2018-12-17 04:57:03 -08:00
Petr Viktorin 2138163621 bpo-29179: Document the Py_UNUSED macro (#4341)
Py_UNUSED has a public name, and is used in the wild outside CPython,
but was not documented. Rectify that.

The macro was added in bpo-19976 and referenced in bpo-26179.
2017-11-08 07:59:20 -08:00
Victor Stinner 54cc0c0789
bpo-31338: C API intro: add missing versionadded (#4339) 2017-11-08 06:06:24 -08:00
Petr Viktorin 8bf288e2c5 Docs: Mention that Py_UNREACHABLE was added in 3.7 (#4337)
The macro was added for bpo-31338 in commit b2e5794870
2017-11-08 15:11:16 +02:00
Barry Warsaw a51b90a313 Document Py_GETENV() (#3890) 2017-10-06 09:53:48 -04:00
Barry Warsaw b2e5794870 bpo-31338 (#3374)
* Add Py_UNREACHABLE() as an alias to abort().
* Use Py_UNREACHABLE() instead of assert(0)
* Convert more unreachable code to use Py_UNREACHABLE()
* Document Py_UNREACHABLE() and a few other macros.
2017-09-14 18:13:16 -07:00
Serhiy Storchaka 885bdc4946 Issue #25985: sys.version_info is now used instead of sys.version
to format short Python version.
2016-02-11 13:10:36 +02:00
Martin Panter b4ce1fc31b Issue #5319: New Py_FinalizeEx() API to exit with status 120 on failure 2015-11-30 03:18:29 +00:00
Gregory P. Smith 4b52ae8f97 Clean up references to the no longer existing PyString_ APIs in our docs. 2013-03-22 13:43:30 -07:00
Terry Jan Reedy 65e69b3718 Issue #17047: removed doubled words in Doc/*, Mac/*, and Tool/*
found by Serhiy Storchaka and Matthew Barnett
2013-03-11 17:23:46 -04:00
Antoine Pitrou 04707c032e Fix error handling in examples of C API use. 2012-01-27 14:07:29 +01:00
Éric Araujo d2f8cec885 Fix a few misuses of :option: I missed in r86521.
Extract of the commit message:

  Fix usage of :option: in the docs (#9312).

  :option: is used to create a link to an option of python, not to mark
  up any instance of any arbitrary command-line option.  These were
  changed to ````.
2011-06-08 05:29:39 +02:00
Éric Araujo 37e6c54ba1 Merge 3.1 2011-04-20 19:24:09 +02:00
Éric Araujo 8b8f2ec560 Kill last reference to defunct module 2011-03-26 07:22:01 +01:00
Georg Brandl f65e25b626 Merged revisions 86134,86315-86316,86390,86424-86425,86428,86550,86561-86562,86564-86565,86705,86708,86713 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k

........
  r86134 | georg.brandl | 2010-11-03 08:41:00 +0100 (Mi, 03 Nov 2010) | 1 line

  A newline in lineno output breaks pyframe output.
........
  r86315 | georg.brandl | 2010-11-08 12:05:18 +0100 (Mo, 08 Nov 2010) | 1 line

  Fix latex conversion glitch in property/feature descriptions.
........
  r86316 | georg.brandl | 2010-11-08 12:08:35 +0100 (Mo, 08 Nov 2010) | 1 line

  Fix typo.
........
  r86390 | georg.brandl | 2010-11-10 08:57:10 +0100 (Mi, 10 Nov 2010) | 1 line

  Fix typo.
........
  r86424 | georg.brandl | 2010-11-12 07:19:48 +0100 (Fr, 12 Nov 2010) | 1 line

  Build a PDF of the FAQs too.
........
  r86425 | georg.brandl | 2010-11-12 07:20:12 +0100 (Fr, 12 Nov 2010) | 1 line

  #10008: Fix duplicate index entry.
........
  r86428 | georg.brandl | 2010-11-12 09:09:26 +0100 (Fr, 12 Nov 2010) | 1 line

  Fix weird line block in table.
........
  r86550 | georg.brandl | 2010-11-20 11:24:34 +0100 (Sa, 20 Nov 2010) | 1 line

  Fix rst markup errors.
........
  r86561 | georg.brandl | 2010-11-20 12:47:10 +0100 (Sa, 20 Nov 2010) | 1 line

  #10460: Update indent.pro to match PEP 7 better.
........
  r86562 | georg.brandl | 2010-11-20 14:44:41 +0100 (Sa, 20 Nov 2010) | 1 line

  #10439: document PyCodec C APIs.
........
  r86564 | georg.brandl | 2010-11-20 15:08:53 +0100 (Sa, 20 Nov 2010) | 1 line

  #10460: an even better indent.pro.
........
  r86565 | georg.brandl | 2010-11-20 15:16:17 +0100 (Sa, 20 Nov 2010) | 1 line

  socket.gethostbyname(socket.gethostname()) can fail when host name resolution is not set up correctly; do not fail test_socket if this is the case.
........
  r86705 | georg.brandl | 2010-11-23 08:54:19 +0100 (Di, 23 Nov 2010) | 1 line

  #10468: document Unicode exception creation and access functions.
........
  r86708 | georg.brandl | 2010-11-23 09:37:54 +0100 (Di, 23 Nov 2010) | 2 lines

  #10511: clarification of what heaps are; suggested by Johannes Hoff.
........
  r86713 | georg.brandl | 2010-11-23 19:14:57 +0100 (Di, 23 Nov 2010) | 1 line

  assert.h is also included. Thanks to Savio Sena.
........
2010-11-26 09:05:43 +00:00
Georg Brandl ab32fec83c Merged revisions 85572-85573,85606,85609-85622,85624,85626-85627,85629,85631,85633,85635-85636,85638-85639,85641-85642 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k

........
  r85572 | georg.brandl | 2010-10-16 20:51:05 +0200 (Sa, 16 Okt 2010) | 1 line

  #10122: typo fix.
........
  r85573 | georg.brandl | 2010-10-16 20:53:08 +0200 (Sa, 16 Okt 2010) | 1 line

  #10124: typo fix.
........
  r85606 | georg.brandl | 2010-10-17 08:32:59 +0200 (So, 17 Okt 2010) | 1 line

  #10058: tweak wording about exception returns.
........
  r85609 | georg.brandl | 2010-10-17 11:19:03 +0200 (So, 17 Okt 2010) | 1 line

  #8556: use less confusing mapping key in example.
........
  r85610 | georg.brandl | 2010-10-17 11:23:05 +0200 (So, 17 Okt 2010) | 1 line

  #8686: remove potentially confusing wording that does not add any value.
........
  r85611 | georg.brandl | 2010-10-17 11:33:24 +0200 (So, 17 Okt 2010) | 1 line

  #8811: small fixes to sqlite3 docs.
........
  r85612 | georg.brandl | 2010-10-17 11:37:54 +0200 (So, 17 Okt 2010) | 1 line

  #8855: add shelve security warning.
........
  r85613 | georg.brandl | 2010-10-17 11:43:35 +0200 (So, 17 Okt 2010) | 1 line

  Fix hmac docs: it takes and returns bytes, except for hexdigest().
........
  r85614 | georg.brandl | 2010-10-17 11:46:11 +0200 (So, 17 Okt 2010) | 1 line

  #8968: add actual name of token constants.
........
  r85615 | georg.brandl | 2010-10-17 12:05:13 +0200 (So, 17 Okt 2010) | 1 line

  #459007: merge info from PC/getpathp.c and using/windows.rst to document the forming of sys.path under Windows.
........
  r85616 | georg.brandl | 2010-10-17 12:07:29 +0200 (So, 17 Okt 2010) | 1 line

  Fix copy-paste error in example.
........
  r85617 | georg.brandl | 2010-10-17 12:09:06 +0200 (So, 17 Okt 2010) | 1 line

  #5212: md5 weaknesses do not affect hmac, so remove the note about that.
........
  r85618 | georg.brandl | 2010-10-17 12:14:38 +0200 (So, 17 Okt 2010) | 1 line

  #9086: correct wrong terminology about linking with pythonXY.dll.
........
  r85619 | georg.brandl | 2010-10-17 12:15:50 +0200 (So, 17 Okt 2010) | 1 line

  Make file names consistent.
........
  r85620 | georg.brandl | 2010-10-17 12:22:28 +0200 (So, 17 Okt 2010) | 1 line

  Remove second parser module example; it referred to non-readily-available example files, and this kind of discovery is much better done with the AST nowadays anyway.
........
  r85621 | georg.brandl | 2010-10-17 12:24:54 +0200 (So, 17 Okt 2010) | 1 line

  #9105: move pickle warning to a bit more prominent location.
........
  r85622 | georg.brandl | 2010-10-17 12:28:04 +0200 (So, 17 Okt 2010) | 1 line

  #9112: document error() and exit() methods of ArgumentParser.
........
  r85624 | georg.brandl | 2010-10-17 12:34:28 +0200 (So, 17 Okt 2010) | 1 line

  Some markup and style fixes in argparse docs.
........
  r85626 | georg.brandl | 2010-10-17 12:38:20 +0200 (So, 17 Okt 2010) | 1 line

  #9117: fix syntax for class definition.
........
  r85627 | georg.brandl | 2010-10-17 12:44:11 +0200 (So, 17 Okt 2010) | 1 line

  #9138: reword introduction to classes in Python.
........
  r85629 | georg.brandl | 2010-10-17 12:51:45 +0200 (So, 17 Okt 2010) | 1 line

  #5962: clarify sys.exit() vs. threads.
........
  r85631 | georg.brandl | 2010-10-17 12:53:54 +0200 (So, 17 Okt 2010) | 1 line

  Fix capitalization.
........
  r85633 | georg.brandl | 2010-10-17 12:59:41 +0200 (So, 17 Okt 2010) | 1 line

  #9204: remove mentions of removed types in the types module.
........
  r85635 | georg.brandl | 2010-10-17 13:03:22 +0200 (So, 17 Okt 2010) | 1 line

  #5121: fix claims about default values leading to segfaults.
........
  r85636 | georg.brandl | 2010-10-17 13:06:14 +0200 (So, 17 Okt 2010) | 1 line

  #9237: document sys.call_tracing().
........
  r85638 | georg.brandl | 2010-10-17 13:13:37 +0200 (So, 17 Okt 2010) | 1 line

  Port changes to pickle docs apparently lost in py3k.
........
  r85639 | georg.brandl | 2010-10-17 13:23:56 +0200 (So, 17 Okt 2010) | 1 line

  Make twisted example a bit more logical.
........
  r85641 | georg.brandl | 2010-10-17 13:29:07 +0200 (So, 17 Okt 2010) | 1 line

  Fix documentation of dis.opmap direction.
........
  r85642 | georg.brandl | 2010-10-17 13:36:28 +0200 (So, 17 Okt 2010) | 1 line

  #9730: fix example.
........
2010-11-26 08:49:15 +00:00
Georg Brandl 4f13d6145f assert.h is also included. Thanks to Savio Sena. 2010-11-23 18:14:57 +00:00
Georg Brandl dd909db1a9 #10058: tweak wording about exception returns. 2010-10-17 06:32:59 +00:00
Georg Brandl 60203b41b0 Migrate to Sphinx 1.0 C language constructs. 2010-10-06 10:11:56 +00:00
Benjamin Peterson 2ebf8ce488 Merged revisions 81881-81882 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r81881 | andrew.kuchling | 2010-06-10 19:16:08 -0500 (Thu, 10 Jun 2010) | 1 line

  #5753: update demo.c to use PySys_SetArgvEx(), and add a comment
........
  r81882 | andrew.kuchling | 2010-06-10 19:23:01 -0500 (Thu, 10 Jun 2010) | 1 line

  #5753: Suggest PySys_SetArgvEx() instead of PySys_SetArgv()
........
2010-06-27 21:48:35 +00:00
Georg Brandl e720c0aa74 Merged revisions 72009 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72009 | georg.brandl | 2009-04-27 17:29:09 +0200 (Mo, 27 Apr 2009) | 3 lines

  Demote warnings to notices where appropriate, following the goal that as few "red box" warnings
  should clutter the docs as possible.  Part 1: stuff that gets merged to Py3k.
........
2009-04-27 16:20:50 +00:00
Benjamin Peterson ad3d5c2235 Merged revisions 69803-69805,69840,69901,69905,69907,69924,69927,69987 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r69803 | georg.brandl | 2009-02-20 01:48:21 -0600 (Fri, 20 Feb 2009) | 1 line

  #5327: fix a broken link by joining it.
........
  r69804 | georg.brandl | 2009-02-20 02:22:21 -0600 (Fri, 20 Feb 2009) | 1 line

  At least separate imports from other statements.
........
  r69805 | georg.brandl | 2009-02-20 02:45:47 -0600 (Fri, 20 Feb 2009) | 2 lines

  Fix punctuation.
........
  r69840 | georg.brandl | 2009-02-21 13:09:40 -0600 (Sat, 21 Feb 2009) | 1 line

  #5338, #5339: two types in the API manual.
........
  r69901 | georg.brandl | 2009-02-23 05:24:46 -0600 (Mon, 23 Feb 2009) | 2 lines

  #5349: C++ pure virtuals can also have an implementation.
........
  r69905 | georg.brandl | 2009-02-23 09:51:27 -0600 (Mon, 23 Feb 2009) | 2 lines

  #5352: str.count() counts non-overlapping instances.
........
  r69907 | georg.brandl | 2009-02-23 12:33:48 -0600 (Mon, 23 Feb 2009) | 1 line

  Fix grammar.
........
  r69924 | benjamin.peterson | 2009-02-23 20:45:35 -0600 (Mon, 23 Feb 2009) | 1 line

  update README on running tests
........
  r69927 | neil.schemenauer | 2009-02-23 22:23:25 -0600 (Mon, 23 Feb 2009) | 1 line

  Fix call to os.waitpid, it does not take keyword args.
........
  r69987 | benjamin.peterson | 2009-02-25 18:30:11 -0600 (Wed, 25 Feb 2009) | 1 line

  fix str.format()'s first arg #5371
........
2009-02-26 03:38:59 +00:00