Skip to content

Conversation

@user202729
Copy link
Contributor

@user202729 user202729 commented Oct 18, 2025

see the newly added test, previously it.

The reason this affect users is that if in a shell you type

sage: class C:
....:     '''
....:     docs
....:     '''
sage: C?

then you'd get an error. After this change, it prints out something somewhat sensible. (also added as a test)

I'm not 100% sure what's a good way out on it be this one. On one hand, you ought to make sage_getfile behave the same way as https://docs.python.org/3/library/inspect.html#inspect.getfile; on the other hand it is not documented by https://docs.python.org/3/library/inspect.html#inspect.getfile that it may raise OSError, so IPython isn't prepared to deal with it.

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

@github-actions
Copy link

github-actions bot commented Oct 18, 2025

Documentation preview for this PR (built with commit 5640b02; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@cxzhong cxzhong requested a review from tobiasdiez October 19, 2025 18:45
vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 26, 2025
sagemathgh-41071: Fix missing file error with sage_getdoc
    
see the newly added test, previously it.

The reason this affect users is that if in a shell you type

```
sage: class C:
....:     '''
....:     docs
....:     '''
sage: C?
```

then you'd get an error. After this change, it prints out something
somewhat sensible. (also added as a test)

I'm not 100% sure what's a good way out on it be this one. On one hand,
you ought to make `sage_getfile` behave the same way as
https://docs.python.org/3/library/inspect.html#inspect.getfile; on the
other hand it is not documented by
https://docs.python.org/3/library/inspect.html#inspect.getfile that it
may raise `OSError`, so IPython isn't prepared to deal with it.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#41071
Reported by: user202729
Reviewer(s): Chenxin Zhong
@vbraun vbraun merged commit b8d8519 into sagemath:develop Oct 27, 2025
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants