Skip to content

Commit 70bfa38

Browse files
committed
Merge branch 'fix-builtin-wrap' of https://github.com/julianz-/cheroot into fix-builtin-wrap
2 parents 015bfd4 + e28d855 commit 70bfa38

39 files changed

+87
-40
lines changed

.github/workflows/ci-cd.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,9 @@ jobs:
10611061
- build
10621062
- post-release-repo-update
10631063
- pre-setup # transitive, for accessing settings
1064+
if: >-
1065+
always()
1066+
&& needs.post-release-repo-update.result == 'success'
10641067
10651068
permissions:
10661069
actions: read

.pre-commit-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ repos:
287287
- pyOpenSSL # needed by pylint-pytest since it picks up pytest's args
288288
- pypytools
289289
- pytest-cov # needed by pylint-pytest since it picks up pytest's args
290+
- pytest-mock # needed by pylint-pytest since it picks up pytest's args
291+
- >- # needed by pylint-pytest since it picks up pytest's args
292+
pytest-rerunfailures
290293
- pytest-xdist # needed by pylint-pytest since it picks up pytest's args
291294
- requests_toolbelt
292295
- requests_unixsocket

cheroot/makefile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
_not_a_socket_err = 10038
2222
else:
2323
# On other platforms, the relevant error is EBADF (Bad file descriptor),
24-
# which is already in your list of handled errors.
24+
# which is already in the list of handled errors.
2525
pass
2626

2727
# Expose the error constant for use in the module's public API if needed.

cheroot/test/test_conn.py

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import errno
44
import http.client
5+
import io
56
import logging
67
import socket
78
import time
@@ -14,6 +15,7 @@
1415
import pytest
1516

1617
from jaraco.text import trim, unwrap
18+
from OpenSSL.SSL import SysCallError
1719

1820
import cheroot.server
1921
from cheroot._compat import IS_CI, IS_MACOS, IS_PYPY, IS_WINDOWS
@@ -1645,8 +1647,6 @@ class TestBufferedWriter:
16451647

16461648
def test_close_is_idempotent(self):
16471649
"""Test that close() can be called multiple times safely."""
1648-
import io
1649-
16501650
raw_buffer = io.BytesIO()
16511651
buffered_writer = BufferedWriter(raw_buffer)
16521652

@@ -1658,8 +1658,6 @@ def test_close_is_idempotent(self):
16581658

16591659
def test_close_handles_already_closed_buffer(self):
16601660
"""Test that close() handles already closed underlying buffer."""
1661-
import io
1662-
16631661
raw_buffer = io.BytesIO()
16641662
buffered_writer = BufferedWriter(raw_buffer)
16651663

@@ -1668,3 +1666,46 @@ def test_close_handles_already_closed_buffer(self):
16681666

16691667
# This should not raise an exception
16701668
buffered_writer.close()
1669+
1670+
def test_close_handles_os_error_ebadf(self, mocker):
1671+
"""Test that close() handles OSError with EBADF errno gracefully."""
1672+
raw_buffer = io.BytesIO()
1673+
buffered_writer = BufferedWriter(raw_buffer)
1674+
1675+
# Mock super().close() to raise OSError with EBADF
1676+
mock_super = mocker.patch('cheroot.makefile.super')
1677+
mock_super.return_value.close.side_effect = OSError(
1678+
errno.EBADF,
1679+
'Bad file descriptor',
1680+
)
1681+
1682+
# Should handle EBADF gracefully (no exception raised)
1683+
buffered_writer.close()
1684+
1685+
def test_close_handles_os_error_enotconn(self, mocker):
1686+
"""Test that close() handles OSError with ENOTCONN errno gracefully."""
1687+
raw_buffer = io.BytesIO()
1688+
buffered_writer = BufferedWriter(raw_buffer)
1689+
1690+
# Mock super().close() to raise OSError with ENOTCONN
1691+
mock_super = mocker.patch('cheroot.makefile.super')
1692+
mock_super.return_value.close.side_effect = OSError(
1693+
errno.ENOTCONN,
1694+
'Socket is not connected',
1695+
)
1696+
1697+
# Should handle ENOTCONN gracefully (no exception raised)
1698+
buffered_writer.close()
1699+
1700+
def test_close_handles_syscall_error(self, mocker):
1701+
"""Test that close() handles SysCallError with expected errno codes."""
1702+
raw_buffer = io.BytesIO()
1703+
buffered_writer = BufferedWriter(raw_buffer)
1704+
1705+
mock_super = mocker.patch('cheroot.makefile.super')
1706+
mock_super.return_value.close.side_effect = SysCallError(
1707+
errno.EBADF,
1708+
) # args[0] will be errno.EBADF
1709+
1710+
# Should handle gracefully
1711+
buffered_writer.close()

requirements/tox-py310-cp310-darwin-arm64.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ charset-normalizer==3.4.3
1818
# via requests
1919
colorama==0.4.6
2020
# via pytest-watch
21-
coverage==7.10.6
21+
coverage==7.10.7
2222
# via
2323
# -r requirements/tox-py310-cp310-darwin-arm64.in
2424
# pytest-cov

requirements/tox-py310-cp310-darwin-x86_64.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ charset-normalizer==3.4.3
1818
# via requests
1919
colorama==0.4.6
2020
# via pytest-watch
21-
coverage==7.10.6
21+
coverage==7.10.7
2222
# via
2323
# -r requirements/tox-py310-cp310-darwin-x86_64.in
2424
# pytest-cov

requirements/tox-py310-cp310-linux-aarch64.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ charset-normalizer==3.4.3
1818
# via requests
1919
colorama==0.4.6
2020
# via pytest-watch
21-
coverage==7.10.6
21+
coverage==7.10.7
2222
# via
2323
# -r requirements/tox-py310-cp310-linux-aarch64.in
2424
# pytest-cov

requirements/tox-py310-cp310-linux-x86_64.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ charset-normalizer==3.4.3
1818
# via requests
1919
colorama==0.4.6
2020
# via pytest-watch
21-
coverage==7.10.6
21+
coverage==7.10.7
2222
# via
2323
# -r requirements/tox-py310-cp310-linux-x86_64.in
2424
# pytest-cov

requirements/tox-py310-cp310-win32-amd64.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ colorama==0.4.6
2020
# via
2121
# pytest
2222
# pytest-watch
23-
coverage==7.10.6
23+
coverage==7.10.7
2424
# via
2525
# -r requirements/tox-py310-cp310-win32-amd64.in
2626
# pytest-cov

requirements/tox-py311-cp311-darwin-arm64.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ charset-normalizer==3.4.3
1818
# via requests
1919
colorama==0.4.6
2020
# via pytest-watch
21-
coverage==7.10.6
21+
coverage==7.10.7
2222
# via
2323
# -r requirements/tox-py311-cp311-darwin-arm64.in
2424
# pytest-cov

0 commit comments

Comments
 (0)