Skip to content

bpo-17735: make inspect.findsource raise OsError instead of IndexError wh…#23633

Merged
taleinat merged 3 commits into
python:masterfrom
iritkatriel:bpo-17735
Dec 4, 2020
Merged

bpo-17735: make inspect.findsource raise OsError instead of IndexError wh…#23633
taleinat merged 3 commits into
python:masterfrom
iritkatriel:bpo-17735

Conversation

@iritkatriel

@iritkatriel iritkatriel commented Dec 3, 2020

Copy link
Copy Markdown
Member

…en co_lineno is larger than length of file (can happen if file was updated since import)

The docstring says this function raises OSError when it can't find the source, so we make it so.
(The bpo is about the consequence of help() not handling IndexError.)

https://bugs.python.org/issue17735

@iritkatriel iritkatriel changed the title bpo-17735: inspect.findsource raises OsError instead of IndexError wh… bpo-17735: make inspect.findsource raise OsError instead of IndexError wh… Dec 3, 2020
@iritkatriel iritkatriel requested a review from taleinat December 3, 2020 22:27
iritkatriel and others added 2 commits December 4, 2020 17:01
…en co_lineno is larger than length of file (can happen if file was updated since import)

@taleinat taleinat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@taleinat taleinat merged commit 2e0760b into python:master Dec 4, 2020
@taleinat taleinat added needs backport to 3.8 type-bug An unexpected behavior, bug, or error labels Dec 4, 2020
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @iritkatriel for the PR, and @taleinat for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @iritkatriel for the PR, and @taleinat for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 4, 2020
…t of range (pythonGH-23633)

This can happen when a file was edited after it was imported.
(cherry picked from commit 2e0760b)

Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
@bedevere-bot

Copy link
Copy Markdown

GH-23646 is a backport of this pull request to the 3.9 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 4, 2020
…t of range (pythonGH-23633)

This can happen when a file was edited after it was imported.
(cherry picked from commit 2e0760b)

Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
@bedevere-bot

Copy link
Copy Markdown

GH-23647 is a backport of this pull request to the 3.8 branch.

miss-islington added a commit that referenced this pull request Dec 4, 2020
…t of range (GH-23633)

This can happen when a file was edited after it was imported.
(cherry picked from commit 2e0760b)

Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
taleinat pushed a commit that referenced this pull request Dec 4, 2020
…t of range (GH-23633)

This can happen when a file was edited after it was imported.
(cherry picked from commit 2e0760b)

Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
…t of range (pythonGH-23633)

This can happen when a file was edited after it was imported.
@iritkatriel iritkatriel deleted the bpo-17735 branch June 18, 2021 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants