-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
bpo-17972: Document findsource in inspect.rst
#6992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -511,10 +511,25 @@ Retrieving source code | |||||
| returned as a single string. An :exc:`OSError` is raised if the source code | ||||||
| cannot be retrieved. | ||||||
|
|
||||||
| If *object* is a wrapper function (that is to say has a :attr:`__wrapped__` | ||||||
| field, :func:`getsource` will follows the chain of :attr:`__wrapped__` | ||||||
| attributes returning the last object in the chain using :func:`unwrap` | ||||||
|
|
||||||
| .. versionchanged:: 3.3 | ||||||
| :exc:`OSError` is raised instead of :exc:`IOError`, now an alias of the | ||||||
| former. | ||||||
|
|
||||||
| .. function:: findsource(object) | ||||||
|
|
||||||
| Return the entire source file and starting line number for an object. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be explicit that the function is returning a tuple, maybe by starting like this and describing both elements: |
||||||
|
|
||||||
| The argument may be a module, class, method, function, traceback, frame, | ||||||
| or code object. The source code is returned as a list of all the lines | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The sentence starting here may be redundent if you fix the previous comment. |
||||||
| in the file and the line number indexes a line in that list. An OSError | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please link to the actual exception, at least as a visual hint while reading (this make it rendered differently in HTML):
Suggested change
|
||||||
| is raised if the source code cannot be retrieved. | ||||||
|
|
||||||
| Prefer the use of :func:`getsource` if possible. | ||||||
|
|
||||||
|
|
||||||
| .. function:: cleandoc(doc) | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Document :func:`inspect.findsource` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a dot at end of sentence: