<feed xmlns='http://www.w3.org/2005/Atom'>
<title>python.git/Include/internal/pycore_pystate.h, branch 3.8</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.</subtitle>
<id>http://dangofactory.net/cgit/cgit.cgi/Server/python.git/atom/Include/internal/pycore_pystate.h?h=3.8</id>
<link rel='self' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/atom/Include/internal/pycore_pystate.h?h=3.8'/>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/'/>
<updated>2022-09-05T20:26:09Z</updated>
<entry>
<title>[3.8] gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96503)</title>
<updated>2022-09-05T20:26:09Z</updated>
<author>
<name>Gregory P. Smith</name>
<email>greg@krypto.org</email>
</author>
<published>2022-09-05T20:26:09Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=b5e331fdb38684808ffc540d53e8595bdc408b89'/>
<id>urn:sha1:b5e331fdb38684808ffc540d53e8595bdc408b89</id>
<content type='text'>
* Correctly pre-check for int-to-str conversion

Converting a large enough `int` to a decimal string raises `ValueError` as expected. However, the raise comes _after_ the quadratic-time base-conversion algorithm has run to completion. For effective DOS prevention, we need some kind of check before entering the quadratic-time loop. Oops! =)

The quick fix: essentially we catch _most_ values that exceed the threshold up front. Those that slip through will still be on the small side (read: sufficiently fast), and will get caught by the existing check so that the limit remains exact.

The justification for the current check. The C code check is:
```c
max_str_digits / (3 * PyLong_SHIFT) &lt;= (size_a - 11) / 10
```

In GitHub markdown math-speak, writing $M$ for `max_str_digits`, $L$ for `PyLong_SHIFT` and $s$ for `size_a`, that check is:
$$\left\lfloor\frac{M}{3L}\right\rfloor \le \left\lfloor\frac{s - 11}{10}\right\rfloor$$

From this it follows that
$$\frac{M}{3L} &lt; \frac{s-1}{10}$$
hence that
$$\frac{L(s-1)}{M} &gt; \frac{10}{3} &gt; \log_2(10).$$
So
$$2^{L(s-1)} &gt; 10^M.$$
But our input integer $a$ satisfies $|a| \ge 2^{L(s-1)}$, so $|a|$ is larger than $10^M$. This shows that we don't accidentally capture anything _below_ the intended limit in the check.

&lt;!-- gh-issue-number: gh-95778 --&gt;
* Issue: gh-95778
&lt;!-- /gh-issue-number --&gt;

Co-authored-by: Gregory P. Smith [Google LLC] &lt;greg@krypto.org&gt;
Co-authored-by: Christian Heimes &lt;christian@python.org&gt;
Co-authored-by: Mark Dickinson &lt;dickinsm@gmail.com&gt;</content>
</entry>
<entry>
<title>bpo-43962: Fix _PyInterpreterState_IDIncref() (GH-25683) (GH-25686)</title>
<updated>2021-04-28T13:46:57Z</updated>
<author>
<name>Victor Stinner</name>
<email>vstinner@python.org</email>
</author>
<published>2021-04-28T13:46:57Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=77db337f1e69213e62ba79a797540cc4ac23492e'/>
<id>urn:sha1:77db337f1e69213e62ba79a797540cc4ac23492e</id>
<content type='text'>
_PyInterpreterState_IDIncref() now calls
_PyInterpreterState_IDInitref() and always increments id_refcount.

(cherry picked from commit 32c5a174445ec93747240cd8472012276ed27acf)</content>
</entry>
<entry>
<title>[3.9] bpo-40826: Fix GIL usage in PyOS_Readline() (GH-20613) (GH-20616)</title>
<updated>2020-06-03T16:28:18Z</updated>
<author>
<name>Victor Stinner</name>
<email>vstinner@python.org</email>
</author>
<published>2020-06-03T16:28:18Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=6f7346bb3983cd7a6aa97eeeafffb3cecd5292b8'/>
<id>urn:sha1:6f7346bb3983cd7a6aa97eeeafffb3cecd5292b8</id>
<content type='text'>
* bpo-40826: Fix GIL usage in PyOS_Readline() (GH-20579)

