Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Glyph <glyph@twistedmatrix.com>
  • Loading branch information
itamarst and glyph authored Mar 15, 2024
1 parent 1ea4db4 commit ed22e47
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/twisted/python/failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 7 additions & 7 deletions src/twisted/test/test_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,14 +522,14 @@ def test_repr(self) -> None:
"<twisted.python.failure.Failure " "%s: division by zero>" % (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()

Expand All @@ -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")
Expand All @@ -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:
Expand All @@ -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.
"""
Expand Down
6 changes: 3 additions & 3 deletions src/twisted/web/_newclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit ed22e47

Please sign in to comment.