././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1757661087.8017535 zope_exceptions-6.0/0000755000076600000240000000000015060743640014305 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/.pre-commit-config.yaml0000644000076600000240000000132615060743636020575 0ustar00m.howitzstaff# Generated from: # https://github.com/zopefoundation/meta/tree/master/config/pure-python minimum_pre_commit_version: '3.6' repos: - repo: https://github.com/pycqa/isort rev: "6.0.1" hooks: - id: isort - repo: https://github.com/hhatto/autopep8 rev: "v2.3.2" hooks: - id: autopep8 args: [--in-place, --aggressive, --aggressive] - repo: https://github.com/asottile/pyupgrade rev: v3.20.0 hooks: - id: pyupgrade args: [--py39-plus] - repo: https://github.com/isidentical/teyit rev: 0.4.3 hooks: - id: teyit - repo: https://github.com/PyCQA/flake8 rev: "7.3.0" hooks: - id: flake8 additional_dependencies: - flake8-debugger == 4.1.2 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/.readthedocs.yaml0000644000076600000240000000123515060743636017542 0ustar00m.howitzstaff# Generated from: # https://github.com/zopefoundation/meta/tree/master/config/pure-python # Read the Docs configuration file # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details # Required version: 2 # Set the version of Python and other tools you might need build: os: ubuntu-22.04 tools: python: "3.11" # Build documentation in the docs/ directory with Sphinx sphinx: configuration: docs/conf.py # We recommend specifying your dependencies to enable reproducible builds: # https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html python: install: - requirements: docs/requirements.txt - method: pip path: . ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/CHANGES.rst0000644000076600000240000001361615060743636016123 0ustar00m.howitzstaff=========================== zope.exceptions Changelog =========================== 6.0 (2025-09-12) ================ - Replace ``pkg_resources`` namespace with PEP 420 native namespace. - Drop support for Python 3.8. 5.2 (2024-10-30) ================ - Drop support for Python 3.7. - Add support for Python 3.13. 5.1 (2024-06-07) ================ - Add support for Python 3.12. - Include code from PEP302 loaders in tracebacks. 5.0.1 (2023-07-11) ================== - Fix issue introduced in the last release which is breaking ``HTMLExceptionFormatter`` when using non-str ``__traceback_info__``. 5.0 (2023-06-29) ================ - Drop support for Python 2.7, 3.5, 3.6. 4.6 (2022-11-10) ================ - Catch exceptions in ``formatExceptionOnly``. Getting an exception when reporting about a different exception is not helpful. On Python 3.11 this is needed for some HTTPErrors. - Add official support for Python 3.11. 4.5 (2022-02-11) ================ - Add official support for Python 3.9 and 3.10. - Undo dropping support for Python 3.5. - Drop support for running the tests using ``python setup.py test``. 4.4 (2020-07-16) ================ - Add support for Python 3.8 and preliminary support for 3.9b4. - Drop support for Python 3.4 and 3.5. 4.3 (2018-10-04) ================ - Add support for Python 3.7. 4.2.0 (2017-09-12) ================== - Add support for Python 3.6. - Drop support for Python 3.3. - Fix handling of unicode supplemental traceback information on Python 2. Now such values are always encoded to UTF-8; previously the results were undefined and depended on system encodings and the values themselves. See `issue 1 `_. 4.1.0 (2017-04-12) ================== - Drop support for Python 2.6 and 3.2. - Make ``exceptionformatter.extract_stack`` signature comply with ``traceback.extract_stack`` - Add support for Python 3.5. 4.0.8 (2015-08-13) ================== - Fixes around ``TextExceptionFormatter`` ``limit``: ``formatException`` and ``extractStack`` was cutting the traceback at the bottom, at the most interesting point. Now it will cut from the middle. Some text about the missing entries will be inserted. - Maybe fix for ``extractStack``, it did not detect recursions in the frames. 4.0.7 (2014-03-19) ================== - Added explicit support for Python 3.4. - Updated ``boostrap.py`` to version 2.2. 4.0.6 (2013-02-28) ================== - Make sure that ``setup.py`` finds all tests. Now tox runs them all as well. - Fix failing test under Python 3. - Made buildout work under Python 3 and Buildout 2. 4.0.5 (2012-12-31) ================== - Fleshed out PyPI Trove classifiers. - Fixed a test failure under Python 2.6. 4.0.4 (2012-12-13) ================== - Release with a fixed MANIFEST.in (without ``docs/``) 4.0.3 (2012-12-10) ================== - Fixed format_exception(..., as_html=True) not to HTML-escape the '
' it adds to the exception value. 4.0.2 (2012-11-21) ================== - Test Python 3.3 support under tox. 4.0.1 (2012-08-20) ================== - Fixed optional dependency code for `'zope.security`` to work under Python 3.3. 4.0.0.1 (2012-05-16) ==================== - Fixed rendering of package docs on PyPI. 4.0.0 (2012-05-16) ================== - Automated build of Sphinx HTML docs and running doctest snippets via tox. - Added Sphinx documentation. - Added support for continuous integration using ``tox`` and ``jenkins``. - Removed use of '2to3' and associated fixers when installing under Py3k. The code is now in a "compatible subset" which supports Python 2.6, 2.7, and 3.2, including PyPy 1.8 (the version compatible with the 2.7 language spec). - 100% unit test coverage. - Dropped explicit support for Python 2.4 / 2.5 / 3.1. - Added 'setup.py dev' alias (runs ``setup.py develop`` plus installs ``nose`` and ``coverage``). - Added 'setup.py docs' alias (installs ``Sphinx`` and dependencies). 3.7.1 (2012-03-28) ================== - Fix: missed to reverse extractStack entries 3.7.0 (2012-03-28) ================== - Added TextExceptionFormatter.extractStack and extract_stack 3.6.2 (2012-03-28) ================== - Fallback to traceback.format_tb when the formatter is called recursively. i.e. Don't let errors in the formatter pass silently. - Fix deprecated unittest functions: ``assert_`` and ``assertEquals``. 3.6.1 (2010-07-06) ================== - Fixed tests to work under Python 2.7. - PEP8 cleanup and removed obsolete build infrastructure files. 3.6.0 (2010-05-02) ================== - Added support to bootstrap on Jython. - Added Python 3 support. - The dependency on zope.testing seemed spurious, possibly a rest of a real dependency that is gone now. I removed it. 3.5.2 (2008-04-30) ================== - Updated CHANGES.txt. 3.5.1 (2008-04-28) ================== - Reverted changes in 3.5.0. 3.5.0 ===== - Added the capability for exceptions to be formatted line-by-line. Unfortunately, also introduced a bug cause each line of the exception to be its own log message. 3.4.0 (2007-10-02) ================== - Updated package meta-data. 3.4.0b2 (2007-08-14) ==================== - Removed superfluous dependency on ``zope.deprecation``. 3.4.0b1 (2007-07-09) ==================== - Corresponds to the version of the ``zope.exceptions`` package shipped as part of the Zope 3.4.0b1 release. 3.2.0 (2006-01-05) ================== - Corresponds to the version of the ``zope.exceptions`` package shipped as part of the Zope 3.2.0 release. - Deprecated the ``INotFoundError`` interface and the corresponding ``NotFoundError`` exception class, in favor of "standard" exceptions ``AttributeError``, ``KeyError``). The deprecated items will be removed in Zope 3.3. 3.0.0 (2004-11-07) ================== - Corresponds to the version of the zope.exceptions package shipped as part of the Zope X3.0.0 release. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/CONTRIBUTING.md0000644000076600000240000000144315060743636016545 0ustar00m.howitzstaff # Contributing to zopefoundation projects The projects under the zopefoundation GitHub organization are open source and welcome contributions in different forms: * bug reports * code improvements and bug fixes * documentation improvements * pull request reviews For any changes in the repository besides trivial typo fixes you are required to sign the contributor agreement. See https://www.zope.dev/developer/becoming-a-committer.html for details. Please visit our [Developer Guidelines](https://www.zope.dev/developer/guidelines.html) if you'd like to contribute code changes and our [guidelines for reporting bugs](https://www.zope.dev/developer/reporting-bugs.html) if you want to file a bug report. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/COPYRIGHT.txt0000644000076600000240000000004015060743636016415 0ustar00m.howitzstaffZope Foundation and Contributors././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/LICENSE.txt0000644000076600000240000000402615060743636016137 0ustar00m.howitzstaffZope Public License (ZPL) Version 2.1 A copyright notice accompanies this license document that identifies the copyright holders. This license has been certified as open source. It has also been designated as GPL compatible by the Free Software Foundation (FSF). Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions in source code must retain the accompanying copyright notice, this list of conditions, and the following disclaimer. 2. Redistributions in binary form must reproduce the accompanying copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Names of the copyright holders must not be used to endorse or promote products derived from this software without prior written permission from the copyright holders. 4. The right to distribute this software or to use it for any purpose does not give you the right to use Servicemarks (sm) or Trademarks (tm) of the copyright holders. Use of them is covered by separate agreement with the copyright holders. 5. If any files are modified, you must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. Disclaimer THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/MANIFEST.in0000644000076600000240000000060715060743636016053 0ustar00m.howitzstaff# Generated from: # https://github.com/zopefoundation/meta/tree/master/config/pure-python include *.md include *.rst include *.txt include buildout.cfg include tox.ini include .pre-commit-config.yaml recursive-include docs *.py recursive-include docs *.rst recursive-include docs *.txt recursive-include docs Makefile recursive-include src *.py include *.yaml recursive-include docs *.bat ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1757661087.8016722 zope_exceptions-6.0/PKG-INFO0000644000076600000240000002152015060743640015402 0ustar00m.howitzstaffMetadata-Version: 2.4 Name: zope.exceptions Version: 6.0 Summary: Zope Exceptions Home-page: https://github.com/zopefoundation/zope.exceptions Author: Zope Foundation and Contributors Author-email: zope-dev@zope.dev License: ZPL-2.1 Project-URL: Issue Tracker, https://github.com/zopefoundation/zope.exceptions/issues Project-URL: Sources, https://github.com/zopefoundation/zope.exceptions Keywords: zope exceptions Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Zope Public License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 Classifier: Programming Language :: Python :: 3.13 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Topic :: Internet :: WWW/HTTP Classifier: Framework :: Zope :: 3 Requires-Python: >=3.9 License-File: LICENSE.txt Requires-Dist: setuptools Requires-Dist: zope.interface Provides-Extra: docs Requires-Dist: Sphinx; extra == "docs" Requires-Dist: repoze.sphinx.autointerface; extra == "docs" Provides-Extra: test Requires-Dist: zope.testrunner>=6.4; extra == "test" Dynamic: author Dynamic: author-email Dynamic: classifier Dynamic: description Dynamic: home-page Dynamic: keywords Dynamic: license Dynamic: license-file Dynamic: project-url Dynamic: provides-extra Dynamic: requires-dist Dynamic: requires-python Dynamic: summary ================= zope.exceptions ================= .. image:: https://img.shields.io/pypi/v/zope.exceptions.svg :target: https://pypi.python.org/pypi/zope.exceptions/ :alt: Latest release .. image:: https://img.shields.io/pypi/pyversions/zope.exceptions.svg :target: https://pypi.org/project/zope.exceptions/ :alt: Supported Python versions .. image:: https://github.com/zopefoundation/zope.exceptions/actions/workflows/tests.yml/badge.svg :target: https://github.com/zopefoundation/zope.exceptions/actions/workflows/tests.yml .. image:: https://coveralls.io/repos/github/zopefoundation/zope.exceptions/badge.svg?branch=master :target: https://coveralls.io/github/zopefoundation/zope.exceptions?branch=master .. image:: https://readthedocs.org/projects/zopeexceptions/badge/?version=latest :target: https://zopeexceptions.readthedocs.io/en/latest/ :alt: Documentation Status This package contains exception exceptions and implementations which are so general purpose that they don't belong in Zope application-specific packages. Please see https://zopeexceptions.readthedocs.io/ for the documentation. =========================== zope.exceptions Changelog =========================== 6.0 (2025-09-12) ================ - Replace ``pkg_resources`` namespace with PEP 420 native namespace. - Drop support for Python 3.8. 5.2 (2024-10-30) ================ - Drop support for Python 3.7. - Add support for Python 3.13. 5.1 (2024-06-07) ================ - Add support for Python 3.12. - Include code from PEP302 loaders in tracebacks. 5.0.1 (2023-07-11) ================== - Fix issue introduced in the last release which is breaking ``HTMLExceptionFormatter`` when using non-str ``__traceback_info__``. 5.0 (2023-06-29) ================ - Drop support for Python 2.7, 3.5, 3.6. 4.6 (2022-11-10) ================ - Catch exceptions in ``formatExceptionOnly``. Getting an exception when reporting about a different exception is not helpful. On Python 3.11 this is needed for some HTTPErrors. - Add official support for Python 3.11. 4.5 (2022-02-11) ================ - Add official support for Python 3.9 and 3.10. - Undo dropping support for Python 3.5. - Drop support for running the tests using ``python setup.py test``. 4.4 (2020-07-16) ================ - Add support for Python 3.8 and preliminary support for 3.9b4. - Drop support for Python 3.4 and 3.5. 4.3 (2018-10-04) ================ - Add support for Python 3.7. 4.2.0 (2017-09-12) ================== - Add support for Python 3.6. - Drop support for Python 3.3. - Fix handling of unicode supplemental traceback information on Python 2. Now such values are always encoded to UTF-8; previously the results were undefined and depended on system encodings and the values themselves. See `issue 1 `_. 4.1.0 (2017-04-12) ================== - Drop support for Python 2.6 and 3.2. - Make ``exceptionformatter.extract_stack`` signature comply with ``traceback.extract_stack`` - Add support for Python 3.5. 4.0.8 (2015-08-13) ================== - Fixes around ``TextExceptionFormatter`` ``limit``: ``formatException`` and ``extractStack`` was cutting the traceback at the bottom, at the most interesting point. Now it will cut from the middle. Some text about the missing entries will be inserted. - Maybe fix for ``extractStack``, it did not detect recursions in the frames. 4.0.7 (2014-03-19) ================== - Added explicit support for Python 3.4. - Updated ``boostrap.py`` to version 2.2. 4.0.6 (2013-02-28) ================== - Make sure that ``setup.py`` finds all tests. Now tox runs them all as well. - Fix failing test under Python 3. - Made buildout work under Python 3 and Buildout 2. 4.0.5 (2012-12-31) ================== - Fleshed out PyPI Trove classifiers. - Fixed a test failure under Python 2.6. 4.0.4 (2012-12-13) ================== - Release with a fixed MANIFEST.in (without ``docs/``) 4.0.3 (2012-12-10) ================== - Fixed format_exception(..., as_html=True) not to HTML-escape the '
' it adds to the exception value. 4.0.2 (2012-11-21) ================== - Test Python 3.3 support under tox. 4.0.1 (2012-08-20) ================== - Fixed optional dependency code for `'zope.security`` to work under Python 3.3. 4.0.0.1 (2012-05-16) ==================== - Fixed rendering of package docs on PyPI. 4.0.0 (2012-05-16) ================== - Automated build of Sphinx HTML docs and running doctest snippets via tox. - Added Sphinx documentation. - Added support for continuous integration using ``tox`` and ``jenkins``. - Removed use of '2to3' and associated fixers when installing under Py3k. The code is now in a "compatible subset" which supports Python 2.6, 2.7, and 3.2, including PyPy 1.8 (the version compatible with the 2.7 language spec). - 100% unit test coverage. - Dropped explicit support for Python 2.4 / 2.5 / 3.1. - Added 'setup.py dev' alias (runs ``setup.py develop`` plus installs ``nose`` and ``coverage``). - Added 'setup.py docs' alias (installs ``Sphinx`` and dependencies). 3.7.1 (2012-03-28) ================== - Fix: missed to reverse extractStack entries 3.7.0 (2012-03-28) ================== - Added TextExceptionFormatter.extractStack and extract_stack 3.6.2 (2012-03-28) ================== - Fallback to traceback.format_tb when the formatter is called recursively. i.e. Don't let errors in the formatter pass silently. - Fix deprecated unittest functions: ``assert_`` and ``assertEquals``. 3.6.1 (2010-07-06) ================== - Fixed tests to work under Python 2.7. - PEP8 cleanup and removed obsolete build infrastructure files. 3.6.0 (2010-05-02) ================== - Added support to bootstrap on Jython. - Added Python 3 support. - The dependency on zope.testing seemed spurious, possibly a rest of a real dependency that is gone now. I removed it. 3.5.2 (2008-04-30) ================== - Updated CHANGES.txt. 3.5.1 (2008-04-28) ================== - Reverted changes in 3.5.0. 3.5.0 ===== - Added the capability for exceptions to be formatted line-by-line. Unfortunately, also introduced a bug cause each line of the exception to be its own log message. 3.4.0 (2007-10-02) ================== - Updated package meta-data. 3.4.0b2 (2007-08-14) ==================== - Removed superfluous dependency on ``zope.deprecation``. 3.4.0b1 (2007-07-09) ==================== - Corresponds to the version of the ``zope.exceptions`` package shipped as part of the Zope 3.4.0b1 release. 3.2.0 (2006-01-05) ================== - Corresponds to the version of the ``zope.exceptions`` package shipped as part of the Zope 3.2.0 release. - Deprecated the ``INotFoundError`` interface and the corresponding ``NotFoundError`` exception class, in favor of "standard" exceptions ``AttributeError``, ``KeyError``). The deprecated items will be removed in Zope 3.3. 3.0.0 (2004-11-07) ================== - Corresponds to the version of the zope.exceptions package shipped as part of the Zope X3.0.0 release. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/README.rst0000644000076600000240000000222715060743636016004 0ustar00m.howitzstaff================= zope.exceptions ================= .. image:: https://img.shields.io/pypi/v/zope.exceptions.svg :target: https://pypi.python.org/pypi/zope.exceptions/ :alt: Latest release .. image:: https://img.shields.io/pypi/pyversions/zope.exceptions.svg :target: https://pypi.org/project/zope.exceptions/ :alt: Supported Python versions .. image:: https://github.com/zopefoundation/zope.exceptions/actions/workflows/tests.yml/badge.svg :target: https://github.com/zopefoundation/zope.exceptions/actions/workflows/tests.yml .. image:: https://coveralls.io/repos/github/zopefoundation/zope.exceptions/badge.svg?branch=master :target: https://coveralls.io/github/zopefoundation/zope.exceptions?branch=master .. image:: https://readthedocs.org/projects/zopeexceptions/badge/?version=latest :target: https://zopeexceptions.readthedocs.io/en/latest/ :alt: Documentation Status This package contains exception exceptions and implementations which are so general purpose that they don't belong in Zope application-specific packages. Please see https://zopeexceptions.readthedocs.io/ for the documentation. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/buildout.cfg0000644000076600000240000000014115060743636016616 0ustar00m.howitzstaff[buildout] develop = . parts = test [test] recipe = zc.recipe.testrunner eggs = zope.exceptions ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1757661087.7992322 zope_exceptions-6.0/docs/0000755000076600000240000000000015060743640015235 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/docs/Makefile0000644000076600000240000001273415060743636016711 0ustar00m.howitzstaff# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/zopeexceptions.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/zopeexceptions.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/zopeexceptions" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/zopeexceptions" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/docs/api.rst0000644000076600000240000000221615060743636016546 0ustar00m.howitzstaff:mod:`zope.exceptions` API documentation ======================================== :py:mod:`zope.exceptions.interfaces` ------------------------------------ .. automodule:: zope.exceptions.interfaces :py:class:`~zope.exceptions.interfaces.ITracebackSupplement` ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .. autointerface:: zope.exceptions.interfaces.ITracebackSupplement :members: :member-order: source :py:mod:`zope.exceptions.exceptionformatter` -------------------------------------------- .. automodule:: zope.exceptions.exceptionformatter :py:func:`~zope.exceptions.exceptionformatter.format_exception` +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .. autofunction:: zope.exceptions.exceptionformatter.format_exception :py:func:`~zope.exceptions.exceptionformatter.print_exception` ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .. autofunction:: zope.exceptions.exceptionformatter.print_exception :py:func:`~zope.exceptions.exceptionformatter.extract_stack` ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .. autofunction:: zope.exceptions.exceptionformatter.extract_stack ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/docs/conf.py0000644000076600000240000002011315060743636016536 0ustar00m.howitzstaff# # zope.exceptions documentation build configuration file, created by # sphinx-quickstart on Fri Apr 6 16:11:13 2012. # # This file is execfile()d with the current directory set to its containing # dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out serve # to show the default. # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. # needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode', 'repoze.sphinx.autointerface', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = {'.rst': 'restructuredtext'} # The encoding of source files. # source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = 'zope.exceptions' copyright = '2012-2024, Zope Foundation contributors.' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = '4.3' # The full version, including alpha/beta/rc tags. release = '4.3' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: # today = '' # Else, today_fmt is used as the format for a strftime call. # today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all # documents. # default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. # add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). # add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. # show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. # html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". # html_title = None # A shorter title for the navigation bar. Default is the same as html_title. # html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. # html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. # html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. # html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. # html_use_smartypants = True # Custom sidebar templates, maps document names to template names. # html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. # html_additional_pages = {} # If false, no module index is generated. # html_domain_indices = True # If false, no index is generated. # html_use_index = True # If true, the index is split into individual pages for each letter. # html_split_index = False # If true, links to the reST sources are added to the pages. # html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. # html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. # html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. # html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). # html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'zopeexceptionsdoc' # -- Options for LaTeX output -------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # 'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples (source start # file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'zopeexceptions.tex', 'zope.exceptions Documentation', 'Zope Foundation contributors.', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. # latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. # latex_use_parts = False # If true, show page references after internal links. # latex_show_pagerefs = False # If true, show URL addresses after external links. # latex_show_urls = False # Documents to append as an appendix to all manuals. # latex_appendices = [] # If false, no module index is generated. # latex_domain_indices = True # -- Options for manual page output -------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [('index', 'zopeexceptions', 'zope.exceptions Documentation', ['Zope Foundation contributors.'], 1)] # If true, show URL addresses after external links. # man_show_urls = False # -- Options for Texinfo output ------------------------------------------ # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'zopeexceptions', 'zope.exceptions Documentation', 'Zope Foundation contributors.', 'zopeexceptions', 'Exceptions and implementations which are general purpose.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. # texinfo_appendices = [] # If false, no module index is generated. # texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. # texinfo_show_urls = 'footnote' # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = {'python': ('http://docs.python.org/', None)} ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/docs/hacking.rst0000644000076600000240000002170015060743636017400 0ustar00m.howitzstaffHacking on :mod:`zope.exceptions` ================================= Getting the Code ################ The main repository for :mod:`zope.exceptions` is in the Zope Foundation Github repository: https://github.com/zopefoundation/zope.exceptions You can get a read-only checkout from there: .. code-block:: sh $ git clone https://github.com/zopefoundation/zope.exceptions.git or fork it and get a writeable checkout of your fork: .. code-block:: sh $ git clone git@github.com/jrandom/zope.exceptions.git The project also mirrors the trunk from the Github repository as a Bazaar branch on Launchpad: https://code.launchpad.net/zope.exceptions You can branch the trunk from there using Bazaar: .. code-block:: sh $ bzr branch lp:zope.exceptions Working in a ``virtualenv`` ########################### Installing ---------- If you use the ``virtualenv`` package to create lightweight Python development environments, you can run the tests using nothing more than the ``python`` binary in a virtualenv. First, create a scratch environment: .. code-block:: sh $ /path/to/virtualenv --no-site-packages /tmp/hack-zope.exceptions Next, get this package registered as a "development egg" in the environment: .. code-block:: sh $ /tmp/hack-zope.exceptions/bin/python setup.py develop Running the tests ----------------- Run the tests using the build-in ``setuptools`` testrunner: .. code-block:: sh $ /tmp/hack-zope.exceptions/bin/python setup.py test -q running test ...--------------------------------------------------------------------- ---------------------------------------------------------------------- Ran 72 tests in 0.017s OK If you have the :mod:`nose` package installed in the virtualenv, you can use its testrunner too: .. code-block:: sh $ /tmp/hack-zope.exceptions/bin/easy_install nose ... $ /tmp/hack-zope.exceptions/bin/python setup.py nosetests running nosetests ........................................................................ ---------------------------------------------------------------------- Ran 73 tests in 0.010s OK or: .. code-block:: sh $ /tmp/hack-zope.exceptions/bin/nosetests ........................................................................ ---------------------------------------------------------------------- Ran 73 tests in 0.011s OK If you have the :mod:`coverage` pacakge installed in the virtualenv, you can see how well the tests cover the code: .. code-block:: sh $ /tmp/hack-zope.exceptions/bin/easy_install nose coverage ... $ /tmp/hack-zope.exceptions/bin/python setup.py nosetests \ --with coverage --cover-package=zope.exceptions running nosetests ... ......................................................................... Name Stmts Miss Cover Missing ------------------------------------------------------------------ zope.exceptions 10 0 100% zope.exceptions.exceptionformatter 171 0 100% zope.exceptions.interfaces 18 0 100% zope.exceptions.log 13 0 100% ------------------------------------------------------------------ TOTAL 212 0 100% ---------------------------------------------------------------------- OK Building the documentation -------------------------- :mod:`zope.exceptions` uses the nifty :mod:`Sphinx` documentation system for building its docs. Using the same virtualenv you set up to run the tests, you can build the docs: .. code-block:: sh $ /tmp/hack-zope.exceptions/bin/easy_install Sphinx ... $ cd docs $ PATH=/tmp/hack-zope.exceptions/bin:$PATH make html sphinx-build -b html -d _build/doctrees . _build/html ... build succeeded. Build finished. The HTML pages are in _build/html. You can also test the code snippets in the documentation: .. code-block:: sh $ bin/sphinx-build -b docs/doctest -d docs/_build/doctrees docs docs/_build/doctest ... 12 tests in 1 items. 12 passed and 0 failed. Test passed. Doctest summary =============== 12 tests 0 failures in tests 0 failures in setup code build succeeded. Testing of doctests in the sources finished, look at the \ results in _build/doctest/output.txt. Using :mod:`zc.buildout` ######################## Setting up the buildout ----------------------- :mod:`zope.exceptions` ships with its own :file:`buildout.cfg` file and :file:`bootstrap.py` for setting up a development buildout: .. code-block:: sh $ /path/to/python2.6 bootstrap.py ... Generated script '.../bin/buildout' $ bin/buildout Develop: '/home/jrandom/projects/Zope/BTK/exceptions/.' ... Generated script '.../bin/sphinx-quickstart'. Generated script '.../bin/sphinx-build'. Running the tests ----------------- Run the tests: .. code-block:: sh $ bin/test --all Running zope.testing.testrunner.layer.UnitTests tests: Set up zope.testing.testrunner.layer.UnitTests in 0.000 seconds. Ran 2 tests with 0 failures and 0 errors in 0.000 seconds. Tearing down left over layers: Tear down zope.testing.testrunner.layer.UnitTests in 0.000 seconds. Using :mod:`tox` ################ Running Tests on Multiple Python Versions ----------------------------------------- `tox `_ is a Python-based test automation tool designed to run tests against multiple Python versions. It creates a ``virtualenv`` for each configured version, installs the current package and configured dependencies into each ``virtualenv``, and then runs the configured commands. :mod:`zope.exceptions` configures the following :mod:`tox` environments via its ``tox.ini`` file: - The ``py26``, ``py27``, ``py33``, ``py34``, and ``pypy`` environments builds a ``virtualenv`` with ``pypy``, installs :mod:`zope.exceptions` and dependencies, and runs the tests via ``python setup.py test -q``. - The ``coverage`` environment builds a ``virtualenv`` with ``python2.6``, installs :mod:`zope.exceptions`, installs :mod:`nose` and :mod:`coverage`, and runs ``nosetests`` with statement coverage. - The ``docs`` environment builds a virtualenv with ``python2.6``, installs :mod:`zope.exceptions`, installs ``Sphinx`` and dependencies, and then builds the docs and exercises the doctest snippets. This example requires that you have a working ``python2.6`` on your path, as well as installing ``tox``: .. code-block:: sh $ tox -e py26 GLOB sdist-make: .../zope.interface/setup.py py26 sdist-reinst: .../zope.interface/.tox/dist/zope.interface-4.0.2dev.zip py26 runtests: commands[0] ...--------------------------------------------------------------------- ---------------------------------------------------------------------- Ran 72 tests in 0.000s OK ___________________________________ summary ____________________________________ py26: commands succeeded congratulations :) Running ``tox`` with no arguments runs all the configured environments, including building the docs and testing their snippets: .. code-block:: sh $ tox GLOB sdist-make: .../zope.interface/setup.py py26 sdist-reinst: .../zope.interface/.tox/dist/zope.interface-4.0.2dev.zip py26 runtests: commands[0] ... Doctest summary =============== 12 tests 0 failures in tests 0 failures in setup code 0 failures in cleanup code build succeeded. ___________________________________ summary ____________________________________ py26: commands succeeded py27: commands succeeded py32: commands succeeded pypy: commands succeeded coverage: commands succeeded docs: commands succeeded congratulations :) Contributing to :mod:`zope.exceptions` ###################################### Submitting a Bug Report ----------------------- :mod:`zope.exceptions` tracks its bugs on Github: https://github.com/zopefoundation/zope.exceptions/issues Please submit bug reports and feature requests there. Sharing Your Changes -------------------- .. note:: Please ensure that all tests are passing before you submit your code. If possible, your submission should include new tests for new features or bug fixes, although it is possible that you may have tested your new code by updating existing tests. If have made a change you would like to share, the best route is to fork the Githb repository, check out your fork, make your changes on a branch in your fork, and push it. You can then submit a pull request from your branch: https://github.com/zopefoundation/zope.exceptions/pulls If you branched the code from Launchpad using Bazaar, you have another option: you can "push" your branch to Launchpad: .. code-block:: sh $ bzr push lp:~jrandom/zope.exceptions/cool_feature After pushing your branch, you can link it to a bug report on Launchpad, or request that the maintainers merge your branch using the Launchpad "merge request" feature. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/docs/index.rst0000644000076600000240000000035415060743636017105 0ustar00m.howitzstaff:mod:`zope.exceptions` documentation ==================================== Contents: .. toctree:: :maxdepth: 2 narr api hacking Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/docs/make.bat0000644000076600000240000001177015060743636016655 0ustar00m.howitzstaff@ECHO OFF REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . set I18NSPHINXOPTS=%SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. devhelp to make HTML files and a Devhelp project echo. epub to make an epub echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. text to make text files echo. man to make manual pages echo. texinfo to make Texinfo files echo. gettext to make PO message catalogs echo. changes to make an overview over all changed/added/deprecated items echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "singlehtml" ( %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\zopeexceptions.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\zopeexceptions.ghc goto end ) if "%1" == "devhelp" ( %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp if errorlevel 1 exit /b 1 echo. echo.Build finished. goto end ) if "%1" == "epub" ( %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub file is in %BUILDDIR%/epub. goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex if errorlevel 1 exit /b 1 echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "text" ( %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text if errorlevel 1 exit /b 1 echo. echo.Build finished. The text files are in %BUILDDIR%/text. goto end ) if "%1" == "man" ( %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man if errorlevel 1 exit /b 1 echo. echo.Build finished. The manual pages are in %BUILDDIR%/man. goto end ) if "%1" == "texinfo" ( %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo if errorlevel 1 exit /b 1 echo. echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. goto end ) if "%1" == "gettext" ( %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale if errorlevel 1 exit /b 1 echo. echo.Build finished. The message catalogs are in %BUILDDIR%/locale. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes if errorlevel 1 exit /b 1 echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck if errorlevel 1 exit /b 1 echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest if errorlevel 1 exit /b 1 echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) :end ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/docs/narr.rst0000644000076600000240000001352215060743636016741 0ustar00m.howitzstaff============================== Using :mod:`zope.exceptions` ============================== This module extends the standard library's :mod:`traceback` module, allowing application code to add additional information to the formatted tracebacks using specially-named variables in the scope of a given frame. We will use examples of a rendering function that's meant to produce some output given a template and a set of options. But this rendering function is quite broken and produces a useless exception, so when we call it we'd like to be able to provide some more contextual information. .. doctest:: >>> import sys >>> def render(source, options): ... raise Exception("Failed to render") Annotating Application Code =========================== :py:data:`__traceback_info__` ----------------------------- This variable can only be defined at local scope. It will be converted to a string when added to the formatted traceback. .. doctest:: >>> def render_w_info(template_file, options): ... with open(template_file) as f: ... source = f.read() ... __traceback_info__ = '%s\n\n%s' % (template_file, source) ... render(source, options) This is convenient for quickly adding context information in an unstructured way, especially if you already have a string, or an object with a custom ``__str__`` or ``__repr__`` that provides the information you need (tuples of multiple such items also work well). However, if you need to format a string to produce readable information, as in the example above, this may have an undesirable runtime cost because it is calculated even when no traceback is formatted. For such cases, ``__traceback_supplement__`` may be helpful. :py:data:`__traceback_supplement__` ----------------------------------- This variable can be defined either at either local or global (module) scope. Unlike ``__traceback__info__`` this is structured data. It must consist of a sequence containing a function and the arguments to pass to that function. At runtime, only if a traceback needs to be formatted will the function be called, with the arguments, to produce a *supplement object*. Because the construction of the object is delayed until needed, this can be a less expensive way to produce lots of useful information with minimal runtime overhead. The formatting functions treat the resulting supplement object as if it supports the :py:class:`~zope.exceptions.interfaces.ITracebackSupplement` interface. The various attributes (all optional) of that interface will be used to add structured information to the formatted traceback. For example, assuming your code renders a template: .. doctest:: >>> import os >>> class Supplement(object): ... def __init__(self, template_file, options): ... self.source_url = 'file://%s' % os.path.abspath(template_file) ... self.options = options ... self.expression = 'an expression' ... def getInfo(self): ... return "Options: " + str(self.options) >>> def render_w_supplement(template_file, options): ... with open(template_file) as f: ... source = f.read() ... __traceback_supplement__ = Supplement, template_file, options ... render(source, options) Here, the filename and options of the template will be rendered as part of the traceback. .. note:: If there is an exception calling the constructor function, no supplement will be formatted, and (by default) the exception will be printed on ``sys.stderr``. API Functions ============= Three API functions support these features when formatting Python exceptions and their associated tracebacks: :py:func:`~zope.exceptions.exceptionformatter.format_exception` --------------------------------------------------------------- Use this API to format an exception and traceback as a list of strings, using the special annotations. E.g.: .. doctest:: >>> from zope.exceptions import format_exception >>> try: ... render_w_info('docs/narr.rst', {}) ... except: ... t, v, tb = sys.exc_info() ... report = format_exception(t, v, tb) ... del tb # avoid a leak ... # Now do something with report, e.g., send e-mail. >>> print('\n'.join(report)) Traceback (most recent call last): Module , line 2, in render_w_info('docs/narr.rst', {}) Module , line 5, in render_w_info - __traceback_info__: docs/narr.rst ... :py:func:`~zope.exceptions.exceptionformatter.print_exception` -------------------------------------------------------------- Use this API to write the formated exception and traceback to a file-like object, using the special annotations. E.g.: .. doctest:: >>> from zope.exceptions import print_exception >>> try: ... render_w_supplement('docs/narr.rst', {}) ... except: ... t, v, tb = sys.exc_info() ... print_exception(t, v, tb, file=sys.stdout) ... del tb # avoid a leak Traceback (most recent call last): File "", line 2, in render_w_supplement('docs/narr.rst', {}) File "", line 5, in render_w_supplement - file:///... - Expression: an expression Options: {} File "", line 2, in render render_w_supplement('docs/narr.rst', {}) Exception: Failed to render :py:func:`~zope.exceptions.exceptionformatter.extract_stack` ------------------------------------------------------------ Use this API to format just the traceback as a list of string,s using the special annotations. E.g.: .. doctest:: >>> import sys >>> from zope.exceptions import extract_stack >>> try: ... raise ValueError('demo') ... except: ... for line in extract_stack(sys.exc_info()[2].tb_frame): ... pass # do something with each line ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/docs/requirements.txt0000644000076600000240000000004315060743636020523 0ustar00m.howitzstaffSphinx repoze.sphinx.autointerface ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/pyproject.toml0000644000076600000240000000121015060743636017220 0ustar00m.howitzstaff# # Generated from: # https://github.com/zopefoundation/meta/tree/master/config/pure-python [build-system] requires = [ "setuptools == 78.1.1", "wheel", ] build-backend = "setuptools.build_meta" [tool.coverage.run] branch = true source = ["zope.exceptions"] [tool.coverage.report] fail_under = 100 precision = 2 ignore_errors = true show_missing = true exclude_lines = [ "pragma: no cover", "pragma: nocover", "except ImportError:", "raise NotImplementedError", "if __name__ == '__main__':", "self.fail", "raise AssertionError", "raise unittest.Skip", ] [tool.coverage.html] directory = "parts/htmlcov" ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1757661087.8019578 zope_exceptions-6.0/setup.cfg0000644000076600000240000000067115060743640016132 0ustar00m.howitzstaff[flake8] doctests = 1 [check-manifest] ignore = .editorconfig .meta.toml docs/_build/html/_sources/* docs/_build/doctest/* [isort] force_single_line = True combine_as_imports = True sections = FUTURE,STDLIB,THIRDPARTY,ZOPE,FIRSTPARTY,LOCALFOLDER known_third_party = docutils, pkg_resources, pytz known_zope = known_first_party = default_section = ZOPE line_length = 79 lines_after_imports = 2 [egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/setup.py0000644000076600000240000000551215060743636016027 0ustar00m.howitzstaff############################################################################## # # Copyright (c) 2006 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## # This package is developed by the Zope Toolkit project, documented here: # https://zopetoolkit.readthedocs.io/ # When developing and releasing this package, please follow the documented # Zope Toolkit policies as described by this documentation. ############################################################################## """Setup for zope.exceptions package """ import os from setuptools import setup def read(*rnames): return open(os.path.join(os.path.dirname(__file__), *rnames)).read() setup( name='zope.exceptions', version='6.0', author='Zope Foundation and Contributors', author_email='zope-dev@zope.dev', description='Zope Exceptions', long_description=(read('README.rst') + '\n\n' + read('CHANGES.rst')), keywords='zope exceptions', classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Web Environment', 'Intended Audience :: Developers', 'License :: OSI Approved :: Zope Public License', 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', 'Programming Language :: Python :: 3.13', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Natural Language :: English', 'Operating System :: OS Independent', 'Topic :: Internet :: WWW/HTTP', 'Framework :: Zope :: 3', ], url='https://github.com/zopefoundation/zope.exceptions', project_urls={ 'Issue Tracker': ('https://github.com/zopefoundation/' 'zope.exceptions/issues'), 'Sources': 'https://github.com/zopefoundation/zope.exceptions', }, license='ZPL-2.1', python_requires='>=3.9', install_requires=[ 'setuptools', 'zope.interface', ], include_package_data=True, zip_safe=False, extras_require={ 'docs': ['Sphinx', 'repoze.sphinx.autointerface'], 'test': ['zope.testrunner >= 6.4'], }, ) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1757661087.7958453 zope_exceptions-6.0/src/0000755000076600000240000000000015060743640015074 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1757661087.7958965 zope_exceptions-6.0/src/zope/0000755000076600000240000000000015060743640016051 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1757661087.8006551 zope_exceptions-6.0/src/zope/exceptions/0000755000076600000240000000000015060743640020232 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/src/zope/exceptions/__init__.py0000644000076600000240000000421515060743636022352 0ustar00m.howitzstaff############################################################################## # # Copyright (c) 2001, 2002 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """General exceptions that wish they were standard exceptions These exceptions are so general purpose that they don't belong in Zope application-specific packages. """ from zope.exceptions.exceptionformatter import extract_stack from zope.exceptions.exceptionformatter import format_exception from zope.exceptions.exceptionformatter import print_exception from zope.exceptions.interfaces import DuplicationError from zope.exceptions.interfaces import IDuplicationError from zope.exceptions.interfaces import IUserError from zope.exceptions.interfaces import UserError __all__ = [ 'DuplicationError', 'IDuplicationError', 'UserError', 'IUserError', 'format_exception', 'print_exception', 'extract_stack', ] # avoid dependency on zope.security: try: import zope.security # noqa: suppress unused import warning from flake8 except ModuleNotFoundError as v: # pragma: no cover # "ModuleNotFoundError: No module named security" if 'security' not in str(v): raise else: # pragma: no cover from zope.security.interfaces import Forbidden from zope.security.interfaces import ForbiddenAttribute from zope.security.interfaces import IForbidden from zope.security.interfaces import IForbiddenAttribute from zope.security.interfaces import IUnauthorized from zope.security.interfaces import Unauthorized __all__ += [ 'IUnauthorized', 'Unauthorized', 'IForbidden', 'IForbiddenAttribute', 'Forbidden', 'ForbiddenAttribute', ] ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/src/zope/exceptions/exceptionformatter.py0000644000076600000240000002601115060743636024533 0ustar00m.howitzstaff############################################################################## # # Copyright (c) 2001, 2002 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """An exception formatter that shows traceback supplements and traceback info, optionally in HTML. """ import linecache import sys import traceback from html import escape DEBUG_EXCEPTION_FORMATTER = 1 class TextExceptionFormatter: line_sep = '\n' def __init__(self, limit=None, with_filenames=False): self.limit = limit self.with_filenames = with_filenames def escape(self, s): return s def getPrefix(self): return 'Traceback (most recent call last):' def getLimit(self): limit = self.limit if limit is None: limit = getattr(sys, 'tracebacklimit', 200) return limit def formatSupplementLine(self, line): return f' - {line}' def formatSourceURL(self, url): return [self.formatSupplementLine(url)] def formatSupplement(self, supplement, tb): result = [] fmtLine = self.formatSupplementLine url = getattr(supplement, 'source_url', None) if url is not None: result.extend(self.formatSourceURL(url)) line = getattr(supplement, 'line', 0) if line == -1: line = tb.tb_lineno col = getattr(supplement, 'column', -1) if line: if col is not None and col >= 0: result.append(fmtLine('Line {}, Column {}'.format( line, col))) else: result.append(fmtLine('Line %s' % line)) elif col is not None and col >= 0: result.append(fmtLine('Column %s' % col)) expr = getattr(supplement, 'expression', None) if expr: result.append(fmtLine('Expression: %s' % expr)) warnings = getattr(supplement, 'warnings', None) if warnings: for warning in warnings: result.append(fmtLine('Warning: %s' % warning)) getInfo = getattr(supplement, 'getInfo', None) if getInfo is not None: try: extra = getInfo() if extra: result.append(self.formatSupplementInfo(extra)) except Exception: # pragma: no cover if DEBUG_EXCEPTION_FORMATTER: traceback.print_exc() # else just swallow the exception. return result def formatSupplementInfo(self, info): return self.escape(info) def formatTracebackInfo(self, tbi): return self.formatSupplementLine(f'__traceback_info__: {tbi}') def formatLine(self, tb=None, f=None): if tb and not f: f = tb.tb_frame lineno = tb.tb_lineno elif not tb and f: lineno = f.f_lineno else: raise ValueError("Pass exactly one of tb or f") co = f.f_code filename = co.co_filename name = co.co_name f_locals = f.f_locals f_globals = f.f_globals if self.with_filenames: s = ' File "%s", line %d' % (filename, lineno) else: modname = f_globals.get('__name__', filename) s = ' Module %s, line %d' % (modname, lineno) s = s + ', in %s' % name result = [] result.append(self.escape(s)) # Append the source line, if available linecache.lazycache(filename, f_globals) line = linecache.getline(filename, lineno) if line: result.append(" " + self.escape(line.strip())) # Output a traceback supplement, if any. if '__traceback_supplement__' in f_locals: # Use the supplement defined in the function. tbs = f_locals['__traceback_supplement__'] elif '__traceback_supplement__' in f_globals: # Use the supplement defined in the module. # This is used by Scripts (Python). tbs = f_globals['__traceback_supplement__'] else: tbs = None if tbs is not None: factory = tbs[0] args = tbs[1:] try: supp = factory(*args) result.extend(self.formatSupplement(supp, tb)) except Exception: # pragma: no cover if DEBUG_EXCEPTION_FORMATTER: traceback.print_exc() # else just swallow the exception. try: tbi = f_locals.get('__traceback_info__', None) if tbi is not None: result.append(self.formatTracebackInfo(tbi)) except Exception: # pragma: no cover if DEBUG_EXCEPTION_FORMATTER: traceback.print_exc() # else just swallow the exception. return self.line_sep.join(result) def formatExceptionOnly(self, etype, value): # We don't want to get an error when we format an error, so we # compensate in our code. For example, on Python 3.11.0 HTTPError # gives an unhelpful KeyError in tempfile when Python formats it. # See https://github.com/python/cpython/issues/90113 try: result = ''.join(traceback.format_exception_only(etype, value)) except Exception: # pragma: no cover # This code branch is only covered on Python 3.11+. result = str(value) return result def formatLastLine(self, exc_line): return self.escape(exc_line) def formatException(self, etype, value, tb): # The next line provides a way to detect recursion. The 'noqa' # comment disables a flake8 warning about the unused variable. __exception_formatter__ = 1 # noqa result = [] while tb is not None: if tb.tb_frame.f_locals.get('__exception_formatter__'): # Stop recursion. result.append('(Recursive formatException() stopped, ' 'trying traceback.format_tb)\n') result.extend(traceback.format_tb(tb)) break line = self.formatLine(tb=tb) result.append(line + '\n') tb = tb.tb_next template = ( '...\n' '{omitted} entries omitted, because limit is {limit}.\n' 'Set sys.tracebacklimit or {klass}.limit to a higher' ' value to see omitted entries\n' '...') self._obeyLimit(result, template) result = [self.getPrefix() + '\n'] + result exc_line = self.formatExceptionOnly(etype, value) result.append(self.formatLastLine(exc_line)) return result def extractStack(self, f=None): if f is None: try: raise ZeroDivisionError except ZeroDivisionError: f = sys.exc_info()[2].tb_frame.f_back # The next line provides a way to detect recursion. The 'noqa' # comment disables a flake8 warning about the unused variable. __exception_formatter__ = 1 # noqa result = [] while f is not None: if f.f_locals.get('__exception_formatter__'): # Stop recursion. result.append('(Recursive extractStack() stopped, ' 'trying traceback.format_stack)\n') res = traceback.format_stack(f) res.reverse() result.extend(res) break line = self.formatLine(f=f) result.append(line + '\n') f = f.f_back self._obeyLimit( result, '...{omitted} entries omitted, because limit is {limit}...\n') result.reverse() return result def _obeyLimit(self, result, template): limit = self.getLimit() if limit is not None and len(result) > limit: # cut out the middle part of the TB tocut = len(result) - limit middle = len(result) // 2 lower = middle - tocut // 2 msg = template.format( omitted=tocut, limit=limit, klass=self.__class__.__name__) result[lower:lower + tocut] = [msg] class HTMLExceptionFormatter(TextExceptionFormatter): line_sep = '
\r\n' def escape(self, s): return escape(str(s), quote=False) def getPrefix(self): return '

Traceback (most recent call last):

\r\n
    ' def formatSupplementLine(self, line): return '%s' % self.escape(line) def formatSupplementInfo(self, info): info = self.escape(info) info = info.replace(" ", " ") info = info.replace("\n", self.line_sep) return info def formatTracebackInfo(self, tbi): s = self.escape(tbi) s = s.replace('\n', self.line_sep) return f'__traceback_info__: {s}' def formatLine(self, tb=None, f=None): line = TextExceptionFormatter.formatLine(self, tb, f) return '
  • %s
  • ' % line def formatLastLine(self, exc_line): line = '

%s

' % self.escape(exc_line) return line.replace('\n', self.line_sep) def format_exception(t, v, tb, limit=None, as_html=False, with_filenames=False): """Format a stack trace and the exception information. Similar to 'traceback.format_exception', but adds supplemental information to the traceback and accepts two options, 'as_html' and 'with_filenames'. The result is a list of strings. """ if as_html: fmt = HTMLExceptionFormatter(limit, with_filenames) else: fmt = TextExceptionFormatter(limit, with_filenames) return fmt.formatException(t, v, tb) def print_exception(t, v, tb, limit=None, file=None, as_html=False, with_filenames=True): """Print exception up to 'limit' stack trace entries from 'tb' to 'file'. Similar to 'traceback.print_exception', but adds supplemental information to the traceback and accepts two options, 'as_html' and 'with_filenames'. """ if file is None: # pragma: no cover file = sys.stderr lines = format_exception(t, v, tb, limit, as_html, with_filenames) for line in lines: file.write(line) def extract_stack(f=None, limit=None, as_html=False, with_filenames=True): """Format a stack trace and the exception information. Similar to 'traceback.extract_stack', but adds supplemental information to the traceback and accepts two options, 'as_html' and 'with_filenames'. """ if as_html: fmt = HTMLExceptionFormatter(limit, with_filenames) else: fmt = TextExceptionFormatter(limit, with_filenames) return fmt.extractStack(f) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/src/zope/exceptions/interfaces.py0000644000076600000240000000655715060743636022751 0ustar00m.howitzstaff############################################################################## # # Copyright (c) 2001, 2002 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """ITracebackSupplement interface definition. When zope.exceptionformatter generates a traceback, it looks for local variables named __traceback_info__ or __traceback_supplement__. It includes the information provided by those local variables in the traceback. __traceback_info__ is for arbitrary information. repr(__traceback_info__) gets dumped to the traceback. __traceback_supplement__ is more structured. It should be a tuple. The first item of the tuple is a callable that produces an object that implements ITracebackSupplement, and the rest of the tuple contains arguments to pass to the factory. The traceback formatter makes an effort to clearly present the information provided by the ITracebackSupplement. """ from zope.interface import Attribute from zope.interface import Interface from zope.interface import implementer class IDuplicationError(Interface): pass @implementer(IDuplicationError) class DuplicationError(Exception): """A duplicate registration was attempted""" class IUserError(Interface): """User error exceptions """ @implementer(IUserError) class UserError(Exception): """User errors These exceptions should generally be displayed to users unless they are handled. """ class ITracebackSupplement(Interface): """Provides valuable information to supplement an exception traceback. The interface is geared toward providing meaningful feedback when exceptions occur in user code written in mini-languages like Zope page templates and restricted Python scripts. """ source_url = Attribute( 'source_url', """Optional. Set to URL of the script where the exception occurred. Normally this generates a URL in the traceback that the user can visit to manage the object. Set to None if unknown or not available. """) line = Attribute( 'line', """Optional. Set to the line number (>=1) where the exception occurred. Set to 0 or None if the line number is unknown. """) column = Attribute( 'column', """Optional. Set to the column offset (>=0) where the exception occurred. Set to None if the column number is unknown. """) expression = Attribute( 'expression', """Optional. Set to the expression that was being evaluated. Set to None if not available or not applicable. """) warnings = Attribute( 'warnings', """Optional. Set to a sequence of warning messages. Set to None if not available, not applicable, or if the exception itself provides enough information. """) def getInfo(): """Optional. Returns a string containing any other useful info. """ ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/src/zope/exceptions/log.py0000644000076600000240000000232415060743636021373 0ustar00m.howitzstaff############################################################################## # # Copyright (c) 2001, 2002 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Log formatter that enhances tracebacks with extra information. """ import io import logging from zope.exceptions.exceptionformatter import print_exception class Formatter(logging.Formatter): def formatException(self, ei): """Format and return the specified exception information as a string. Uses zope.exceptions.exceptionformatter to generate the traceback. """ sio = io.StringIO() print_exception(ei[0], ei[1], ei[2], file=sio, with_filenames=True) s = sio.getvalue() s = s[:-1] if s.endswith("\n") else s return s ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1757661087.8011293 zope_exceptions-6.0/src/zope/exceptions/tests/0000755000076600000240000000000015060743640021374 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/src/zope/exceptions/tests/__init__.py0000644000076600000240000000000215060743636023502 0ustar00m.howitzstaff# ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/src/zope/exceptions/tests/test_exceptionformatter.py0000644000076600000240000010770315060743636026744 0ustar00m.howitzstaff############################################################################## # # Copyright (c) 2001, 2002 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """ExceptionFormatter tests. """ import importlib import pathlib import sys import tempfile import textwrap import unittest import zipfile from urllib.error import HTTPError IS_PY312_OR_OLDER = sys.version_info < (3, 13) class TextExceptionFormatterTests(unittest.TestCase): def _getTargetClass(self): from zope.exceptions.exceptionformatter import TextExceptionFormatter return TextExceptionFormatter def _makeOne(self, *args, **kw): return self._getTargetClass()(*args, **kw) def test_ctor_defaults(self): fmt = self._makeOne() self.assertEqual(fmt.line_sep, '\n') self.assertEqual(fmt.limit, None) self.assertEqual(fmt.with_filenames, False) def test_ctor_explicit(self): fmt = self._makeOne(limit=20, with_filenames=True) self.assertEqual(fmt.line_sep, '\n') self.assertEqual(fmt.limit, 20) self.assertEqual(fmt.with_filenames, True) def test_escape(self): fmt = self._makeOne() self.assertEqual(fmt.escape('XXX'), 'XXX') def test_getPrefix(self): fmt = self._makeOne() self.assertEqual(fmt.getPrefix(), 'Traceback (most recent call last):') def test_getLimit_default(self): fmt = self._makeOne() self.assertEqual(fmt.getLimit(), 200) def test_getLimit_sys_has_limit(self): fmt = self._makeOne() with _Monkey(sys, tracebacklimit=15): self.assertEqual(fmt.getLimit(), 15) def test_getLimit_explicit(self): fmt = self._makeOne(limit=10) self.assertEqual(fmt.getLimit(), 10) def test_formatSupplementLine(self): fmt = self._makeOne() self.assertEqual(fmt.formatSupplementLine('XXX'), ' - XXX') def test_formatSourceURL(self): fmt = self._makeOne() self.assertEqual(fmt.formatSourceURL('http://example.com/'), [' - http://example.com/']) def test_formatSupplement_no_info(self): fmt = self._makeOne() supplement = DummySupplement() self.assertEqual(fmt.formatSupplement(supplement, tb=None), []) def test_formatSupplement_w_source_url(self): fmt = self._makeOne() supplement = DummySupplement() supplement.source_url = 'http://example.com/' self.assertEqual(fmt.formatSupplement(supplement, tb=None), [' - http://example.com/']) def test_formatSupplement_w_line_as_marker(self): fmt = self._makeOne() supplement = DummySupplement() supplement.line = -1 tb = DummyTB() self.assertEqual(fmt.formatSupplement(supplement, tb=tb), [' - Line 14']) def test_formatSupplement_w_line_no_column(self): fmt = self._makeOne() supplement = DummySupplement() supplement.line = 23 self.assertEqual(fmt.formatSupplement(supplement, tb=None), [' - Line 23']) def test_formatSupplement_w_column_no_line(self): fmt = self._makeOne() supplement = DummySupplement() supplement.column = 47 self.assertEqual(fmt.formatSupplement(supplement, tb=None), [' - Column 47']) def test_formatSupplement_w_line_and_column(self): fmt = self._makeOne() supplement = DummySupplement() supplement.line = 23 supplement.column = 47 self.assertEqual(fmt.formatSupplement(supplement, tb=None), [' - Line 23, Column 47']) def test_formatSupplement_w_expression(self): fmt = self._makeOne() supplement = DummySupplement() supplement.expression = 'a*x^2 + b*x + c' self.assertEqual(fmt.formatSupplement(supplement, tb=None), [' - Expression: a*x^2 + b*x + c']) def test_formatSupplement_w_warnings(self): fmt = self._makeOne() supplement = DummySupplement() supplement.warnings = [ 'Beware the ides of March!', 'You\'re gonna get wasted.', ] self.assertEqual( fmt.formatSupplement(supplement, tb=None), [ ' - Warning: Beware the ides of March!', ' - Warning: You\'re gonna get wasted.', ]) def test_formatSupplement_w_getInfo_empty(self): fmt = self._makeOne() supplement = DummySupplement() self.assertEqual(fmt.formatSupplement(supplement, tb=None), []) def test_formatSupplement_w_getInfo_text(self): INFO = 'Some days\nI wish I had stayed in bed.' fmt = self._makeOne() supplement = DummySupplement(INFO) self.assertEqual(fmt.formatSupplement(supplement, tb=None), [INFO]) def test_formatSupplementInfo(self): INFO = 'Some days\nI wish I had stayed in bed.' fmt = self._makeOne() self.assertEqual(fmt.formatSupplementInfo(INFO), INFO) def test_formatTracebackInfo(self): fmt = self._makeOne() self.assertEqual(fmt.formatTracebackInfo('XYZZY'), ' - __traceback_info__: XYZZY') def test_formatTracebackInfo_unicode(self): __traceback_info__ = "Have a Snowman: \u2603" fmt = self._makeOne() result = fmt.formatTracebackInfo(__traceback_info__) expected = ' - __traceback_info__: Have a Snowman: \u2603' self.assertIsInstance(result, str) self.assertEqual(result, expected) def test_formatLine_no_tb_no_f(self): fmt = self._makeOne() self.assertRaises(ValueError, fmt.formatLine, None, None) def test_formatLine_w_tb_and_f(self): fmt = self._makeOne() tb = DummyTB() f = DummyFrame() self.assertRaises(ValueError, fmt.formatLine, tb, f) def test_formatLine_w_tb_bogus_linecache_w_filenames(self): fmt = self._makeOne(with_filenames=True) tb = DummyTB() tb.tb_frame = f = DummyFrame() lines = fmt.formatLine(tb).splitlines() self.assertEqual(len(lines), 1) self.assertEqual( lines[0], ' File "%s", line %d, in %s' % (f.f_code.co_filename, tb.tb_lineno, f.f_code.co_name,) ) def test_formatLine_w_f_bogus_linecache_w_filenames(self): fmt = self._makeOne(with_filenames=True) f = DummyFrame() lines = fmt.formatLine(f=f).splitlines() self.assertEqual(len(lines), 1) self.assertEqual( lines[0], ' File "%s", line %d, in %s' % (f.f_code.co_filename, f.f_lineno, f.f_code.co_name,) ) def test_formatLine_w_tb_bogus_linecache_wo_filenames(self): fmt = self._makeOne(with_filenames=False) tb = DummyTB() tb.tb_frame = f = DummyFrame() f.f_globals['__name__'] = 'dummy.filename' lines = fmt.formatLine(tb).splitlines() self.assertEqual(len(lines), 1) self.assertEqual( lines[0], ' Module dummy.filename, line %d, in %s' % (tb.tb_lineno, f.f_code.co_name,) ) def test_formatLine_w_f_real_linecache_w_filenames(self): fmt = self._makeOne(with_filenames=True) f = sys._getframe() lineno = f.f_lineno result = fmt.formatLine(f=f) lines = result.splitlines() self.assertEqual(len(lines), 2) self.assertEqual( lines[0], ' File "%s", line %d, in %s' % (f.f_code.co_filename, lineno + 1, f.f_code.co_name,) ) self.assertEqual(lines[1], ' result = fmt.formatLine(f=f)') def test_formatLine_w_supplement_in_locals(self): INFO_L = 'I wish I had stayed in bed.' INFO_G = 'I would rather soak my head.' fmt = self._makeOne(with_filenames=False) tb = DummyTB() tb.tb_frame = f = DummyFrame() f.f_globals['__name__'] = 'dummy.filename' f.f_locals['__traceback_supplement__'] = (DummySupplement, INFO_L) f.f_globals['__traceback_supplement__'] = (DummySupplement, INFO_G) lines = fmt.formatLine(tb).splitlines() self.assertEqual(len(lines), 2) self.assertEqual(lines[1], INFO_L) def test_formatLine_w_supplement_in_globals(self): INFO_G = 'I would rather soak my head.' fmt = self._makeOne(with_filenames=False) tb = DummyTB() tb.tb_frame = f = DummyFrame() f.f_globals['__name__'] = 'dummy.filename' f.f_globals['__traceback_supplement__'] = (DummySupplement, INFO_G) lines = fmt.formatLine(tb).splitlines() self.assertEqual(len(lines), 2) self.assertEqual(lines[1], INFO_G) def test_formatLine_w_traceback_info(self): INFO_T = 'I would rather soak my head.' fmt = self._makeOne(with_filenames=False) tb = DummyTB() tb.tb_frame = f = DummyFrame() f.f_globals['__name__'] = 'dummy.filename' f.f_locals['__traceback_info__'] = INFO_T lines = fmt.formatLine(tb).splitlines() self.assertEqual(len(lines), 2) self.assertEqual(lines[1], ' - __traceback_info__: %s' % INFO_T) def test_formatExceptionOnly(self): import traceback fmt = self._makeOne() err = ValueError('testing') self.assertEqual(fmt.formatExceptionOnly(ValueError, err), ''.join( traceback.format_exception_only(ValueError, err))) def test_formatExceptionOnly_httperror(self): # On Python 3.11.0 HTTPError may behave wrongly, giving a KeyError in # tempfile when Python tries to format it. # See https://github.com/python/cpython/issues/90113 # or examples in Plone tests, especially doctests: # https://github.com/plone/Products.CMFPlone/issues/3663 # We don't want to get an error when we format an error, # so let's compensate in our code. fmt = self._makeOne() err = HTTPError('url', 400, 'oops', [], None) result = fmt.formatExceptionOnly(HTTPError, err).strip() # The output can differ too much per Python version, # but it is just one line when stripped. self.assertIn("400", result) self.assertIn("oops", result) self.assertIn("Error", result) self.assertEqual(len(result.splitlines()), 1) def test_formatException_httperror(self): # See test_formatExceptionOnly_httperror. # Here we check that formatException works. fmt = self._makeOne() err = HTTPError('url', 400, 'oops', [], None) result = fmt.formatException(HTTPError, err, None) self.assertEqual(result[0], 'Traceback (most recent call last):\n') last = result[-1] # The output can differ per Python version. self.assertIn("400", last) self.assertIn("oops", last) self.assertIn("Error", last) def test_formatLastLine(self): fmt = self._makeOne() self.assertEqual(fmt.formatLastLine('XXX'), 'XXX') def test_formatException_empty_tb_stack(self): import traceback fmt = self._makeOne() err = ValueError('testing') lines = fmt.formatException(ValueError, err, None) self.assertEqual(len(lines), 2) self.assertEqual(lines[0], 'Traceback (most recent call last):\n') self.assertEqual(lines[1], ''.join( traceback.format_exception_only(ValueError, err))) def test_formatException_non_empty_tb_stack(self): import traceback fmt = self._makeOne() err = ValueError('testing') tb = DummyTB() tb.tb_frame = DummyFrame() lines = fmt.formatException(ValueError, err, tb) self.assertEqual(len(lines), 3) self.assertEqual(lines[0], 'Traceback (most recent call last):\n') self.assertEqual(lines[1], ' Module dummy/filename.py, line 14, ' 'in dummy_function\n') self.assertEqual(lines[2], ''.join( traceback.format_exception_only(ValueError, err))) def test_formatException_deep_tb_stack_with_limit(self): import traceback fmt = self._makeOne(limit=4) err = ValueError('testing') tb = self._makeTBs(10) lines = fmt.formatException(ValueError, err, tb) self.assertEqual(len(lines), 7) expected = [ 'Traceback (most recent call last):\n', ' Module dummy/filename.py, line 4345, in dummy_function\n', ' Module dummy/filename.py, line 2287, in dummy_function\n', ('...\n' '6 entries omitted, because limit is 4.\n' 'Set sys.tracebacklimit or TextExceptionFormatter.limit to' ' a higher value to see omitted entries\n' '...'), ' Module dummy/filename.py, line 26, in dummy_function\n', ' Module dummy/filename.py, line 14, in dummy_function\n', ''.join(traceback.format_exception_only(ValueError, err)) ] self.assertEqual(lines, expected) def test_formatException_recursion_in_tb_stack(self): import traceback fmt = self._makeOne() err = ValueError('testing') tb_recurse = DummyTB() tb_recurse.tb_lineno = 27 r_f = tb_recurse.tb_frame = DummyFrame() r_f.f_lineno = 27 r_f.f_locals['__exception_formatter__'] = 1 tb = DummyTB() tb.tb_frame = DummyFrame() tb.tb_next = tb_recurse lines = fmt.formatException(ValueError, err, tb) self.assertEqual(len(lines), 5) self.assertEqual(lines[0], 'Traceback (most recent call last):\n') self.assertEqual(lines[1], ' Module dummy/filename.py, line 14, ' 'in dummy_function\n') self.assertEqual(lines[2], '(Recursive formatException() stopped, ' 'trying traceback.format_tb)\n') self.assertEqual(lines[3], ' File "dummy/filename.py", line 27, ' 'in dummy_function\n') self.assertEqual(lines[4], ''.join( traceback.format_exception_only(ValueError, err))) def test_extractStack_wo_frame(self): fmt = self._makeOne() f = sys._getframe() lineno = f.f_lineno lines = fmt.extractStack() # rather don't assert this here # self.assertEqual(len(lines), 10) self.assertEqual(lines[-1], ' Module ' 'zope.exceptions.tests.test_exceptionformatter, ' 'line %d, in test_extractStack_wo_frame\n' ' lines = fmt.extractStack()\n' % (lineno + 1)) def test_extractStack_wo_frame_w_limit(self): fmt = self._makeOne(limit=2) f = sys._getframe() lineno = f.f_lineno lines = fmt.extractStack() self.assertEqual(len(lines), 3) self.assertEqual(lines[-1], ' Module ' 'zope.exceptions.tests.test_exceptionformatter, ' 'line %d, in test_extractStack_wo_frame_w_limit\n' ' lines = fmt.extractStack()\n' % (lineno + 1)) def test_extractStack_w_single_frame(self): fmt = self._makeOne() f = DummyFrame() lines = fmt.extractStack(f) self.assertEqual(len(lines), 1) self.assertEqual(lines[0], ' Module dummy/filename.py, line 137, ' 'in dummy_function\n') def test_extractStack_w_multiple_frames_and_limit(self): fmt = self._makeOne(limit=2) f = self._makeFrames(10) lines = fmt.extractStack(f) self.assertEqual(len(lines), 3) expected = [ ' Module dummy/filename.py, line 17, in dummy_function\n', '...8 entries omitted, because limit is 2...\n', ' Module dummy/filename.py, line 1126, in dummy_function\n', ] self.assertEqual(expected, lines) def test_extractStack_w_recursive_frames(self): fmt = self._makeOne() f = self._makeFrames(3) f.f_back.f_locals['__exception_formatter__'] = 1 lines = fmt.extractStack(f) self.assertEqual(len(lines), 4) expected = [ ' File "dummy/filename.py", line 17, in dummy_function\n', ' File "dummy/filename.py", line 27, in dummy_function\n', ('(Recursive extractStack() stopped,' ' trying traceback.format_stack)\n'), ' Module dummy/filename.py, line 43, in dummy_function\n', ] self.assertEqual(expected, lines) def test_extractStack_w_recursive_frames_and_limit(self): fmt = self._makeOne(limit=2) f = self._makeFrames(3) f.f_back.f_locals['__exception_formatter__'] = 1 lines = fmt.extractStack(f) self.assertEqual(len(lines), 3) expected = [ ' File "dummy/filename.py", line 17, in dummy_function\n', '...2 entries omitted, because limit is 2...\n', ' Module dummy/filename.py, line 43, in dummy_function\n', ] self.assertEqual(expected, lines) def _makeTBs(self, count): prev = None for _i in range(count): tb = DummyTB() tb.tb_lineno = 14 tb.tb_frame = DummyFrame() if prev is not None: tb.tb_lineno = int(prev.tb_lineno * 1.9) tb.tb_next = prev prev = tb return tb def _makeFrames(self, count): prev = None for _i in range(count): f = DummyFrame() f.f_lineno = 17 if prev is not None: f.f_lineno = int(prev.f_lineno * 1.6) f.f_back = prev prev = f return f class HTMLExceptionFormatterTests(unittest.TestCase): def _getTargetClass(self): from zope.exceptions.exceptionformatter import HTMLExceptionFormatter return HTMLExceptionFormatter def _makeOne(self, *args, **kw): return self._getTargetClass()(*args, **kw) def test_ctor_defaults(self): fmt = self._makeOne() self.assertEqual(fmt.line_sep, '
\r\n') self.assertEqual(fmt.limit, None) self.assertEqual(fmt.with_filenames, False) def test_ctor_explicit(self): fmt = self._makeOne(limit=20, with_filenames=True) self.assertEqual(fmt.line_sep, '
\r\n') self.assertEqual(fmt.limit, 20) self.assertEqual(fmt.with_filenames, True) def test_escape_simple(self): fmt = self._makeOne() self.assertEqual(fmt.escape('XXX'), 'XXX') def test_escape_non_str(self): fmt = self._makeOne() self.assertEqual(fmt.escape(123), '123') def test_escape_w_markup(self): fmt = self._makeOne() self.assertEqual(fmt.escape('XXX & YYY'), '<span>XXX & YYY<span>') def test_getPrefix(self): fmt = self._makeOne() self.assertEqual(fmt.getPrefix(), '

Traceback (most recent call last):

\r\n
    ') def test_formatSupplementLine(self): fmt = self._makeOne() self.assertEqual(fmt.formatSupplementLine('XXX'), 'XXX') def test_formatSupplementLine_w_markup(self): fmt = self._makeOne() self.assertEqual(fmt.formatSupplementLine('XXX & YYY'), 'XXX & YYY') def test_formatSupplementInfo_simple(self): INFO = 'Some days\nI wonder.' fmt = self._makeOne() self.assertEqual(fmt.formatSupplementInfo(INFO), 'Some days
    \r\nI wonder.') def test_formatSupplementInfo_w_markup(self): INFO = 'Some days\nI wonder, Why?.' fmt = self._makeOne() self.assertEqual(fmt.formatSupplementInfo(INFO), 'Some days
    \r\nI wonder, ' '<b>Why?</b>.') def test_formatTracebackInfo(self): fmt = self._makeOne() self.assertEqual(fmt.formatTracebackInfo('XXX & YYY\nZZZ'), '__traceback_info__: XXX & YYY
    \r\nZZZ') def test_formatLine_simple(self): fmt = self._makeOne(with_filenames=True) tb = DummyTB() tb.tb_frame = f = DummyFrame() result = fmt.formatLine(tb) self.assertEqual( result, '
  • File "%s", line %d, in %s
  • ' % (f.f_code.co_filename, tb.tb_lineno, f.f_code.co_name,) ) def test_formatLastLine(self): fmt = self._makeOne() self.assertEqual(fmt.formatLastLine('XXX'), '

XXX

') class Test_format_exception(unittest.TestCase): def _callFUT(self, as_html=False): from zope.exceptions.exceptionformatter import format_exception t, v, b = sys.exc_info() try: return ''.join(format_exception(t, v, b, as_html=as_html)) finally: del b def test_basic_names_text(self): try: raise ExceptionForTesting except ExceptionForTesting: s = self._callFUT(False) # The traceback should include the name of this function. self.assertGreaterEqual(s.find('test_basic_names_text'), 0) # The traceback should include the name of the exception. self.assertGreaterEqual(s.find('ExceptionForTesting'), 0) def test_basic_names_html(self): try: raise ExceptionForTesting except ExceptionForTesting: s = self._callFUT(True) # The traceback should include the name of this function. self.assertGreaterEqual(s.find('test_basic_names_html'), 0) # The traceback should include the name of the exception. self.assertGreaterEqual(s.find('ExceptionForTesting'), 0) def test_traceback_info_text(self): try: __traceback_info__ = "Adam & Eve" raise ExceptionForTesting except ExceptionForTesting: s = self._callFUT(False) self.assertGreaterEqual(s.find('Adam & Eve'), 0, s) def test_traceback_info_html(self): try: __traceback_info__ = "Adam & Eve" raise ExceptionForTesting except ExceptionForTesting: s = self._callFUT(True) # Be sure quoting is happening. self.assertGreaterEqual(s.find('Adam & Eve'), 0, s) def test_traceback_info_is_tuple(self): try: __traceback_info__ = ("Adam", "Eve") raise ExceptionForTesting except ExceptionForTesting: s = self._callFUT(False) self.assertGreaterEqual(s.find('Adam'), 0, s) self.assertGreaterEqual(s.find('Eve'), 0, s) def test_supplement_text(self, as_html=0): try: __traceback_supplement__ = (TestingTracebackSupplement, "You're one in a million") raise ExceptionForTesting except ExceptionForTesting: s = self._callFUT(as_html) # The source URL self.assertGreaterEqual(s.find('/somepath'), 0, s) # The line number self.assertGreaterEqual(s.find('634'), 0, s) # The column number self.assertGreaterEqual(s.find('57'), 0, s) # The expression self.assertGreaterEqual(s.find("You're one in a million"), 0, s) # The warning self.assertGreaterEqual(s.find("Repent, for the end is nigh"), 0, s) def test_supplement_html(self): try: __traceback_supplement__ = (TestingTracebackSupplement, "You're one in a million") raise ExceptionForTesting except ExceptionForTesting: s = self._callFUT(True) # The source URL self.assertGreaterEqual(s.find('/somepath'), 0, s) # The line number self.assertGreaterEqual(s.find('634'), 0, s) # The column number self.assertGreaterEqual(s.find('57'), 0, s) # The expression self.assertGreaterEqual(s.find("You're one in a million"), 0, s) # The warning self.assertGreaterEqual(s.find("Repent, for the end is nigh"), 0, s) def test_multiple_levels(self): # Ensure many levels are shown in a traceback. HOW_MANY = 10 def f(n): """Produces a (n + 1)-level traceback.""" __traceback_info__ = 'level%d' % n if n > 0: f(n - 1) else: raise ExceptionForTesting try: f(HOW_MANY) except ExceptionForTesting: s = self._callFUT(False) for n in range(HOW_MANY + 1): self.assertGreaterEqual(s.find('level%d' % n), 0, s) def test_quote_last_line(self): class C: pass try: raise TypeError(C()) except TypeError: s = self._callFUT(True) self.assertIn('<', s) self.assertIn('>', s) def test_multiline_exception(self): try: exec('syntax error\n') except SyntaxError: s = self._callFUT(False) lines = s.splitlines()[-3:] self.assertEqual(lines[0], ' syntax error') self.assertIn(' ^', lines[1]) self.assertTrue(lines[2].startswith('SyntaxError: invalid syntax'), lines[2]) def test_traceback_info_non_ascii(self): __traceback_info__ = "Have a Snowman: \u2603" try: raise TypeError() except TypeError: s = self._callFUT(True) self.assertIsInstance(s, str) self.assertIn('Have a Snowman', s) def test_recursion_failure(self): from zope.exceptions.exceptionformatter import TextExceptionFormatter class FormatterException(Exception): pass class FailingFormatter(TextExceptionFormatter): def formatLine(self, tb=None, f=None): raise FormatterException("Formatter failed") fmt = FailingFormatter() try: raise ExceptionForTesting except ExceptionForTesting: try: fmt.formatException(*sys.exc_info()) except FormatterException: s = self._callFUT(False) # Recursion was detected self.assertIn( '(Recursive formatException() stopped, ' 'trying traceback.format_tb)', s, s ) # and we fellback to the stdlib rather than hid the real error self.assertEqual(s.splitlines()[-2], ' raise FormatterException("Formatter failed")') self.assertIn( 'FormatterException: Formatter failed', s.splitlines()[-1] ) def test_format_exception_as_html(self): # Test for format_exception (as_html=True) import re from zope.exceptions.exceptionformatter import format_exception try: exec('import') except SyntaxError: result = ''.join(format_exception(*sys.exc_info(), as_html=True)) expected = textwrap.dedent("""\

Traceback (most recent call last):

  • Module {module}, line ABC, in {fn}
    exec('import')

File "<string>", line 1
import
^
SyntaxError: Expected one or more names after 'import'

""").format( module='zope.exceptions.tests.test_exceptionformatter', fn='test_format_exception_as_html', ) if IS_PY312_OR_OLDER: # pragma: no cover # Python <= 3.12 had a different error message: expected = expected.replace( "Expected one or more names after 'import'", "invalid syntax") # HTML formatter uses Windows line endings for some reason. result = result.replace('\r\n', '\n') result = re.sub(r'line \d\d\d,', 'line ABC,', result) self.maxDiff = None self.assertEqual(expected, result) def test_pep302_loader_source_in_traceback(self): sys_path = sys.path[::] def restore_sys_path(): sys.path[::] = sys_path self.addCleanup(restore_sys_path) module_name = self._testMethodName with tempfile.TemporaryDirectory() as td: td = pathlib.Path(td) module_zipfile = td / f"{module_name}.zip" with zipfile.ZipFile(module_zipfile, "w") as zf: zf.writestr( zipfile.ZipInfo(f"{module_name}/__init__.py"), textwrap.dedent(""" def f(): 1 / 0 """)) sys.path.insert(0, str(module_zipfile)) try: importlib.import_module(module_name).f() except ZeroDivisionError: s = self._callFUT(False) self.assertIn('1 / 0', s) class Test_print_exception(unittest.TestCase): def _callFUT(self, as_html=False): import io buf = io.StringIO() if bytes is not str else io.BytesIO() from zope.exceptions.exceptionformatter import print_exception t, v, b = sys.exc_info() try: print_exception(t, v, b, file=buf, as_html=as_html) return buf.getvalue() finally: del b def test_basic_names_text(self): try: raise ExceptionForTesting except ExceptionForTesting: s = self._callFUT(False) # The traceback should include the name of this function. self.assertGreaterEqual(s.find('test_basic_names_text'), 0) # The traceback should include the name of the exception. self.assertGreaterEqual(s.find('ExceptionForTesting'), 0) def test_basic_names_html(self): try: raise ExceptionForTesting except ExceptionForTesting: s = self._callFUT(True) # The traceback should include the name of this function. self.assertGreaterEqual(s.find('test_basic_names_html'), 0) # The traceback should include the name of the exception. self.assertGreaterEqual(s.find('ExceptionForTesting'), 0) class Test_extract_stack(unittest.TestCase): def _callFUT(self, as_html=False): from zope.exceptions.exceptionformatter import extract_stack f = sys.exc_info()[2].tb_frame try: return ''.join(extract_stack(f, as_html=as_html)) finally: del f def test_basic_names_as_text(self, as_html=0): try: raise ExceptionForTesting except ExceptionForTesting: s = self._callFUT(False) # The stack trace should include the name of this function. self.assertGreaterEqual(s.find('test_basic_names_as_text'), 0) def test_basic_names_as_html(self): try: raise ExceptionForTesting except ExceptionForTesting: s = self._callFUT(True) # The stack trace should include the name of this function. self.assertGreaterEqual(s.find('test_basic_names_as_html'), 0) def test_traceback_info_text(self): try: __traceback_info__ = "Adam & Eve" raise ExceptionForTesting except ExceptionForTesting: s = self._callFUT(False) self.assertGreaterEqual(s.find('Adam & Eve'), 0, s) def test_traceback_info_html(self): try: __traceback_info__ = "Adam & Eve" raise ExceptionForTesting except ExceptionForTesting: s = self._callFUT(True) self.assertGreaterEqual(s.find('Adam & Eve'), 0, s) def test_traceback_supplement_text(self): try: __traceback_supplement__ = (TestingTracebackSupplement, "You're one in a million") raise ExceptionForTesting except ExceptionForTesting: s = self._callFUT(False) # The source URL self.assertGreaterEqual(s.find('/somepath'), 0, s) # The line number self.assertGreaterEqual(s.find('634'), 0, s) # The column number self.assertGreaterEqual(s.find('57'), 0, s) # The expression self.assertGreaterEqual(s.find("You're one in a million"), 0, s) # The warning self.assertGreaterEqual(s.find("Repent, for the end is nigh"), 0, s) def test_traceback_supplement_html(self): try: __traceback_supplement__ = (TestingTracebackSupplement, "You're one in a million") raise ExceptionForTesting except ExceptionForTesting: s = self._callFUT(True) # The source URL self.assertGreaterEqual(s.find('/somepath'), 0, s) # The line number self.assertGreaterEqual(s.find('634'), 0, s) # The column number self.assertGreaterEqual(s.find('57'), 0, s) # The expression self.assertGreaterEqual(s.find("You're one in a million"), 0, s) # The warning self.assertGreaterEqual(s.find("Repent, for the end is nigh"), 0, s) def test_noinput(self): try: raise ExceptionForTesting except ExceptionForTesting: from zope.exceptions.exceptionformatter import extract_stack s = ''.join(extract_stack()) self.assertGreaterEqual(s.find('test_noinput'), 0) class ExceptionForTesting(Exception): pass class TestingTracebackSupplement: source_url = '/somepath' line = 634 column = 57 warnings = ['Repent, for the end is nigh'] def __init__(self, expression): self.expression = expression class DummySupplement: def __init__(self, info=''): self._info = info def getInfo(self): return self._info class DummyTB: # https://docs.python.org/3/reference/datamodel.html#traceback-objects tb_frame = None tb_lineno = 14 tb_next = None tb_lasti = 1 class DummyFrame: f_lineno = 137 f_back = None def __init__(self): self.f_locals = {} self.f_globals = {} self.f_code = DummyCode() class DummyCode: co_filename = 'dummy/filename.py' co_name = 'dummy_function' def co_positions(self): # New in Python 3.11. # https://docs.python.org/3/reference/datamodel.html#codeobject.co_positions # Note that this is not called for DummyTB if you have tb_lasti=-1. # The 27 in the return value is chosen to match tb_recurse.tb_lineno=27 # in test_formatException_recursion_in_tb_stack in this file. # The rest is random. # Note that this code is only called on Python 3.11+, so we mark it for # the coverage tool. return [(27, 2, 3, 4)] # pragma: no cover class _Monkey: # context-manager for replacing module names in the scope of a test. def __init__(self, module, **kw): self.module = module self.to_restore = {key: getattr(module, key, self) for key in kw} for key, value in kw.items(): setattr(module, key, value) def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): for key, value in self.to_restore.items(): if value is not self: # pragma: no cover setattr(self.module, key, value) else: delattr(self.module, key) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/src/zope/exceptions/tests/test_log.py0000644000076600000240000000545215060743636023601 0ustar00m.howitzstaff############################################################################## # # Copyright (c) 2012 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """log.Formatter tests. """ import unittest class FormatterTests(unittest.TestCase): def _getTargetClass(self): from zope.exceptions.log import Formatter return Formatter def _makeOne(self, *args, **kw): return self._getTargetClass()(*args, **kw) def test_simple_exception(self): import traceback tb = DummyTB() exc = ValueError('testing') fmt = self._makeOne() result = fmt.formatException((ValueError, exc, tb)) lines = result.splitlines() self.assertEqual(len(lines), 3) self.assertEqual(lines[0], 'Traceback (most recent call last):') self.assertEqual(lines[1], ' File "dummy/filename.py", line 14, ' 'in dummy_function') emsg = traceback.format_exception_only(ValueError, exc)[0] self.assertEqual(lines[2], emsg[:-1]) # strip trailing \n from emsg def test_unicode_traceback_info(self): import traceback __traceback_info__ = "Have a Snowman: \u2603" tb = DummyTB() tb.tb_frame.f_locals['__traceback_info__'] = __traceback_info__ exc = ValueError('testing') fmt = self._makeOne() result = fmt.formatException((ValueError, exc, tb)) self.assertIsInstance(result, str) lines = result.splitlines() self.assertEqual(len(lines), 4) self.assertEqual(lines[0], 'Traceback (most recent call last):') self.assertEqual(lines[1], ' File "dummy/filename.py", line 14, ' 'in dummy_function') expected = ' - __traceback_info__: Have a Snowman: \u2603' self.assertEqual(lines[2], expected) emsg = traceback.format_exception_only(ValueError, exc)[0] self.assertEqual(lines[3], emsg[:-1]) # strip trailing \n from emsg class DummyTB: tb_lineno = 14 tb_next = None def __init__(self): self.tb_frame = DummyFrame() class DummyFrame: f_lineno = 137 f_back = None def __init__(self): self.f_locals = {} self.f_globals = {} self.f_code = DummyCode() class DummyCode: co_filename = 'dummy/filename.py' co_name = 'dummy_function' ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1757661087.8012984 zope_exceptions-6.0/src/zope.exceptions.egg-info/0000755000076600000240000000000015060743640021723 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661087.0 zope_exceptions-6.0/src/zope.exceptions.egg-info/PKG-INFO0000644000076600000240000002152015060743637023026 0ustar00m.howitzstaffMetadata-Version: 2.4 Name: zope.exceptions Version: 6.0 Summary: Zope Exceptions Home-page: https://github.com/zopefoundation/zope.exceptions Author: Zope Foundation and Contributors Author-email: zope-dev@zope.dev License: ZPL-2.1 Project-URL: Issue Tracker, https://github.com/zopefoundation/zope.exceptions/issues Project-URL: Sources, https://github.com/zopefoundation/zope.exceptions Keywords: zope exceptions Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Zope Public License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 Classifier: Programming Language :: Python :: 3.13 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Topic :: Internet :: WWW/HTTP Classifier: Framework :: Zope :: 3 Requires-Python: >=3.9 License-File: LICENSE.txt Requires-Dist: setuptools Requires-Dist: zope.interface Provides-Extra: docs Requires-Dist: Sphinx; extra == "docs" Requires-Dist: repoze.sphinx.autointerface; extra == "docs" Provides-Extra: test Requires-Dist: zope.testrunner>=6.4; extra == "test" Dynamic: author Dynamic: author-email Dynamic: classifier Dynamic: description Dynamic: home-page Dynamic: keywords Dynamic: license Dynamic: license-file Dynamic: project-url Dynamic: provides-extra Dynamic: requires-dist Dynamic: requires-python Dynamic: summary ================= zope.exceptions ================= .. image:: https://img.shields.io/pypi/v/zope.exceptions.svg :target: https://pypi.python.org/pypi/zope.exceptions/ :alt: Latest release .. image:: https://img.shields.io/pypi/pyversions/zope.exceptions.svg :target: https://pypi.org/project/zope.exceptions/ :alt: Supported Python versions .. image:: https://github.com/zopefoundation/zope.exceptions/actions/workflows/tests.yml/badge.svg :target: https://github.com/zopefoundation/zope.exceptions/actions/workflows/tests.yml .. image:: https://coveralls.io/repos/github/zopefoundation/zope.exceptions/badge.svg?branch=master :target: https://coveralls.io/github/zopefoundation/zope.exceptions?branch=master .. image:: https://readthedocs.org/projects/zopeexceptions/badge/?version=latest :target: https://zopeexceptions.readthedocs.io/en/latest/ :alt: Documentation Status This package contains exception exceptions and implementations which are so general purpose that they don't belong in Zope application-specific packages. Please see https://zopeexceptions.readthedocs.io/ for the documentation. =========================== zope.exceptions Changelog =========================== 6.0 (2025-09-12) ================ - Replace ``pkg_resources`` namespace with PEP 420 native namespace. - Drop support for Python 3.8. 5.2 (2024-10-30) ================ - Drop support for Python 3.7. - Add support for Python 3.13. 5.1 (2024-06-07) ================ - Add support for Python 3.12. - Include code from PEP302 loaders in tracebacks. 5.0.1 (2023-07-11) ================== - Fix issue introduced in the last release which is breaking ``HTMLExceptionFormatter`` when using non-str ``__traceback_info__``. 5.0 (2023-06-29) ================ - Drop support for Python 2.7, 3.5, 3.6. 4.6 (2022-11-10) ================ - Catch exceptions in ``formatExceptionOnly``. Getting an exception when reporting about a different exception is not helpful. On Python 3.11 this is needed for some HTTPErrors. - Add official support for Python 3.11. 4.5 (2022-02-11) ================ - Add official support for Python 3.9 and 3.10. - Undo dropping support for Python 3.5. - Drop support for running the tests using ``python setup.py test``. 4.4 (2020-07-16) ================ - Add support for Python 3.8 and preliminary support for 3.9b4. - Drop support for Python 3.4 and 3.5. 4.3 (2018-10-04) ================ - Add support for Python 3.7. 4.2.0 (2017-09-12) ================== - Add support for Python 3.6. - Drop support for Python 3.3. - Fix handling of unicode supplemental traceback information on Python 2. Now such values are always encoded to UTF-8; previously the results were undefined and depended on system encodings and the values themselves. See `issue 1 `_. 4.1.0 (2017-04-12) ================== - Drop support for Python 2.6 and 3.2. - Make ``exceptionformatter.extract_stack`` signature comply with ``traceback.extract_stack`` - Add support for Python 3.5. 4.0.8 (2015-08-13) ================== - Fixes around ``TextExceptionFormatter`` ``limit``: ``formatException`` and ``extractStack`` was cutting the traceback at the bottom, at the most interesting point. Now it will cut from the middle. Some text about the missing entries will be inserted. - Maybe fix for ``extractStack``, it did not detect recursions in the frames. 4.0.7 (2014-03-19) ================== - Added explicit support for Python 3.4. - Updated ``boostrap.py`` to version 2.2. 4.0.6 (2013-02-28) ================== - Make sure that ``setup.py`` finds all tests. Now tox runs them all as well. - Fix failing test under Python 3. - Made buildout work under Python 3 and Buildout 2. 4.0.5 (2012-12-31) ================== - Fleshed out PyPI Trove classifiers. - Fixed a test failure under Python 2.6. 4.0.4 (2012-12-13) ================== - Release with a fixed MANIFEST.in (without ``docs/``) 4.0.3 (2012-12-10) ================== - Fixed format_exception(..., as_html=True) not to HTML-escape the '
' it adds to the exception value. 4.0.2 (2012-11-21) ================== - Test Python 3.3 support under tox. 4.0.1 (2012-08-20) ================== - Fixed optional dependency code for `'zope.security`` to work under Python 3.3. 4.0.0.1 (2012-05-16) ==================== - Fixed rendering of package docs on PyPI. 4.0.0 (2012-05-16) ================== - Automated build of Sphinx HTML docs and running doctest snippets via tox. - Added Sphinx documentation. - Added support for continuous integration using ``tox`` and ``jenkins``. - Removed use of '2to3' and associated fixers when installing under Py3k. The code is now in a "compatible subset" which supports Python 2.6, 2.7, and 3.2, including PyPy 1.8 (the version compatible with the 2.7 language spec). - 100% unit test coverage. - Dropped explicit support for Python 2.4 / 2.5 / 3.1. - Added 'setup.py dev' alias (runs ``setup.py develop`` plus installs ``nose`` and ``coverage``). - Added 'setup.py docs' alias (installs ``Sphinx`` and dependencies). 3.7.1 (2012-03-28) ================== - Fix: missed to reverse extractStack entries 3.7.0 (2012-03-28) ================== - Added TextExceptionFormatter.extractStack and extract_stack 3.6.2 (2012-03-28) ================== - Fallback to traceback.format_tb when the formatter is called recursively. i.e. Don't let errors in the formatter pass silently. - Fix deprecated unittest functions: ``assert_`` and ``assertEquals``. 3.6.1 (2010-07-06) ================== - Fixed tests to work under Python 2.7. - PEP8 cleanup and removed obsolete build infrastructure files. 3.6.0 (2010-05-02) ================== - Added support to bootstrap on Jython. - Added Python 3 support. - The dependency on zope.testing seemed spurious, possibly a rest of a real dependency that is gone now. I removed it. 3.5.2 (2008-04-30) ================== - Updated CHANGES.txt. 3.5.1 (2008-04-28) ================== - Reverted changes in 3.5.0. 3.5.0 ===== - Added the capability for exceptions to be formatted line-by-line. Unfortunately, also introduced a bug cause each line of the exception to be its own log message. 3.4.0 (2007-10-02) ================== - Updated package meta-data. 3.4.0b2 (2007-08-14) ==================== - Removed superfluous dependency on ``zope.deprecation``. 3.4.0b1 (2007-07-09) ==================== - Corresponds to the version of the ``zope.exceptions`` package shipped as part of the Zope 3.4.0b1 release. 3.2.0 (2006-01-05) ================== - Corresponds to the version of the ``zope.exceptions`` package shipped as part of the Zope 3.2.0 release. - Deprecated the ``INotFoundError`` interface and the corresponding ``NotFoundError`` exception class, in favor of "standard" exceptions ``AttributeError``, ``KeyError``). The deprecated items will be removed in Zope 3.3. 3.0.0 (2004-11-07) ================== - Corresponds to the version of the zope.exceptions package shipped as part of the Zope X3.0.0 release. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661087.0 zope_exceptions-6.0/src/zope.exceptions.egg-info/SOURCES.txt0000644000076600000240000000145715060743637023624 0ustar00m.howitzstaff.pre-commit-config.yaml .readthedocs.yaml CHANGES.rst CONTRIBUTING.md COPYRIGHT.txt LICENSE.txt MANIFEST.in README.rst buildout.cfg pyproject.toml setup.cfg setup.py tox.ini docs/Makefile docs/api.rst docs/conf.py docs/hacking.rst docs/index.rst docs/make.bat docs/narr.rst docs/requirements.txt src/zope.exceptions.egg-info/PKG-INFO src/zope.exceptions.egg-info/SOURCES.txt src/zope.exceptions.egg-info/dependency_links.txt src/zope.exceptions.egg-info/not-zip-safe src/zope.exceptions.egg-info/requires.txt src/zope.exceptions.egg-info/top_level.txt src/zope/exceptions/__init__.py src/zope/exceptions/exceptionformatter.py src/zope/exceptions/interfaces.py src/zope/exceptions/log.py src/zope/exceptions/tests/__init__.py src/zope/exceptions/tests/test_exceptionformatter.py src/zope/exceptions/tests/test_log.py././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661087.0 zope_exceptions-6.0/src/zope.exceptions.egg-info/dependency_links.txt0000644000076600000240000000000115060743637025777 0ustar00m.howitzstaff ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661087.0 zope_exceptions-6.0/src/zope.exceptions.egg-info/not-zip-safe0000644000076600000240000000000115060743637024157 0ustar00m.howitzstaff ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661087.0 zope_exceptions-6.0/src/zope.exceptions.egg-info/requires.txt0000644000076600000240000000014215060743637024326 0ustar00m.howitzstaffsetuptools zope.interface [docs] Sphinx repoze.sphinx.autointerface [test] zope.testrunner>=6.4 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661087.0 zope_exceptions-6.0/src/zope.exceptions.egg-info/top_level.txt0000644000076600000240000000000515060743637024456 0ustar00m.howitzstaffzope ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1757661086.0 zope_exceptions-6.0/tox.ini0000644000076600000240000000363015060743636015627 0ustar00m.howitzstaff# Generated from: # https://github.com/zopefoundation/meta/tree/master/config/pure-python [tox] minversion = 3.18 envlist = release-check lint py39 py310 py311 py312 py313 py314 pypy3 docs coverage [testenv] usedevelop = true package = wheel wheel_build_env = .pkg pip_pre = py314: true deps = setuptools == 78.1.1 Sphinx commands = zope-testrunner --test-path=src {posargs:-vc} sphinx-build -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest extras = test docs [testenv:setuptools-latest] basepython = python3 deps = git+https://github.com/pypa/setuptools.git\#egg=setuptools [testenv:release-check] description = ensure that the distribution is ready to release basepython = python3 skip_install = true deps = setuptools == 78.1.1 wheel twine build check-manifest check-python-versions >= 0.20.0 wheel commands_pre = commands = check-manifest check-python-versions --only setup.py,tox.ini,.github/workflows/tests.yml python -m build --sdist --no-isolation twine check dist/* [testenv:lint] description = This env runs all linters configured in .pre-commit-config.yaml basepython = python3 skip_install = true deps = pre-commit commands_pre = commands = pre-commit run --all-files --show-diff-on-failure [testenv:docs] basepython = python3 skip_install = false commands_pre = commands = sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html sphinx-build -b doctest -d docs/_build/doctrees docs docs/_build/doctest [testenv:coverage] basepython = python3 allowlist_externals = mkdir deps = coverage[toml] Sphinx commands = mkdir -p {toxinidir}/parts/htmlcov coverage run -m zope.testrunner --test-path=src {posargs:-vc} coverage run -a -m sphinx -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest coverage html coverage report