Skip to content

Commit 65dcd9d

Browse files
Deploy preview for PR 1153 🛫
1 parent 5de0dd0 commit 65dcd9d

File tree

580 files changed

+927
-625
lines changed

Some content is hidden

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

580 files changed

+927
-625
lines changed

pr-preview/pr-1153/_sources/c-api/dict.rst.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ Dictionary Objects
245245
``len(p)`` on a dictionary.
246246
247247
248+
.. c:function:: Py_ssize_t PyDict_GET_SIZE(PyObject *p)
249+
250+
Similar to :c:func:`PyDict_Size`, but without error checking.
251+
252+
248253
.. c:function:: int PyDict_Next(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue)
249254
250255
Iterate over all key-value pairs in the dictionary *p*. The

pr-preview/pr-1153/_sources/c-api/float.rst.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ Floating-Point Objects
7878
Return the minimum normalized positive float *DBL_MIN* as C :c:expr:`double`.
7979
8080
81+
.. c:macro:: Py_RETURN_NAN
82+
83+
Return :data:`math.nan` from a function.
84+
85+
On most platforms, this is equivalent to ``return PyFloat_FromDouble(NAN)``.
86+
87+
88+
.. c:macro:: Py_RETURN_INF(sign)
89+
90+
Return :data:`math.inf` or :data:`-math.inf <math.inf>` from a function,
91+
depending on the sign of *sign*.
92+
93+
On most platforms, this is equivalent to the following::
94+
95+
return PyFloat_FromDouble(copysign(INFINITY, sign));
96+
97+
8198
Pack and Unpack functions
8299
-------------------------
83100

pr-preview/pr-1153/_sources/c-api/iterator.rst.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,32 @@ sentinel value is returned.
5050
callable object that can be called with no parameters; each call to it should
5151
return the next item in the iteration. When *callable* returns a value equal to
5252
*sentinel*, the iteration will be terminated.
53+
54+
55+
Other Iterator Objects
56+
^^^^^^^^^^^^^^^^^^^^^^
57+
58+
.. c:var:: PyTypeObject PyByteArrayIter_Type
59+
.. c:var:: PyTypeObject PyBytesIter_Type
60+
.. c:var:: PyTypeObject PyListIter_Type
61+
.. c:var:: PyTypeObject PyListRevIter_Type
62+
.. c:var:: PyTypeObject PySetIter_Type
63+
.. c:var:: PyTypeObject PyTupleIter_Type
64+
.. c:var:: PyTypeObject PyRangeIter_Type
65+
.. c:var:: PyTypeObject PyLongRangeIter_Type
66+
.. c:var:: PyTypeObject PyDictIterKey_Type
67+
.. c:var:: PyTypeObject PyDictRevIterKey_Type
68+
.. c:var:: PyTypeObject PyDictIterValue_Type
69+
.. c:var:: PyTypeObject PyDictRevIterValue_Type
70+
.. c:var:: PyTypeObject PyDictIterItem_Type
71+
.. c:var:: PyTypeObject PyDictRevIterItem_Type
72+
73+
Type objects for iterators of various built-in objects.
74+
75+
Do not create instances of these directly; prefer calling
76+
:c:func:`PyObject_GetIter` instead.
77+
78+
Note that there is no guarantee that a given built-in type uses a given iterator
79+
type. For example, iterating over :class:`range` will use one of two iterator
80+
types depending on the size of the range. Other types may start using a
81+
similar scheme in the future, without warning.

