Skip to content

Commit a5c4b48

Browse files
author
Release Manager
committed
gh-39193: Some improvements to findstat._submit * for some reason the proper header is needed to open the HTML file on my machine. * It's reported that `webbrowser.open()` doesn't work when called on a file path, rather an URI is needed (#38946) ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. (not needed) ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #39193 Reported by: user202729 Reviewer(s): Martin Rubey
2 parents 3950c7d + 4a82a39 commit a5c4b48

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/sage/databases/findstat.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ def mapping(sigma):
213213

214214
from ast import literal_eval
215215
from copy import deepcopy
216+
from pathlib import Path
216217
import re
217218
import webbrowser
218219
import tempfile
@@ -491,8 +492,9 @@ def _submit(args, url):
491492
....: "CurrentEmail": ""}
492493
sage: _submit(args, url) # optional -- webbrowser
493494
"""
494-
f = tempfile.NamedTemporaryFile(mode='w', suffix='.html', delete=False)
495+
f = tempfile.NamedTemporaryFile(mode='w', suffix='.html', encoding='utf-8', delete=False)
495496
verbose("Created temporary file %s" % f.name, caller_name='FindStat')
497+
f.write('<!doctype html>\n<html lang="en">\n<meta charset="utf-8">\n')
496498
f.write(FINDSTAT_POST_HEADER)
497499
f.write(url)
498500
for key, value in args.items():
@@ -506,7 +508,7 @@ def _submit(args, url):
506508
f.write(FINDSTAT_FORM_FOOTER)
507509
f.close()
508510
verbose("Opening file with webbrowser", caller_name='FindStat')
509-
webbrowser.open(f.name)
511+
webbrowser.open(Path(f.name).as_uri())
510512

511513

512514
def _data_to_str(data, domain, codomain=None):

0 commit comments

Comments
 (0)