Skip to content

fix: close annotation file handle via context manager#484

Open
tempoo04 wants to merge 1 commit into
roboflow:mainfrom
tempoo04:fix/close-annotation-file-handle
Open

fix: close annotation file handle via context manager#484
tempoo04 wants to merge 1 commit into
roboflow:mainfrom
tempoo04:fix/close-annotation-file-handle

Conversation

@tempoo04
Copy link
Copy Markdown

What does this PR do?

Fixes a resource leak in Project._annotation_params() where annotation_path was opened twice — once via a context
manager that did nothing, and again with a bare open() call whose handle was never closed.

Before:

 with open(annotation_path):
  annotation_string = open(annotation_path).read()

After:

with open(annotation_path) as f:
  annotation_string = f.read()

Related Issue(s): N/A

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Testing

  • I have tested this change locally
  • I have added/updated tests for this change

Test details:
Manually verified annotation upload flow reads file content correctly with the fixed handle. No behavioral change —
fix only affects resource cleanup.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings or errors

Additional Context

File descriptor leak only matters under high-volume upload loops or on systems with low fd limits, but the fix also
removes the redundant open() call making the intent clearer.

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.

1 participant