Skip to content

Commit

Permalink
Reinforce in get_functions that eval/format methods are indeed callab…
Browse files Browse the repository at this point in the history
…le (#1322)

`Builtin.get_functions` collects attributes of the subclasses with names starting with a prefix and it assumes that these are methods. 

Until now, the way to check that they are indeed methods was to check if they have a docstring. What we want to check is whether the method is callable. In Python 3.13, this is needed.
This PR implements a callable check.
  • Loading branch information
mmatera authored Jan 29, 2025
1 parent 68f9287 commit b5b8857
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mathics/core/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ def get_functions(self, prefix="eval", is_pymodule=False):
for name in dir(self):
if name.startswith(prefix):
function = getattr(self, name)
if not hasattr(function, "__call__"):
continue
pattern = function.__doc__
if pattern is None: # Fixes PyPy bug
continue
Expand Down

0 comments on commit b5b8857

Please sign in to comment.