Skip to content
Permalink

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
Choose a base ref
...
head repository: ipython/ipython
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9.10.0
Choose a head ref
  • 14 commits
  • 7 files changed
  • 3 contributors

Commits on Dec 26, 2025

  1. fix: Removing leading indentation #15089

    michaelj094 committed Dec 26, 2025
    Configuration menu
    Copy the full SHA
    d4aa4c8 View commit details
    Browse the repository at this point in the history

Commits on Jan 3, 2026

  1. Configuration menu
    Copy the full SHA
    1110979 View commit details
    Browse the repository at this point in the history

Commits on Jan 5, 2026

  1. back to dev

    Carreau committed Jan 5, 2026
    Configuration menu
    Copy the full SHA
    28d9b9c View commit details
    Browse the repository at this point in the history

Commits on Jan 22, 2026

  1. Configuration menu
    Copy the full SHA
    8e7ebe4 View commit details
    Browse the repository at this point in the history
  2. conditional register_at_fork

    Carreau committed Jan 22, 2026
    Configuration menu
    Copy the full SHA
    e3c66c0 View commit details
    Browse the repository at this point in the history
  3. fix typing

    Carreau committed Jan 22, 2026
    Configuration menu
    Copy the full SHA
    add29df View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    e602694 View commit details
    Browse the repository at this point in the history

Commits on Jan 23, 2026

  1. 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
    ```
    Carreau authored Jan 23, 2026
    Configuration menu
    Copy the full SHA
    7dbbd24 View commit details
    Browse the repository at this point in the history

Commits on Feb 2, 2026

  1. 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
    Carreau authored Feb 2, 2026
    Configuration menu
    Copy the full SHA
    8a5b3bf View commit details
    Browse the repository at this point in the history
  2. Add debug info for autoreload.

    See issue #15116
    Carreau committed Feb 2, 2026
    Configuration menu
    Copy the full SHA
    d791458 View commit details
    Browse the repository at this point in the history
  3. Add debug info for autoreload. (#15118)

    See issue #15116
    Carreau authored Feb 2, 2026
    Configuration menu
    Copy the full SHA
    3e5f4a0 View commit details
    Browse the repository at this point in the history
  4. whatsnew 9.10

    Carreau committed Feb 2, 2026
    Configuration menu
    Copy the full SHA
    7188bbf View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    5bc8c99 View commit details
    Browse the repository at this point in the history
  6. release 9.10.0

    Carreau committed Feb 2, 2026
    Configuration menu
    Copy the full SHA
    178fef7 View commit details
    Browse the repository at this point in the history
Loading