Opened 3 years ago

Closed 3 years ago

#25676 closed enhancement (fixed)

py3: Automatically alias OSError subclasses in exception doctests

Reported by: embray Owned by:
Priority: major Milestone: sage-8.4
Component: python3 Keywords: doctests
Cc: slelievre, vklein Merged in:
Authors: Erik Bray Reviewers: Frédéric Chapoton, Vincent Klein
Report Upstream: N/A Work issues:
Branch: 4fff9a0 (Commits, GitHub, GitLab) Commit: 4fff9a01300c548f2e68ebecc585905553be98b3
Dependencies: Stopgaps:

Status badges

Description

There are at least a handful of doctests that expect OSError to be raised. However, Python 3 added many OSError subclasses that are raised in many common cases instead (e.g. FileNotFoundError).

This patches doctest results to paper over this difference in doctests written against Python 2.

Change History (15)

comment:1 Changed 3 years ago by embray

  • Status changed from new to needs_review

comment:2 Changed 3 years ago by slelievre

  • Cc slelievre added
  • Summary changed from py3: Automatically alias OSError subclases in exception doctests to py3: Automatically alias OSError subclasses in exception doctests

comment:3 follow-up: Changed 3 years ago by chapoton

pyflakes plugin is not happy..

comment:4 in reply to: ↑ 3 Changed 3 years ago by embray

Replying to chapoton:

pyflakes plugin is not happy..

Not due to anything related to these changes. If someone will otherwise give a conditional positive review to this ticket I'll make sure the pyflakes warnings get taken care of as a rider to this before it's merged.

comment:5 Changed 3 years ago by vklein

  • Cc vklein added

comment:6 Changed 3 years ago by vklein

Edit remove old comment as it matters only with twisted ways of building error messages.

Last edited 3 years ago by vklein (previous) (diff)

comment:7 Changed 3 years ago by vklein

Why two line break ?

                                    exc_msg = exc_msg.replace(subcls, 'OSError',

                                                              1)

comment:8 Changed 3 years ago by embray

Huh?

comment:9 Changed 3 years ago by vklein

i mean why writing :

exc_msg = exc_msg.replace(subcls, 'OSError',

                          1)

rather than

exc_msg = exc_msg.replace(subcls, 'OSError',
                          1)
}}}.

I am not saying it's an important issue (it's not). I just wonder why.
Version 0, edited 3 years ago by vklein (next)

comment:10 Changed 3 years ago by embray

I don't know. My editor is configured to enforce a 79 character line and knows Python syntax (most of the time) so it will bump things onto the next line when it can.

comment:11 Changed 3 years ago by slelievre

Name the subclass "sc" instead of "subcls" in the for loop to get a shorter line?

comment:12 Changed 3 years ago by embray

It's....really okay.

comment:13 Changed 3 years ago by chapoton

  • Reviewers set to Frédéric Chapoton, Vincent Klein
  • Status changed from needs_review to positive_review

let it be

comment:14 Changed 3 years ago by embray

  • Milestone changed from sage-8.3 to sage-8.4

I believe this issue can reasonably be addressed for Sage 8.4.

comment:15 Changed 3 years ago by vbraun

  • Branch changed from u/embray/python3/doctest/oserror-subclasses to 4fff9a01300c548f2e68ebecc585905553be98b3
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.