Skip to content

Commit fbcf4e3

Browse files
committed
Merge branch 'main' into pythongh-72904-fnmatch-seps
2 parents 2728dcd + c6c5665 commit fbcf4e3

File tree

155 files changed

+5046
-2091
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+5046
-2091
lines changed

.coveragerc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[run]
2+
branch = True
3+
4+
[report]
5+
# Regexes for lines to exclude from consideration
6+
exclude_lines =
7+
# Don't complain if non-runnable code isn't run:
8+
if 0:
9+
if __name__ == .__main__.:
10+
11+
.*# pragma: no cover
12+
.*# pragma: no branch
13+
14+
# Additions for IDLE:
15+
.*# htest #
16+
if not (_htest or _utest):
17+
if not .*_utest:
18+
if .*_htest:
19+

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ Programs/test_frozenmain.h generated
8787
Python/Python-ast.c generated
8888
Python/executor_cases.c.h generated
8989
Python/generated_cases.c.h generated
90-
Include/internal/pycore_opcode_metadata.h generated
9190
Python/opcode_targets.h generated
9291
Python/stdlib_module_names.h generated
9392
Tools/peg_generator/pegen/grammar_parser.py generated

.github/CODEOWNERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,9 @@ Doc/c-api/stable.rst @encukou
172172
**/*pathlib* @barneygale
173173

174174
# zipfile.Path
175-
**/*zipfile/*_path.py @jaraco
175+
**/*zipfile/_path/* @jaraco
176176

177177
# Argument Clinic
178178
/Tools/clinic/** @erlend-aasland @AlexWaygood
179179
/Lib/test/test_clinic.py @erlend-aasland @AlexWaygood
180+
Doc/howto/clinic.rst @erlend-aasland

Doc/c-api/module.rst

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -486,12 +486,29 @@ state:
486486
.. versionadded:: 3.10
487487
488488
489+
.. c:function:: int PyModule_Add(PyObject *module, const char *name, PyObject *value)
490+
491+
Similar to :c:func:`PyModule_AddObjectRef`, but "steals" a reference
492+
to *value*.
493+
It can be called with a result of function that returns a new reference
494+
without bothering to check its result or even saving it to a variable.
495+
496+
Example usage::
497+
498+
if (PyModule_Add(module, "spam", PyBytes_FromString(value)) < 0) {
499+
goto error;
500+
}
501+
502+
.. versionadded:: 3.13
503+
504+
489505
.. c:function:: int PyModule_AddObject(PyObject *module, const char *name, PyObject *value)
490506
491507
Similar to :c:func:`PyModule_AddObjectRef`, but steals a reference to
492508
*value* on success (if it returns ``0``).
493509
494-
The new :c:func:`PyModule_AddObjectRef` function is recommended, since it is
510+
The new :c:func:`PyModule_Add` or :c:func:`PyModule_AddObjectRef`
511+
functions are recommended, since it is
495512
easy to introduce reference leaks by misusing the
496513
:c:func:`PyModule_AddObject` function.
497514
@@ -501,44 +518,24 @@ state:
501518
only decrements the reference count of *value* **on success**.
502519
503520
This means that its return value must be checked, and calling code must
504-
:c:func:`Py_DECREF` *value* manually on error.
521+
:c:func:`Py_XDECREF` *value* manually on error.
505522
506523
Example usage::
507524
508-
static int
509-
add_spam(PyObject *module, int value)
510-
{
511-
PyObject *obj = PyLong_FromLong(value);
512-
if (obj == NULL) {
513-
return -1;
514-
}
515-
if (PyModule_AddObject(module, "spam", obj) < 0) {
516-
Py_DECREF(obj);
517-
return -1;
518-
}
519-
// PyModule_AddObject() stole a reference to obj:
520-
// Py_DECREF(obj) is not needed here
521-
return 0;
522-
}
523-
524-
The example can also be written without checking explicitly if *obj* is
525-
``NULL``::
525+
PyObject *obj = PyBytes_FromString(value);
526+
if (PyModule_AddObject(module, "spam", obj) < 0) {
527+
// If 'obj' is not NULL and PyModule_AddObject() failed,
528+
// 'obj' strong reference must be deleted with Py_XDECREF().
529+
// If 'obj' is NULL, Py_XDECREF() does nothing.
530+
Py_XDECREF(obj);
531+
goto error;
532+
}
533+
// PyModule_AddObject() stole a reference to obj:
534+
// Py_XDECREF(obj) is not needed here.
526535
527-
static int
528-
add_spam(PyObject *module, int value)
529-
{
530-
PyObject *obj = PyLong_FromLong(value);
531-
if (PyModule_AddObject(module, "spam", obj) < 0) {
532-
Py_XDECREF(obj);
533-
return -1;
534-
}
535-
// PyModule_AddObject() stole a reference to obj:
536-
// Py_DECREF(obj) is not needed here
537-
return 0;
538-
}
536+
.. deprecated:: 3.13
539537
540-
Note that ``Py_XDECREF()`` should be used instead of ``Py_DECREF()`` in
541-
this case, since *obj* can be ``NULL``.
538+
:c:func:`PyModule_AddObject` is :term:`soft deprecated`.
542539
543540
544541
.. c:function:: int PyModule_AddIntConstant(PyObject *module, const char *name, long value)

Doc/data/stable_abi.dat

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/faq/library.rst

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -669,41 +669,6 @@ and client-side web systems.
669669
A summary of available frameworks is maintained by Paul Boddie at
670670
https://wiki.python.org/moin/WebProgramming\ .
671671
672-
Cameron Laird maintains a useful set of pages about Python web technologies at
673-
https://web.archive.org/web/20210224183619/http://phaseit.net/claird/comp.lang.python/web_python.
674-
675-
676-
How can I mimic CGI form submission (METHOD=POST)?
677-
--------------------------------------------------
678-
679-
I would like to retrieve web pages that are the result of POSTing a form. Is
680-
there existing code that would let me do this easily?
681-
682-
Yes. Here's a simple example that uses :mod:`urllib.request`::
683-
684-
#!/usr/local/bin/python
685-
686-
import urllib.request
687-
688-
# build the query string
689-
qs = "First=Josephine&MI=Q&Last=Public"
690-
691-
# connect and send the server a path
692-
req = urllib.request.urlopen('http://www.some-server.out-there'
693-
'/cgi-bin/some-cgi-script', data=qs)
694-
with req:
695-
msg, hdrs = req.read(), req.info()
696-
697-
Note that in general for percent-encoded POST operations, query strings must be
698-
quoted using :func:`urllib.parse.urlencode`. For example, to send
699-
``name=Guy Steele, Jr.``::
700-
701-
>>> import urllib.parse
702-
>>> urllib.parse.urlencode({'name': 'Guy Steele, Jr.'})
703-
'name=Guy+Steele%2C+Jr.'
704-
705-
.. seealso:: :ref:`urllib-howto` for extensive examples.
706-
707672
708673
What module should I use to help with generating HTML?
709674
------------------------------------------------------

0 commit comments

Comments
 (0)