Skip to content

Remove monkey patching of inspect.isfunction in sage.__init__ #32479

@mkoeppe

Description

@mkoeppe

"Monkey-patch inspect.isfunction() to support Cython functions."

Introduced in 2018 (8.3.beta2) in #25373 (for #24994).

However, this change has been rejected by upstream (https://bugs.python.org/issue30071, https://www.python.org/dev/peps/pep-0575/, https://www.python.org/dev/peps/pep-0580/).

In this ticket:

  • we remove the monkey-patching

  • replace unnecessary uses of inspect in ordinary Sage library code by other solutions

  • replace remaining uses of inspect.isfunction by the new name of our monkey-patched variant: sage.misc.sageinspect.is_function_or_cython_function

(To be checked whether https://www.python.org/dev/peps/pep-0590, superseding some of the above rejected PEPs, offers help; see also the informational PEP https://www.python.org/dev/peps/pep-0579/)

Related:

Depends on #31420

CC: @fchapoton @kwankyu @jhpalmieri @orlitzky

Component: refactoring

Author: Matthias Koeppe

Branch/Commit: 2ba4c43

Reviewer: Michael Orlitzky

Issue created by migration from https://trac.sagemath.org/ticket/32479

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions