https://github.com/python/cpython/commit/0df99207b3810fa862b2f3444cc7d752f2d3f594
commit: 0df99207b3810fa862b2f3444cc7d752f2d3f594
branch: 3.14
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: sobolevn <m...@sobolevn.me>
date: 2025-05-31T12:02:20Z
summary:

[3.14] Improve format of `InternalDocs/exception_handling.md` (GH-134969) 
(#134975)

Improve format of `InternalDocs/exception_handling.md` (GH-134969)
(cherry picked from commit 5507eff19c757a908a2ff29dfe423e35595fda00)

Co-authored-by: sobolevn <m...@sobolevn.me>

files:
M InternalDocs/exception_handling.md

diff --git a/InternalDocs/exception_handling.md 
b/InternalDocs/exception_handling.md
index 28589787e1fad7..9e38da4c862f16 100644
--- a/InternalDocs/exception_handling.md
+++ b/InternalDocs/exception_handling.md
@@ -8,7 +8,7 @@ The cost of raising an exception is increased, but not by much.
 
 The following code:
 
-```
+```python
 try:
     g(0)
 except:
@@ -18,7 +18,7 @@ except:
 
 compiles into intermediate code like the following:
 
-```
+```python
                   RESUME                   0
 
      1            SETUP_FINALLY            8 (to L1)
@@ -118,13 +118,13 @@ All offsets and lengths are in code units, not bytes.
 
 We want the format to be compact, but quickly searchable.
 For it to be compact, it needs to have variable sized entries so that we can 
store common (small) offsets compactly, but handle large offsets if needed.
-For it to be searchable quickly, we need to support binary search giving us 
log(n) performance in all cases.
+For it to be searchable quickly, we need to support binary search giving us 
`log(n)` performance in all cases.
 Binary search typically assumes fixed size entries, but that is not necessary, 
as long as we can identify the start of an entry.
 
 It is worth noting that the size (end-start) is always smaller than the end, 
so we encode the entries as:
 `start, size, target, depth, push-lasti`.
 
-Also, sizes are limited to 2**30 as the code length cannot exceed 2**31 and 
each code unit takes 2 bytes.
+Also, sizes are limited to `2**30` as the code length cannot exceed `2**31` 
and each code unit takes 2 bytes.
 It also happens that depth is generally quite small.
 
 So, we need to encode:
@@ -140,7 +140,7 @@ lasti   (1 bit)
 We need a marker for the start of the entry, so the first byte of entry will 
have the most significant bit set.
 Since the most significant bit is reserved for marking the start of an entry, 
we have 7 bits per byte to encode offsets.
 Encoding uses a standard varint encoding, but with only 7 bits instead of the 
usual 8.
-The 8 bits of a byte are (msb left) SXdddddd where S is the start bit. X is 
the extend bit meaning that the next byte is required to extend the offset.
+The 8 bits of a byte are (msb left) `SXdddddd` where `S` is the start bit. `X` 
is the extend bit meaning that the next byte is required to extend the offset.
 
 In addition, we combine `depth` and `lasti` into a single value, 
`((depth<<1)+lasti)`, before encoding.
 

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: arch...@mail-archive.com

Reply via email to