Repository navigation
Close the workbook in get_xlsx_sheet_info (#1051) - #1055
Merged
Merged
Conversation
get_xlsx_sheet_info opened a workbook with pd.ExcelFile(path) to list its sheet names but never closed it, leaking the file handle. The unclosed handle raised a ResourceWarning on garbage collection and, on Windows, kept the .xlsx locked against deletion or overwrite. Read the sheet names inside a 'with pd.ExcelFile(path) as book:' block so the workbook is always closed. Adds a regression test and a CHANGELOG entry.
sammist2
requested review from
Shreyash0712,
ahmdkaml and
yakew7
as code owners
October 17, 2026 19:57
Contributor
|
@sammist2 is attempting to deploy a commit to the yashkewlani2020-gmailcom's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Hey @sammist2, your first PR on Fair Code, that's awesome, thank you. This project is about making AI more accountable, and contributions like yours are what keep that work going. We'll review your changes shortly. If you haven't already, give the contributing guide a quick read: it covers how audits are structured and what we look for in a review. And if you're finding Fair Code useful or interesting, a star on the repo genuinely helps more people find it - no pressure, just appreciated. |
|
@yakew7 @Shreyash0712 @ahmdkaml - new PR touching a path you own, please review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1051.
get_xlsx_sheet_infoopened a workbook withpd.ExcelFile(path)only to list its sheet names, but never closed it. The leaked handle raised aResourceWarningon garbage collection and, on Windows, kept the.xlsxlocked against deletion or overwrite.The sheet names are now read inside a
with pd.ExcelFile(path) as book:block, so the workbook is always closed. The existing behavior is unchanged: a non-.xlsxpath and an unreadable file still returnNone.Added
test_get_xlsx_sheet_info_closes_the_workbookintests/test_loaders.py(it records warnings and forces a collection; fails before the change, passes after) and a CHANGELOG entry under [Unreleased].