Skip to content

cProfile.Profile: timer=None signature differs from explicit None behavior #161233

Closed

Description

@youknowdot

Bug report

cProfile.Profile shows timer=None in its signature, but explicitly passing None causes unraisable TypeErrors while omitting it works.

Reproduced with CPython 3.15.0 and 3.15.2 on Linux x86_64 using python3.15 -I -S repro.py:

import cProfile
import inspect
import sys

print(inspect.signature(cProfile.Profile))
errors = []
sys.unraisablehook = lambda event: errors.append(event.exc_value)

def work():
    pass

for kwargs in ({}, {'timer': None}):
    errors.clear()
    profiler = cProfile.Profile(**kwargs)
    profiler.enable()
    work()
    profiler.disable()
    if errors:
        exc = errors[0]
        print(f'explicit None: {type(exc).__name__}: {exc}')
    else:
        print('omitted timer: OK')

Output on both versions:

(timer=None, timeunit=0.0, subcalls=True, builtins=True)
omitted timer: OK
explicit None: TypeError: 'NoneType' object is not callable

CPython versions tested on:

3.15

Operating systems tested on:

Linux

Linked PRs

Activity

  1. youknowone commented on Nov 3, 2026

    @youknowone
    Contributor

    similar to #161229

  2. self-assigned this
    on Nov 3, 2026
  3. added 3 commits that reference this issue on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions