Opened 7 years ago

Closed 7 years ago

#18249 closed defect (fixed)

Introspection for builtin functions

Reported by: SimonKing Owned by:
Priority: major Milestone: sage-6.7
Component: misc Keywords:
Cc: Merged in:
Authors: Simon King Reviewers: Volker Braun
Report Upstream: N/A Work issues:
Branch: e478d5b (Commits, GitHub, GitLab) Commit: e478d5b842268da0314778105e6801f316d7070c
Dependencies: #17814 Stopgaps:

Status badges

Description (last modified by SimonKing)

Up to now, the attempt to inspect Python builtins with ? results in a TypeError, raised by Python's inspect module. This is when the argspec or the source file is requested.

I suggest to return generic information. With the attached branch, we get

sage: range?
Docstring:
range(stop) -> list of integers range(start, stop[, step]) -> list of
integers

Return a list containing an arithmetic progression of integers.
range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.
When step is given, it specifies the increment (or decrement). For
example, range(4) returns [0, 1, 2, 3].  The end point is omitted!
These are exactly the valid indices for a list of 4 elements.
Init docstring: x.__init__(...) initializes x; see help(type(x)) for signature
File:           
Type:           builtin_function_or_method

Change History (8)

comment:1 Changed 7 years ago by SimonKing

  • Branch set to u/SimonKing/introspection_for_builtin_functions

comment:2 Changed 7 years ago by SimonKing

  • Authors set to Simon King
  • Commit set to dffa7659dc2f0129458fa7394b851fa018f91363
  • Component changed from PLEASE CHANGE to misc
  • Dependencies set to #17814
  • Description modified (diff)
  • Status changed from new to needs_review
  • Type changed from PLEASE CHANGE to defect

New commits:

30543e7Avoid source inspection for cached cython methods without arguments
a0b829dMake a cached function/method work with default argspec when introspection fails
831173bMerge branch 't/17814/make_calling_a_cached_method_independent_of_source_code_inspection' into t/17814/rebased-make_calling_a_cached_method_independent_of_source_code_inspection
b340eebUse embedded signature for introspection
0e8ef00Catch syntax error when extraction of signature fails
dffa765Introspection of builtins returns generic data instead of raising an error

comment:3 Changed 7 years ago by vbraun

  • Reviewers set to Volker Braun
  • Status changed from needs_review to needs_work

Merge conflict, can you merge in 6.7.beta3

Code looks good, set to positive review when you are done.

comment:4 Changed 7 years ago by SimonKing

Can someone else please do the merge, I will be too busy till next week.

comment:5 Changed 7 years ago by jdemeyer

  • Branch changed from u/SimonKing/introspection_for_builtin_functions to u/jdemeyer/introspection_for_builtin_functions

comment:6 Changed 7 years ago by jdemeyer

  • Commit changed from dffa7659dc2f0129458fa7394b851fa018f91363 to e478d5b842268da0314778105e6801f316d7070c
  • Status changed from needs_work to needs_review

New commits:

e478d5bMerge tag '6.7.beta3' into t/18249/introspection_for_builtin_functions

comment:7 Changed 7 years ago by vbraun

  • Status changed from needs_review to positive_review

comment:8 Changed 7 years ago by vbraun

  • Branch changed from u/jdemeyer/introspection_for_builtin_functions to e478d5b842268da0314778105e6801f316d7070c
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.