Allow retrying failed pool stream closes
Closed
JA
6h ago+82+82+01234567890123456789-6-6-0123456789
Fixes #1328.
PoolByteStream.aclose() marked itself closed before closing its inner stream. An ordinary close exception then made every retry a no-op, leaving the associated pool request registered. The sync path had the same failure.
Roll back _closed only when the inner close raises, preserving its successful-close idempotence. Regression tests cover a failing first close, successful retry, pool-slot release, and a no-op third close for asyncio, trio and sync.
Verified with scripts/check, scripts/test (2,132 passed, 100% coverage), and a fresh installed httpcore2 wheel exercised with the reported reproduction on Python 3.15.