-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Permalink
Choose a base ref
{{ refName }}
default
Choose a head ref
{{ refName }}
default
Comparing changes
Choose two branches to see what’s changed or to start a new pull request.
If you need to, you can also or
learn more about diff comparisons.
Open a pull request
Create a new pull request by comparing changes across two branches. If you need to, you can also .
Learn more about diff comparisons here.
base repository: ipython/ipython
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9.9.0
Could not load branches
Nothing to show
Loading
Could not load tags
Nothing to show
{{ refName }}
default
Loading
...
head repository: ipython/ipython
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9.10.0
Could not load branches
Nothing to show
Loading
Could not load tags
Nothing to show
{{ refName }}
default
Loading
- 14 commits
- 7 files changed
- 3 contributors
Commits on Dec 26, 2025
-
fix: Removing leading indentation #15089
michaelj094 committedDec 26, 2025 Configuration menu - View commit details
-
Copy full SHA for d4aa4c8 - Browse repository at this point
Copy the full SHA d4aa4c8View commit details
Commits on Jan 3, 2026
-
fix: preserve doctest prompts when pasting inside docstrings
michaelj094 committedJan 3, 2026 Configuration menu - View commit details
-
Copy full SHA for 1110979 - Browse repository at this point
Copy the full SHA 1110979View commit details
Commits on Jan 5, 2026
-
Configuration menu - View commit details
-
Copy full SHA for 28d9b9c - Browse repository at this point
Copy the full SHA 28d9b9cView commit details
Commits on Jan 22, 2026
-
Configuration menu - View commit details
-
Copy full SHA for 8e7ebe4 - Browse repository at this point
Copy the full SHA 8e7ebe4View commit details -
Configuration menu - View commit details
-
Copy full SHA for e3c66c0 - Browse repository at this point
Copy the full SHA e3c66c0View commit details -
Configuration menu - View commit details
-
Copy full SHA for add29df - Browse repository at this point
Copy the full SHA add29dfView commit details -
Configuration menu - View commit details
-
Copy full SHA for e602694 - Browse repository at this point
Copy the full SHA e602694View commit details
Commits on Jan 23, 2026
-
Stop HistorySavingThread before fork (#15115)
Python 3.12+ issues a DeprecationWarning if `os.fork()` is called while there are multiple threads, and in fact this is not strictly safe on any version of Python, although on Linux with glibc it mostly works well enough that we don't notice. The man page for `fork()` says: > After a fork() in a multithreaded program, the child can safely call only async-signal-safe functions (see signal-safety(7)) until such time as it calls execve(2). This is incompatible with executing any Python code, hence the warning. IPython is always multi-threaded because of HistorySavingThread, so it's never safe to call `os.fork()` or use multiprocessing's fork context. However, I think we can easily resolve this by stopping the history saving thread before fork, and starting it again after, so at the moment of fork it's a single-threaded process. In principle, I think it's safe to start it again in the `after_in_parent` handler, but Python's check for threads to issue the warning runs after that callback, so to avoid triggering the warning, it's better to start it again when there's something for it to do. This unfortunately only solves the issue for IPython in the terminal, since IPykernel uses several more threads. But fixing it in the terminal is already useful, and this would also be one small step towards fixing it in IPykernel. ----- Testing: ```python import os import time def func_with_fork(): if (pid := os.fork()) > 0: print("Parent") t = os.waitpid(pid, 0) print("Parent: child finished", t) else: print("Child") time.sleep(0.5) print("Child finishing") os._exit(0) if __name__ == "__main__": func_with_fork() ``` ```shell PYTHONWARNINGS=default ipython ```Configuration menu - View commit details
-
Copy full SHA for 7dbbd24 - Browse repository at this point
Copy the full SHA 7dbbd24View commit details
Commits on Feb 2, 2026
-
fix: bug#15089 - Removing leading indentation (#15110)
# Fix doctest paste: strip prompts and dedent (#15089) ## Summary This PR improves how IPython handles pasting doctest and xdoctest code snippets. When pasting code like: ``` >>> print(1) ``` IPython now strips the `>>>` prompt and also removes the extra indentation, so the result is: ``` print(1) ``` Previously, the result would have been: ``` print(1) ``` which can cause an `IndentationError` at top-level. ## What changed - `inputtransformer2.py` - Enhanced PromptStripper to: - Detect doctest-style pastes when any line matches `^\s*>>>`. - In doctest-mode, strip `^\s*>>>\s?` and `^\s*\.\.\.\s?` (continuation). - After stripping, apply `textwrap.dedent()` to the joined block, then return dedented lines. - Only apply dedent when doctest prompts were actually stripped (to avoid changing non-doctest pastes). - Only treat `...` as a continuation prompt when a `>>>` is present in the same block (avoids confusing Python Ellipsis with doctest continuation). - `test_inputtransformer2_line.py` - Added/updated tests covering single-line doctest, indented `>>>`, multi-line `>>>` + `...` doctest, and standalone ... (unchanged when no `>>>`). ## Description of changes - Update `IPython/core/inputtransformer2.py` to enhance the `PromptStripper`: - Detect doctest-mode for a pasted block when any line matches `^\s*>>>`. - In doctest-mode, strip indented doctest prompts: - `^\s*>>>\s?` (primary prompt) - `^\s*\.\.\.\s?` (continuation prompt) - After stripping doctest prompts, apply `textwrap.dedent()` to the joined block and return the dedented lines. - Only apply `dedent()` when doctest prompts were actually stripped to avoid changing normal paste semantics. - Update/add tests in `tests/test_inputtransformer2_line.py` for the new behavior. ## Motivation and context Users often copy doctest examples from documentation or tools that show doctest prompts and indentation (for example, xdoctest-style indented examples). Previously IPython removed the `>>>` prompt but preserved the remaining indentation, which could turn a pasted, single-line doctest into an indented top-level statement and raise `IndentationError`. This PR makes doctest pastes behave as users expect: prompts are removed and the code block is normalized by dedenting. ## Examples (Before → After) ### Single-line doctest Input: ```py >>> print(1) ``` Before: ```py print(1) ``` After: ```py print(1) ``` ### Indented xdoctest-style prompt Input: ```py >>> print(1) ``` After: ```py print(1) ``` ### Multi-line doctest with continuation Input: ```py >>> for i in range(2): ... print(i) ``` After: ```py for i in range(2): print(i) ``` ### Standalone continuation prompt (unchanged) Input: ```py ... print(1) ``` After (unchanged because no `>>>` present): ```py ... print(1) ``` ## Implementation notes - `dedent()` is applied only after doctest prompts were detected and stripped. This avoids affecting normal paste behavior for non-doctest code, and prevents accidental removal of meaningful indentation in user-pasted code. - `...` is considered a continuation prompt only when the pasted block contains at least one `>>>`, to avoid confusing Python's `Ellipsis` literal with doctest continuations. - Regexes used are tolerant of leading whitespace to support indented `>>>` prompts (xdoctest-style). ## Related issues - Fixes #15089 ## Testing performed - Added and updated tests in `tests/test_inputtransformer2_line.py` to cover: - Single-line doctest with extra indentation: `">>> print(1)\n" -> "print(1)\n"` - Leading whitespace before `>>>`: `" >>> print(1)\n" -> "print(1)\n"` - Multiline doctest using `>>>` and `...` continuation lines. - Standalone `...` only lines remain unchanged. ## Doc Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=191372963
Configuration menu - View commit details
-
Copy full SHA for 8a5b3bf - Browse repository at this point
Copy the full SHA 8a5b3bfView commit details -
Configuration menu - View commit details
-
Copy full SHA for d791458 - Browse repository at this point
Copy the full SHA d791458View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3e5f4a0 - Browse repository at this point
Copy the full SHA 3e5f4a0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7188bbf - Browse repository at this point
Copy the full SHA 7188bbfView commit details -
Configuration menu - View commit details
-
Copy full SHA for 5bc8c99 - Browse repository at this point
Copy the full SHA 5bc8c99View commit details -
Configuration menu - View commit details
-
Copy full SHA for 178fef7 - Browse repository at this point
Copy the full SHA 178fef7View commit details
Loading
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff 9.9.0...9.10.0