Fix GIL usage in PyOS_Readline(): lock the GIL to set an exception.

Pass tstate to my_fgets() and _PyOS_WindowsConsoleReadline(). Cleanup
these functions.

(cherry picked from commit c353764fd564e401cf47a5d9efab18c72c60014e)

* bpo-40826: Add _PyOS_InterruptOccurred(tstate) function (GH-20599)

my_fgets() now calls _PyOS_InterruptOccurred(tstate) to check for
pending signals, rather calling PyOS_InterruptOccurred().

my_fgets() is called with the GIL released, whereas
PyOS_InterruptOccurred() must be called with the GIL held.

test_repl: use text=True and avoid SuppressCrashReport in
test_multiline_string_parsing().

Fix my_fgets() on Windows: fgets(fp) does crash if fileno(fp) is closed.

(cherry picked from commit fa7ab6aa0f9a4f695e5525db5a113cd21fa93787)</content>
</entry>
<entry>
<title>[3.8] bpo-38070: Py_FatalError() logs runtime state (GH-16258)</title>
<updated>2019-09-18T12:10:16Z</updated>
<author>
<name>Victor Stinner</name>
<email>vstinner@redhat.com</email>
</author>
<published>2019-09-18T12:10:16Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=47bbab9f76735acc1991e541d12fd18be6b13b16'/>
<id>urn:sha1:47bbab9f76735acc1991e541d12fd18be6b13b16</id>
<content type='text'>
* bpo-38070: _Py_DumpTraceback() writes &lt;no Python frame&gt; (GH-16244)

When a Python thread has no frame, _Py_DumpTraceback() and
_Py_DumpTracebackThreads() now write "&lt;no Python frame&gt;", rather than
writing nothing.

(cherry picked from commit 8fa3e1740b3f03ea65ddb68411c2238c5f98eec2)

* bpo-38070: Enhance _PyObject_Dump() (GH-16243)

_PyObject_Dump() now dumps the object address for freed objects and
objects with ob_type=NULL.

(cherry picked from commit b39afb78768418d9405c4b528c80fa968ccc974d)

* bpo-38070: Add _PyRuntimeState.preinitializing (GH-16245)

Add _PyRuntimeState.preinitializing field: set to 1 while
Py_PreInitialize() is running.

_PyRuntimeState: rename also pre_initialized field to preinitialized.

(cherry picked from commit d3b904144e86e2442961de6a7dccecbe133d5c6d)

* bpo-38070: Py_FatalError() logs runtime state (GH-16246)


