Opened 5 years ago

Closed 5 years ago

#17673 closed enhancement (worksforme)

Make NamedBinopMethod remember the name and module

Reported by: vdelecroix Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: coercion Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by vdelecroix)

Currently

sage: from sage.structure.element import coerce_binop
sage: @coerce_binop
....: def f(a,b): return a+b
sage: f.__module__
Traceback (most recent call last):
...
AttributeError: ...
sage: f.__name__
Traceback (most recent call last):
...
AttributeError: ...

and with the branch

sage: from sage.structure.element import coerce_binop
sage: @coerce_binop
....: def f(a,b): return a+b
sage: f.__module__
'__main__'
sage: f.__name__
'f'

That way methods with this decorator will looks like method. In particular it will not break introspection (e.g. access to the documentation with ? and to the source code with ??).

Change History (3)

comment:1 Changed 5 years ago by vdelecroix

  • Branch set to public/17673
  • Commit set to 7d2009c7539cb638e492e0518f4dc11cc7f1d34c
  • Status changed from new to needs_review

New commits:

7d2009ctrac #17673: __module__/__name__ for coerce_binop

comment:2 Changed 5 years ago by vdelecroix

  • Authors Vincent Delecroix deleted
  • Branch public/17673 deleted
  • Commit 7d2009c7539cb638e492e0518f4dc11cc7f1d34c deleted
  • Description modified (diff)
  • Milestone changed from sage-6.5 to sage-duplicate/invalid/wontfix
  • Status changed from needs_review to positive_review
  • Type changed from defect to enhancement

It seems that I had a bug on my computer since the introspection is perfectly fine without this... obscure!

comment:3 Changed 5 years ago by vbraun

  • Resolution set to worksforme
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.