Skip to content

Return context-manager iterator from scandir()#363

Merged
jborean93 merged 1 commit into
jborean93:masterfrom
henrik-nil-acc:pr/scandir-context-manager
Jun 25, 2026
Merged

Return context-manager iterator from scandir()#363
jborean93 merged 1 commit into
jborean93:masterfrom
henrik-nil-acc:pr/scandir-context-manager

Conversation

@henrik-nil-acc

Copy link
Copy Markdown
Contributor

Abandoning scandir() iteration before exhaustion left the SMB directory handle open until GC finalized the generator, and callers had no idiomatic way to release it sooner. Stdlib os.scandir() solves this by returning a context-manager iterator.

Abandoning scandir() iteration before exhaustion left the SMB
directory handle open until GC finalized the generator, and
callers had no idiomatic way to release it sooner. Stdlib
os.scandir() solves this by returning a context-manager
iterator.
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.45283% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.73%. Comparing base (b23a216) to head (e8cb07b).

Files with missing lines Patch % Lines
src/smbclient/shutil.py 80.00% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #363   +/-   ##
=======================================
  Coverage   98.73%   98.73%           
=======================================
  Files          24       24           
  Lines        5288     5306   +18     
=======================================
+ Hits         5221     5239   +18     
  Misses         67       67           
Flag Coverage Δ
macOS 69.58% <54.71%> (+0.48%) ⬆️
py3.10 98.73% <92.45%> (+<0.01%) ⬆️
py3.11 98.73% <92.45%> (+<0.01%) ⬆️
py3.12 98.73% <92.45%> (+<0.01%) ⬆️
py3.13 98.73% <92.45%> (+<0.01%) ⬆️
py3.14 98.73% <92.45%> (+<0.01%) ⬆️
ubuntu 96.66% <88.67%> (+0.01%) ⬆️
windows 98.66% <92.45%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@jborean93 jborean93 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Nice, I realised I made this mistake after I did the initial release but didn't think I could actually solve it without making a breaking change. Glad to see I was wrong.

@jborean93
jborean93 merged commit f4529e7 into jborean93:master Jun 25, 2026
18 of 19 checks passed
@henrik-nil-acc
henrik-nil-acc deleted the pr/scandir-context-manager branch June 26, 2026 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants