GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix HTTPS httpx mocking in `wrap_bio()` plus regressions occurred by Copilot · Pull Request #324 · mindflayer/python-mocket

Conversation

Copilot AI commented Jul 13, 2026 •
edited by mindflayer
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

What this MR fixes

This MR resolves async networking regressions introduced while fixing large-response behavior, and stabilizes HTTP/SSL mocking across httpx and aiohttp.

1) Large async response hang (test_async_case_high_number)

  • Fixed a deadlock caused by writing large mocked responses directly into OS pipes.
  • Introduced a hybrid pipe strategy:
    • small responses mirror bytes into pipes (legacy-compatible behavior),
    • large responses use bounded readiness signaling to avoid pipe-buffer blocking.
  • Kept response payloads in shared in-memory buffers per address.

2) aiohttp SSL failures (test_aiohttp)

  • Fixed ServerDisconnectedError / SSL read-loop instability by decoupling SSL reads from shared socket cursor state.
  • MocketSSLSocket now keeps a private pending SSL read buffer snapshot after writes, so protocol reads are deterministic across runtimes.
  • Preserved expected pre-write SSL probing behavior (SSLWantReadError before first write after handshake).

3) Multi-socket regression during full test run

  • Fixed TypeError: 'NoneType' object cannot be interpreted as an integer in recv() when called via recv_into() with buffersize=None and pipe-backed reads.
  • recv() now normalizes None to the socket default buffer size.

4) PyPy compatibility regression (BufferError)

  • Fixed BufferError: Existing exports of data: object cannot be re-sized seen in true-send HTTP flows on PyPy.
  • Root cause: BytesIO.getbuffer() exports remained active while later writes resized the buffer.
  • Replaced resize-sensitive getbuffer() reads with getvalue()-based logic in socket buffering paths.

5) Coverage recovery for new logic

  • Added targeted tests for:
    • shared per-address I/O behavior,
    • pipe-mode flags and reset behavior,
    • large-response readiness sentinel drain/resync path,
    • SSL read behavior around handshake/write ordering,
    • empty server_hostname handling in SSL bio wrapping,
    • getpeercert() fallback to Mocket._address when host/port are unset.

Result

  • Local full test target passes (make test).
  • Previously failing async paths (httpx high payload + aiohttp SSL flow) now pass consistently.
  • PyPy-specific true-send path is stable again.
  • Coverage remains high (overall 99%; mocket/socket.py and mocket/ssl/socket.py at 100%).
  • Latest local run: 228 passed, 3 xfailed (+ tests/test_pook.py passed).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Initial plan
2224d47
Copilot AI assigned Copilot and mindflayer Jul 13, 2026
Copilot started work on behalf of mindflayer July 13, 2026 06:15
View session
Copilot AI added 5 commits July 13, 2026 06:25
fix httpx https wrap_bio address handling
045c147
refine ssl wrap_bio regression fix
dc6607e
clarify ssl wrap_bio address assignment
52ac684
harden ssl wrap_bio hostname decoding
3d69a48
simplify ssl wrap_bio fallback logic
6d4f283
@mindflayer
mindflayer marked this pull request as ready for review July 13, 2026 06:29
Copilot AI review requested due to automatic review settings July 13, 2026 06:29
handle empty ssl wrap_bio hostnames explicitly
51ef057
Copilot started reviewing on behalf of mindflayer July 13, 2026 06:30
View session
Copilot AI added 2 commits July 13, 2026 06:30
rename ssl wrap_bio hostname locals
6524dd9
preserve ssl wrap_bio port state consistently
c35a05c
Copilot AI changed the title [WIP] Fix failing GitHub Actions job "build (3.10)" Fix HTTPS httpx mocking in wrap_bio() for the Python 3.10 build Jul 13, 2026
Copilot AI requested a review from mindflayer July 13, 2026 06:32
Copilot finished work on behalf of mindflayer July 13, 2026 06:32
Copilot AI reviewed Jul 13, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts Mocket’s fake SSLContext.wrap_bio() behavior to better match how HTTPS clients (notably httpx on Python 3.10) provide/expect server_hostname, and adds a focused regression test to ensure the SSL object reflects the currently connected Mocket address.

