summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurits van Rees <maurits@vanrees.org>2022-11-08 12:12:03 +0100
committerMaurits van Rees <maurits@vanrees.org>2022-11-08 12:12:03 +0100
commit10cb81a7f9de9b8bf70b4657472cbe6dc9eed323 (patch)
tree5d7591f81b77bad11e80e21f095e8f40e460529b
parent0beb5834325358315f8e33dccaff911ee586d21d (diff)
downloadzope-exceptions-10cb81a7f9de9b8bf70b4657472cbe6dc9eed323.tar.gz
tox -e isort-apply
-rw-r--r--setup.py4
-rw-r--r--src/zope/exceptions/__init__.py16
-rw-r--r--src/zope/exceptions/exceptionformatter.py4
-rw-r--r--src/zope/exceptions/interfaces.py2
-rw-r--r--src/zope/exceptions/log.py3
-rw-r--r--src/zope/exceptions/tests/test_exceptionformatter.py7
6 files changed, 22 insertions, 14 deletions
diff --git a/setup.py b/setup.py
index 05fdec7..8db8909 100644
--- a/setup.py
+++ b/setup.py
@@ -19,7 +19,9 @@
"""Setup for zope.exceptions package
"""
import os
-from setuptools import setup, find_packages
+
+from setuptools import find_packages
+from setuptools import setup
def read(*rnames):
diff --git a/src/zope/exceptions/__init__.py b/src/zope/exceptions/__init__.py
index 84d1dd2..3dcdf02 100644
--- a/src/zope/exceptions/__init__.py
+++ b/src/zope/exceptions/__init__.py
@@ -17,14 +17,14 @@ 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 UserError
from zope.exceptions.interfaces import IUserError
+from zope.exceptions.interfaces import UserError
-from zope.exceptions.exceptionformatter import format_exception
-from zope.exceptions.exceptionformatter import print_exception
-from zope.exceptions.exceptionformatter import extract_stack
__all__ = [
'DuplicationError', 'IDuplicationError', 'UserError', 'IUserError',
@@ -40,12 +40,12 @@ except ImportError as v: # pragma: no cover
if 'security' not in str(v):
raise
else: # pragma: no cover
- from zope.security.interfaces import IUnauthorized
- from zope.security.interfaces import Unauthorized
- from zope.security.interfaces import IForbidden
- from zope.security.interfaces import IForbiddenAttribute
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',
diff --git a/src/zope/exceptions/exceptionformatter.py b/src/zope/exceptions/exceptionformatter.py
index d74dcf4..e6b0314 100644
--- a/src/zope/exceptions/exceptionformatter.py
+++ b/src/zope/exceptions/exceptionformatter.py
@@ -15,13 +15,17 @@
optionally in HTML.
"""
import sys
+
+
try:
from html import escape
except ImportError: # pragma: PY2
from cgi import escape
+
import linecache
import traceback
+
DEBUG_EXCEPTION_FORMATTER = 1
diff --git a/src/zope/exceptions/interfaces.py b/src/zope/exceptions/interfaces.py
index 4f792a5..525e4b0 100644
--- a/src/zope/exceptions/interfaces.py
+++ b/src/zope/exceptions/interfaces.py
@@ -28,8 +28,8 @@ 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 Interface
from zope.interface import Attribute
+from zope.interface import Interface
from zope.interface import implementer
diff --git a/src/zope/exceptions/log.py b/src/zope/exceptions/log.py
index d5a6c30..82049aa 100644
--- a/src/zope/exceptions/log.py
+++ b/src/zope/exceptions/log.py
@@ -14,11 +14,12 @@
"""Log formatter that enhances tracebacks with extra information.
"""
-import logging
import io
+import logging
from zope.exceptions.exceptionformatter import print_exception
+
Buffer = io.StringIO if bytes is not str else io.BytesIO # PY2
diff --git a/src/zope/exceptions/tests/test_exceptionformatter.py b/src/zope/exceptions/tests/test_exceptionformatter.py
index cf4ea9b..b8de36c 100644
--- a/src/zope/exceptions/tests/test_exceptionformatter.py
+++ b/src/zope/exceptions/tests/test_exceptionformatter.py
@@ -13,8 +13,8 @@
##############################################################################
"""ExceptionFormatter tests.
"""
-import unittest
import sys
+import unittest
IS_PY39_OR_GREATER = sys.version_info >= (3, 9)
@@ -709,9 +709,10 @@ class Test_format_exception(unittest.TestCase):
def test_format_exception_as_html(self):
# Test for format_exception (as_html=True)
- from zope.exceptions.exceptionformatter import format_exception
- from textwrap import dedent
import re
+ from textwrap import dedent
+
+ from zope.exceptions.exceptionformatter import format_exception
try:
exec('import')
except SyntaxError: