Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trac #33064: sage_docbuild: fails when cache cannot be saved
When doctesting `src/sage_docbuild/__init__.py` on a read-only location we get a failure which ultimately boils down to: {{{ ┌────────────────────────────────────────────────────────────────────┐ │ SageMath version 9.5.beta8, Release Date: 2021-12-12 │ │ Using Python 3.10.1. Type "help()" for help. │ └────────────────────────────────────────────────────────────────────┘ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Warning: this is a prerelease version, and it may be unstable. ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ sage: from sage_docbuild import DocBuilder, setup_parser, ReferenceSubBuilder sage: DocBuilder._options = setup_parser().parse_args([]) sage: import sage_docbuild.sphinxbuild sage: def raiseBaseException(): ....: raise BaseException("abort pool operation") ....: sage: original_runsphinx, sage_docbuild.sphinxbuild.runsphinx = sage_docbuild.sphinxbuild.runsphinx, raiseBaseException sage: ReferenceSubBuilder("docname", "en")._wrapper("html") ------------------------------------------------------------------------ --- PermissionError Traceback (most recent call last) <ipython-input-11-7faec88fcc76> in <module> ----> 1 ReferenceSubBuilder("docname", "en")._wrapper("html") /usr/lib/sage-9.5.beta8/local/var/lib/sage/venv- python3.10/lib/python3.10/site-packages/sage_docbuild/__init__.py in _wrapper(self, build_type, *args, **kwds) 797 cache['option_inherited'] = self._options.inherited 798 cache['option_underscore'] = self._options.underscore --> 799 self.save_cache() 800 801 # After "sage -clone", refresh the reST file mtimes in /usr/lib/sage-9.5.beta8/local/var/lib/sage/venv- python3.10/lib/python3.10/site-packages/sage_docbuild/__init__.py in save_cache(self) 857 """ 858 cache = self.get_cache() --> 859 with open(self.cache_filename(), 'wb') as file: 860 pickle.dump(cache, file) 861 logger.debug("Saved the reference cache: %s", self.cache_filename()) PermissionError: [Errno 13] Permission denied: '/usr/lib/sage-9.5.beta8/ local/share/doc/sage/doctrees/en/docname/reference.pickle' }}} This is due to a `save_cache()` method trying to save into that file; I believe it would be harmless to ignore this permission error (if the cache is not saved, it will have to be regenerated, so what). URL: https://trac.sagemath.org/33064 Reported by: tornaria Ticket author(s): Gonzalo Tornaría Reviewer(s): John Palmieri
- Loading branch information