Changes:

  • Decode server_hostname when it is passed as bytes (UTF-8 with replacement) so internal host handling stays string-based.
  • When server_hostname is None, derive the host/port (and _address) from Mocket._address to preserve expected HTTPS behavior.
  • Add a parametrized test covering bytes/str/None/empty/invalid-byte hostnames for wrap_bio().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/test_socket.py Adds a regression test asserting wrap_bio() populates _host, _port, and _address consistently (including bytes hostname decoding).
mocket/ssl/context.py Updates MocketSSLContext.wrap_bio() to normalize server_hostname and to use Mocket._address for host/port derivation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mindflayer
Prevent deadlock when mocking large async HTTP responses.
ba01de9
@mindflayer
mindflayer requested a review from Copilot July 13, 2026 08:05
Copilot started reviewing on behalf of mindflayer July 13, 2026 08:06
View session
@codecov

codecov Bot commented Jul 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.66667% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.09%. Comparing base (c5daccb) to head (2329887).

Files with missing lines Patch % Lines
mocket/socket.py 86.25% 11 Missing ⚠️
mocket/ssl/socket.py 92.59% 2 Missing ⚠️
mocket/ssl/context.py 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #324      +/-   ##
==========================================
- Coverage   99.06%   98.09%   -0.98%     
==========================================
  Files          22       22              
  Lines        1075     1207     +132     
==========================================
+ Hits         1065     1184     +119     
- Misses         10       23      +13     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot AI reviewed Jul 13, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread mocket/socket.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread mocket/ssl/context.py
Comment on lines +126 to +131
effective_host = hostname if hostname is not None else current_host
ssl_obj._host = effective_host
if current_port is not None:
ssl_obj._port = current_port
if effective_host is not None and current_port is not None:
ssl_obj._address = (effective_host, current_port)
mindflayer and others added 2 commits July 13, 2026 10:18
@mindflayer
Add more tests for coverage and preventing regressions.
7f5f281
@mindflayer
Potential fix for pull request finding
3ba91b5
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copilot started work on behalf of mindflayer July 13, 2026 08:24
View session
Fix SSL host fallback check for empty server_hostname
05ee3ff
Copilot finished work on behalf of mindflayer July 13, 2026 08:27
Copilot started work on behalf of mindflayer July 13, 2026 08:32
View session
Copilot finished work on behalf of mindflayer July 13, 2026 08:35
mindflayer added 5 commits July 13, 2026 10:58
@mindflayer
Add more tests for coverage and preventing regressions.
a667969
@mindflayer
Merge branch 'copilot/fix-failing-github-actions-job' of github.com:m…
1092c68
…indflayer/python-mocket into copilot/fix-failing-github-actions-job
@mindflayer
Add more tests for coverage and preventing regressions.
728e9d2
@mindflayer
Add more tests for coverage and preventing regressions.
91b4e88
@mindflayer
More tests
6fc1de6
@mindflayer mindflayer changed the title Fix HTTPS httpx mocking in wrap_bio() for the Python 3.10 build Fix HTTPS httpx mocking in wrap_bio() plus regressions occurred Jul 13, 2026
Copilot started work on behalf of mindflayer July 13, 2026 09:31
View session
Preserve empty SSL host when filling missing peer cert fields
2329887
@sonarqubecloud

sonarqubecloud Bot commented Jul 13, 2026

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot finished work on behalf of mindflayer July 13, 2026 09:36
@mindflayer
mindflayer merged commit aba1797 into main Jul 13, 2026
10 of 12 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@mindflayer
mindflayer deleted the copilot/fix-failing-github-actions-job branch July 13, 2026 09:42
@mweinelt mweinelt mentioned this pull request Jul 13, 2026
test_httprettish_httpx_session breaks with anyio 4.14.2 #325
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@mindflayer mindflayer Awaiting requested review from mindflayer

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@mindflayer mindflayer

Copilot code review Copilot

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@mindflayer
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.