Skip to content

Commit 4d2dd49

Browse files
author
Release Manager
committed
gh-36696: Fix SSL timeout in doctest / internet feature Recently I've been getting timeouts in a couple of doctests in `src/sage/doctest/control.py`, including earlier today when testing 10.2.rc1 This has two causes: 1. The test for the internet feature doesn't catch a `TimeoutError`. 2. These two doctests cause internet feature to be tested. The first one is clearly a bug: sagemath only expects `urllib.error.URLError`, but in some cases urllib raises `TimeoutError`. Arguably a bug in urlib, but easier to fix (or workaround) on our side. Done in the first commit of this PR. The second one is IMO a bug, since I didn't use `--optional=internet` no test should hit internet (in particular, should not test internet feature). These two doctests are meant to test options `--hide=all` and `--hide=optional`. For some reason the semantics of these include testing for the internet feature. I believe the semantics of these options should be similar to `--optional=all`, that is, exclude "external" software (internet feature is considered "external"). That's what I implemented in the second commit in this PR. - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. URL: #36696 Reported by: Gonzalo Tornaría Reviewer(s):
2 parents 613775f + 4a70c1e commit 4d2dd49

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/sage/doctest/control.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,15 @@ def __init__(self, options, args):
457457
options.hide.discard('all')
458458
from sage.features.all import all_features
459459
feature_names = {f.name for f in all_features() if not f.is_standard()}
460+
from sage.doctest.external import external_software
461+
feature_names.difference_update(external_software)
460462
options.hide = options.hide.union(feature_names)
461463
if 'optional' in options.hide:
462464
options.hide.discard('optional')
463465
from sage.features.all import all_features
464466
feature_names = {f.name for f in all_features() if f.is_optional()}
467+
from sage.doctest.external import external_software
468+
feature_names.difference_update(external_software)
465469
options.hide = options.hide.union(feature_names)
466470

467471
options.disabled_optional = set()

src/sage/features/internet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _is_present(self):
5656
try:
5757
urlopen(req, timeout=1, context=default_context())
5858
return FeatureTestResult(self, True)
59-
except urllib.error.URLError:
59+
except (urllib.error.URLError, TimeoutError):
6060
return FeatureTestResult(self, False)
6161

6262

0 commit comments

Comments
 (0)