(cherry picked from commit 1ce16fb0977283ae42a9f8917bbca5f44aa69324)
</content>
</entry>
<entry>
<title>Revert "bpo-36818: Add PyInterpreterState.runtime field. (gh-13129)" (GH-13795)</title>
<updated>2019-06-04T01:15:09Z</updated>
<author>
<name>Victor Stinner</name>
<email>vstinner@redhat.com</email>
</author>
<published>2019-06-04T01:15:09Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=0fd2c300c2a85b3b227a907b2a39ef79fa86d850'/>
<id>urn:sha1:0fd2c300c2a85b3b227a907b2a39ef79fa86d850</id>
<content type='text'>
This reverts commit 396e0a8d9dc65453cb9d53500d0a620602656cfe.</content>
</entry>
<entry>
<title>Revert "bpo-33608: Factor out a private, per-interpreter _Py_AddPendingCall(). (gh-13714)" (GH-13780)</title>
<updated>2019-06-03T16:14:24Z</updated>
<author>
<name>Victor Stinner</name>
<email>vstinner@redhat.com</email>
</author>
<published>2019-06-03T16:14:24Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=e225bebc1409bcf68db74a35ed3c31222883bf8f'/>
<id>urn:sha1:e225bebc1409bcf68db74a35ed3c31222883bf8f</id>
<content type='text'>
This reverts commit 6a150bcaeb190d1731b38ab9c7a5d1a352847ddc.</content>
</entry>
<entry>
<title>bpo-33608: Factor out a private, per-interpreter _Py_AddPendingCall(). (gh-13714)</title>
<updated>2019-06-01T21:39:46Z</updated>
<author>
<name>Eric Snow</name>
<email>ericsnowcurrently@gmail.com</email>
</author>
<published>2019-06-01T21:39:46Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=6a150bcaeb190d1731b38ab9c7a5d1a352847ddc'/>
<id>urn:sha1:6a150bcaeb190d1731b38ab9c7a5d1a352847ddc</id>
<content type='text'>
</content>
</entry>
<entry>
<title>bpo-36818: Add PyInterpreterState.runtime field. (gh-13129)</title>
<updated>2019-06-01T03:16:47Z</updated>
<author>
<name>Eric Snow</name>
<email>ericsnowcurrently@gmail.com</email>
</author>
<published>2019-06-01T03:16:47Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=396e0a8d9dc65453cb9d53500d0a620602656cfe'/>
<id>urn:sha1:396e0a8d9dc65453cb9d53500d0a620602656cfe</id>
<content type='text'>
https://bugs.python.org/issue36818</content>
</entry>
<entry>
<title>bpo-36763: Implement the PEP 587 (GH-13592)</title>
<updated>2019-05-27T14:39:22Z</updated>
<author>
<name>Victor Stinner</name>
<email>vstinner@redhat.com</email>
</author>
<published>2019-05-27T14:39:22Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=331a6a56e9a9c72f3e4605987fabdaec72677702'/>
<id>urn:sha1:331a6a56e9a9c72f3e4605987fabdaec72677702</id>
<content type='text'>
* 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 =&gt; Python/initconfig.c
  * Include/cpython/coreconfig.h =&gt; Include/cpython/initconfig.h
  * Include/internal/: pycore_coreconfig.h =&gt; pycore_initconfig.h

* Rename structures

  * _PyCoreConfig =&gt; PyConfig
  * _PyPreConfig =&gt; PyPreConfig
  * _PyInitError =&gt; PyStatus
  * _PyWstrList =&gt; PyWideStringList

* Rename PyConfig fields:

  * use_module_search_paths =&gt; module_search_paths_set
  * module_search_path_env =&gt; pythonpath_env

* Rename PyStatus field: _func =&gt; func
* PyInterpreterState: rename core_config field to config
* Rename macros and functions:

  * _PyCoreConfig_SetArgv() =&gt; PyConfig_SetBytesArgv()
  * _PyCoreConfig_SetWideArgv() =&gt; PyConfig_SetArgv()
  * _PyCoreConfig_DecodeLocale() =&gt; PyConfig_SetBytesString()
  * _PyInitError_Failed() =&gt; PyStatus_Exception()
  * _Py_INIT_ERROR_TYPE_xxx enums =&gt; _PyStatus_TYPE_xxx
  * _Py_UnixMain() =&gt; Py_BytesMain()
  * _Py_ExitInitError() =&gt; Py_ExitStatusException()
  * _Py_PreInitializeFromArgs() =&gt; Py_PreInitializeFromBytesArgs()
  * _Py_PreInitializeFromWideArgs() =&gt; Py_PreInitializeFromArgs()
  * _Py_PreInitialize() =&gt; Py_PreInitialize()
  * _Py_RunMain() =&gt; Py_RunMain()
  * _Py_InitializeFromConfig() =&gt; Py_InitializeFromConfig()
  * _Py_INIT_XXX() =&gt; _PyStatus_XXX()
  * _Py_INIT_FAILED() =&gt; _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()</content>
</entry>
<entry>
<title>bpo-36842: Implement PEP 578 (GH-12613)</title>
<updated>2019-05-23T15:45:22Z</updated>
<author>
<name>Steve Dower</name>
<email>steve.dower@microsoft.com</email>
</author>
<published>2019-05-23T15:45:22Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=b82e17e626f7b1cd98aada0b1ebb65cb9f8fb184'/>
<id>urn:sha1:b82e17e626f7b1cd98aada0b1ebb65cb9f8fb184</id>
<content type='text'>
Adds sys.audit, sys.addaudithook, io.open_code, and associated C APIs.</content>
</entry>
</feed>
