Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5d9deff

Browse files
authored
Merge branch 'main' into magics
2 parents 62fa204 + 10c8e9c commit 5d9deff

9 files changed

Lines changed: 28 additions & 25 deletions

File tree

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v5
1414
- name: Set up Python
1515
uses: actions/setup-python@v5
1616
with:

.github/workflows/downstream.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
python-version: "3.13"
3030

3131
steps:
32-
- uses: actions/checkout@v4
32+
- uses: actions/checkout@v5
3333
- name: Set up Python ${{ matrix.python-version }}
3434
uses: actions/setup-python@v5
3535
with:

.github/workflows/mypy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
python-version: ["3.x"]
1919

2020
steps:
21-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@v5
2222
- name: Set up Python ${{ matrix.python-version }}
2323
uses: actions/setup-python@v5
2424
with:

.github/workflows/nightly-wheel-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
if: github.event_name != 'pull_request' && (github.event_name != 'schedule' || github.repository_owner == 'ipython')
1414

1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v5
1717
- name: Set up Python
1818
uses: actions/setup-python@v5
1919
with:

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
timeout-minutes: 5
2020
steps:
21-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@v5
2222
with:
2323
fetch-depth: 0
2424
- name: Set up Python

.github/workflows/ruff.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
python-version: ["3.x"]
1919

2020
steps:
21-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@v5
2222
- name: Set up Python ${{ matrix.python-version }}
2323
uses: actions/setup-python@v5
2424
with:

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
want-latest-entry-point-code: true
5858

5959
steps:
60-
- uses: actions/checkout@v4
60+
- uses: actions/checkout@v5
6161
- name: Set up Python ${{ matrix.python-version }}
6262
uses: actions/setup-python@v5
6363
with:

IPython/extensions/deduperreload/deduperreload_patching.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import Any
55

66
NOT_FOUND: object = object()
7+
NULL: object = object()
78
_MAX_FIELD_SEARCH_OFFSET = 50
89

910
if sys.maxsize > 2**32:
@@ -55,12 +56,17 @@ def try_write_readonly_attr(
5556
if offset == -1:
5657
return
5758
obj_addr = ctypes.c_void_p.from_buffer(ctypes.py_object(obj)).value
58-
new_value_addr = ctypes.c_void_p.from_buffer(ctypes.py_object(new_value)).value
59+
if new_value is NULL:
60+
new_value_addr: int | None = 0
61+
else:
62+
new_value_addr = ctypes.c_void_p.from_buffer(
63+
ctypes.py_object(new_value)
64+
).value
5965
if obj_addr is None or new_value_addr is None:
6066
return
6167
if prev_value is not None:
6268
ctypes.pythonapi.Py_DecRef(ctypes.py_object(prev_value))
63-
if new_value is not None:
69+
if new_value not in (None, NULL):
6470
ctypes.pythonapi.Py_IncRef(ctypes.py_object(new_value))
6571
ctypes.cast(
6672
obj_addr + WORD_N_BYTES * offset, ctypes.POINTER(WORD_TYPE)
@@ -108,12 +114,10 @@ def try_patch_attr(
108114
def patch_function(
109115
cls, to_patch_to: Any, to_patch_from: Any, is_method: bool
110116
) -> None:
111-
new_freevars = []
112117
new_closure = []
113118
for freevar, closure_val in zip(
114119
to_patch_from.__code__.co_freevars or [], to_patch_from.__closure__ or []
115120
):
116-
new_freevars.append(freevar)
117121
if (
118122
callable(closure_val.cell_contents)
119123
and freevar in to_patch_to.__code__.co_freevars
@@ -125,23 +129,19 @@ def patch_function(
125129
)
126130
else:
127131
new_closure.append(closure_val)
128-
code_with_new_freevars = to_patch_from.__code__.replace(
129-
co_freevars=tuple(new_freevars)
130-
)
131132
# lambdas may complain if there is more than one freevar
132-
cls.try_patch_attr(
133-
to_patch_to, code_with_new_freevars, "__code__", new_is_value=True
134-
)
133+
cls.try_patch_attr(to_patch_to, to_patch_from, "__code__")
135134
offset = -1
136135
if to_patch_to.__closure__ is None and to_patch_from.__closure__ is not None:
137136
offset = cls.infer_field_offset(to_patch_from, "__closure__")
138-
cls.try_patch_readonly_attr(
139-
to_patch_to,
140-
tuple(new_closure) or None,
141-
"__closure__",
142-
new_is_value=True,
143-
offset=offset,
144-
)
137+
if to_patch_to.__closure__ is not None or to_patch_from.__closure__ is not None:
138+
cls.try_patch_readonly_attr(
139+
to_patch_to,
140+
tuple(new_closure) or NULL,
141+
"__closure__",
142+
new_is_value=True,
143+
offset=offset,
144+
)
145145
for attr in ("__defaults__", "__kwdefaults__", "__doc__", "__dict__"):
146146
cls.try_patch_attr(to_patch_to, to_patch_from, attr)
147147
if is_method:

tests/test_ultratb.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,10 @@ class ExceptionMessagePreferenceTest(unittest.TestCase):
445445

446446
def test_jsondecodeerror_message(self):
447447
cell = "import json;json.loads('{\"a\": }')"
448-
expected = "JSONDecodeError: Expecting value: line 1 column 7 (char 6)"
448+
if platform.python_implementation() == "PyPy":
449+
expected = "JSONDecodeError: Unexpected '}': line 1 column 7 (char 6)"
450+
else:
451+
expected = "JSONDecodeError: Expecting value: line 1 column 7 (char 6)"
449452
ip.run_cell("%xmode plain")
450453
with tt.AssertPrints(expected):
451454
ip.run_cell(cell)

0 commit comments

Comments
 (0)