Skip to content
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

Small bug in doctest framework's mapping of Python 2 exception classes to Python 3 exceptions #26244

Closed
embray opened this issue Sep 11, 2018 · 6 comments

Comments

@embray
Copy link
Contributor

embray commented Sep 11, 2018

The doctest framework has some built-in mappings of built-in exception classes from their Python 2 spellings to their Python 3, so that doctests that expect those exceptions can be raised can be written for Python 2 but still work on Python 3: #25676

There is at least one case where the current implementation of this fails. See: #26213 comment:22

CC: @fchapoton

Component: python3

Reviewer: Matthias Koeppe, Frédéric Chapoton

Issue created by migration from https://trac.sagemath.org/ticket/26244

@embray embray added this to the sage-8.4 milestone Sep 11, 2018
@embray
Copy link
Contributor Author

embray commented Sep 11, 2018

comment:1

If you would like to take a stab at it. Otherwise I'll fix it. It's just a question of slightly rearranging this code in sage.doctest.forker:

 702                     else:
 703                         # Special case: On Python 3 these exceptions are all
 704                         # just aliases for OSError
 705                         for alias in _OSError_ALIASES:
 706                             if example.exc_msg.startswith(alias + ':'):
 707                                 exc_msg = exc_msg.replace('OSError', alias, 1)
 708                                 break
 709                         else:
 710                             for subcls in _OSError_SUBCLASSES:
 711                                 if exc_msg.startswith(subcls + ':'):
 712                                     exc_msg = exc_msg.replace(subcls, 'OSError',
 713
 714                                                               1)
 715                                     break

@embray embray modified the milestones: sage-8.4, sage-8.5 Oct 28, 2018
@embray
Copy link
Contributor Author

embray commented Dec 28, 2018

comment:3

Retargeting some of my tickets (somewhat optimistically for now).

@embray embray modified the milestones: sage-8.5, sage-8.7 Dec 28, 2018
@embray
Copy link
Contributor Author

embray commented Mar 25, 2019

comment:4

Removing most of the rest of my open tickets out of the 8.7 milestone, which should be closed.

@embray embray removed this from the sage-8.7 milestone Mar 25, 2019
@embray embray added the pending label Mar 25, 2019
@mkoeppe
Copy link
Member

mkoeppe commented Oct 10, 2021

comment:5

outdated?

@fchapoton
Copy link
Contributor

comment:6

ok

@slel
Copy link
Member

slel commented Oct 25, 2021

Reviewer: Matthias Koeppe, Frédéric Chapoton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants