From ed22e471e583bcc5261c580321af9ac75a2db883 Mon Sep 17 00:00:00 2001
From: Itamar Turner-Trauring
Date: Fri, 15 Mar 2024 09:38:53 -0400
Subject: [PATCH] Apply suggestions from code review
Co-authored-by: Glyph
---
src/twisted/python/failure.py | 2 +-
src/twisted/test/test_failure.py | 14 +++++++-------
src/twisted/web/_newclient.py | 6 +++---
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/twisted/python/failure.py b/src/twisted/python/failure.py
index 2604f05848d..e2048523a94 100644
--- a/src/twisted/python/failure.py
+++ b/src/twisted/python/failure.py
@@ -460,7 +460,7 @@ def _extrapolate(self, otherFailure):
self.frames = frames
@staticmethod
- def _without_traceback(value: BaseException) -> Failure:
+ def _withoutTraceback(value: BaseException) -> Failure:
"""
Create a L{Failure} for an exception without a traceback.
diff --git a/src/twisted/test/test_failure.py b/src/twisted/test/test_failure.py
index fbd49c22d0f..75ea02c4d6c 100644
--- a/src/twisted/test/test_failure.py
+++ b/src/twisted/test/test_failure.py
@@ -522,14 +522,14 @@ def test_repr(self) -> None:
"" % (typeName,),
)
- def test_failure_without_traceback(self) -> None:
+ def test_failureWithoutTraceback(self) -> None:
"""
- C{Failure._without_traceback(exc)} gives the same result as
+ C{Failure._withoutTraceback(exc)} gives the same result as
C{Failure(exc)}.
"""
exc = ZeroDivisionError("hello")
dict1 = failure.Failure(exc).__dict__.copy()
- failure2 = failure.Failure._without_traceback(exc)
+ failure2 = failure.Failure._withoutTraceback(exc)
self.assertIsInstance(failure2, failure.Failure)
dict2 = failure2.__dict__.copy()
@@ -539,9 +539,9 @@ def test_failure_without_traceback(self) -> None:
# The rest of the attributes should be identical:
self.assertEqual(dict1, dict2)
- def test_failure_pickling(self) -> None:
+ def test_failurePickling(self) -> None:
"""
- C{Failure(exc)} and C{Failure._without_traceback(exc)} can be pickled
+ C{Failure(exc)} and C{Failure._withoutTraceback(exc)} can be pickled
and unpickled.
"""
exc = ComparableException("hello")
@@ -551,7 +551,7 @@ def test_failure_pickling(self) -> None:
# You would think this test is unnecessary, since it's just a
# C{Failure}, but actually the behavior of pickling can sometimes be
# different because of the way the constructor works!
- failure2 = failure.Failure._without_traceback(exc)
+ failure2 = failure.Failure._withoutTraceback(exc)
self.assertPicklingRoundtrips(failure2)
def assertPicklingRoundtrips(self, original_failure: failure.Failure) -> None:
@@ -564,7 +564,7 @@ def assertPicklingRoundtrips(self, original_failure: failure.Failure) -> None:
expected["pickled"] = 1
self.assertEqual(expected, failure2.__dict__)
- def test_failure_pickling_includes_parents(self) -> None:
+ def test_failurePicklingIncludesParents(self) -> None:
"""
C{Failure.parents} is included in the pickle.
"""
diff --git a/src/twisted/web/_newclient.py b/src/twisted/web/_newclient.py
index 8f864b4d355..f1736e5a043 100644
--- a/src/twisted/web/_newclient.py
+++ b/src/twisted/web/_newclient.py
@@ -1270,7 +1270,7 @@ def _bodyDataFinished_INITIAL(self, reason=None):
"""
self._state = "DEFERRED_CLOSE"
if reason is None:
- reason = Failure._without_traceback(
+ reason = Failure._withoutTraceback(
ResponseDone("Response body fully received")
)
self._reason = reason
@@ -1280,7 +1280,7 @@ def _bodyDataFinished_CONNECTED(self, reason=None):
Disconnect the protocol and move to the C{'FINISHED'} state.
"""
if reason is None:
- reason = Failure._without_traceback(
+ reason = Failure._withoutTraceback(
ResponseDone("Response body fully received")
)
self._bodyProtocol.connectionLost(reason)
@@ -1597,7 +1597,7 @@ def _finishResponse_WAITING(self, rest):
or self._state != "QUIESCENT"
or not self._currentRequest.persistent
):
- self._giveUp(Failure._without_traceback(reason))
+ self._giveUp(Failure._withoutTraceback(reason))
else:
# Just in case we had paused the transport, resume it before
# considering it quiescent again.