pr-preview/pr-1153/_sources/c-api/memoryview.rst.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ A :class:`memoryview` object exposes the C level :ref:`buffer interface
1313
any other object.
1414

1515

16+
.. c:var:: PyTypeObject PyMemoryView_Type
17+
18+
This instance of :c:type:`PyTypeObject` represents the Python memoryview
19+
type. This is the same object as :class:`memoryview` in the Python layer.
20+
21+
1622
.. c:function:: PyObject *PyMemoryView_FromObject(PyObject *obj)
1723
1824
Create a memoryview object from an object that provides the buffer interface.

pr-preview/pr-1153/_sources/library/argparse.rst.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,9 @@ Parser defaults
20712071
>>> parser.parse_args(['736'])
20722072
Namespace(bar=42, baz='badger', foo=736)
20732073

2074-
Note that parser-level defaults always override argument-level defaults::
2074+
Note that defaults can be set at both the parser level using :meth:`set_defaults`
2075+
and at the argument level using :meth:`add_argument`. If both are called for the
2076+
same argument, the last default set for an argument is used::
20752077

20762078
>>> parser = argparse.ArgumentParser()
20772079
>>> parser.add_argument('--foo', default='bar')

pr-preview/pr-1153/_sources/library/curses.rst.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,6 @@ The :mod:`curses` module defines the following data members:
13491349

13501350

13511351
.. data:: version
1352-
.. data:: __version__
13531352

13541353
A bytes object representing the current version of the module.
13551354

pr-preview/pr-1153/_sources/library/functools.rst.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ The :mod:`functools` module defines the following functions:
4242
def factorial(n):
4343
return n * factorial(n-1) if n else 1
4444

45-
>>> factorial(10) # no previously cached result, makes 11 recursive calls
45+
>>> factorial(10) # no previously cached result, makes 11 recursive calls
4646
3628800
47-
>>> factorial(5) # just looks up cached value result
47+
>>> factorial(5) # no new calls, just returns the cached result
4848
120
49-
>>> factorial(12) # makes two new recursive calls, the other 10 are cached
49+
>>> factorial(12) # two new recursive calls, factorial(10) is cached
5050
479001600
5151

5252
The cache is threadsafe so that the wrapped function can be used in

pr-preview/pr-1153/_sources/library/pyexpat.rst.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,15 @@ otherwise stated.
558558

559559
.. method:: xmlparser.ExternalEntityRefHandler(context, base, systemId, publicId)
560560

561+
.. warning::
562+
563+
Implementing a handler that accesses local files and/or the network
564+
may create a vulnerability to
565+
`external entity attacks <https://en.wikipedia.org/wiki/XML_external_entity_attack>`_
566+
if :class:`xmlparser` is used with user-provided XML content.
567+
Please reflect on your `threat model <https://en.wikipedia.org/wiki/Threat_model>`_
568+
before implementing this handler.
569+
561570
Called for references to external entities. *base* is the current base, as set
562571
by a previous call to :meth:`SetBase`. The public and system identifiers,
563572
*systemId* and *publicId*, are strings if given; if the public identifier is not

pr-preview/pr-1153/_sources/library/xml.rst.txt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,22 @@ XML security
5353

5454
An attacker can abuse XML features to carry out denial of service attacks,
5555
access local files, generate network connections to other machines, or
56-
circumvent firewalls.
57-
58-
Expat versions lower than 2.6.0 may be vulnerable to "billion laughs",
59-
"quadratic blowup" and "large tokens". Python may be vulnerable if it uses such
60-
older versions of Expat as a system-provided library.
56+
circumvent firewalls when attacker-controlled XML is being parsed,
57+
in Python or elsewhere.
58+
59+
The built-in XML parsers of Python rely on the library `libexpat`_, commonly
60+
called Expat, for parsing XML.
61+
62+
By default, Expat itself does not access local files or create network
63+
connections.
64+
65+
Expat versions lower than 2.7.2 may be vulnerable to the "billion laughs",
66+
"quadratic blowup" and "large tokens" vulnerabilities, or to disproportional
67+
use of dynamic memory.
68+
Python bundles a copy of Expat, and whether Python uses the bundled or a
69+
system-wide Expat, depends on how the Python interpreter
70+
:option:`has been configured <--with-system-expat>` in your environment.
71+
Python may be vulnerable if it uses such older versions of Expat.
6172
Check :const:`!pyexpat.EXPAT_VERSION`.
6273

6374
:mod:`xmlrpc` is **vulnerable** to the "decompression bomb" attack.
@@ -90,5 +101,6 @@ large tokens
90101
be used to cause denial of service in the application parsing XML.
91102
The issue is known as :cve:`2023-52425`.
92103

104+
.. _libexpat: https://github.com/libexpat/libexpat
93105
.. _Billion Laughs: https://en.wikipedia.org/wiki/Billion_laughs
94106
.. _ZIP bomb: https://en.wikipedia.org/wiki/Zip_bomb

pr-preview/pr-1153/_sources/reference/datamodel.rst.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ Objects, values and types
1616
single: data
1717

1818
:dfn:`Objects` are Python's abstraction for data. All data in a Python program
19-
is represented by objects or by relations between objects. (In a sense, and in
20-
conformance to Von Neumann's model of a "stored program computer", code is also
21-
represented by objects.)
19+
is represented by objects or by relations between objects. Even code is
20+
represented by objects.
2221

2322
.. index::
2423
pair: built-in function; id
@@ -29,9 +28,6 @@ represented by objects.)
2928
single: mutable object
3029
single: immutable object
3130

32-
.. XXX it *is* now possible in some cases to change an object's
33-
type, under certain controlled conditions
34-
3531
Every object has an identity, a type and a value. An object's *identity* never
3632
changes once it has been created; you may think of it as the object's address in
3733
memory. The :keyword:`is` operator compares the identity of two objects; the

0 commit comments

Comments
 (0)