Skip to content

Explicitly close url file to avoid ResourceWarning in Python 3.14#605

Closed
iwanb wants to merge 1 commit into
python-ldap:mainfrom
iwanb:patch-1
Closed

Explicitly close url file to avoid ResourceWarning in Python 3.14#605
iwanb wants to merge 1 commit into
python-ldap:mainfrom
iwanb:patch-1

Conversation

@iwanb

@iwanb iwanb commented Jan 17, 2026

Copy link
Copy Markdown
Contributor

urlopen opens a file, when it's not closed explicitly it creates the following warning (at least with Python 3.14):

ResourceWarning: Implicitly cleaning up <addinfourl at 140737302018240 whose fp = <_io.BufferedReader name='/build/source/Tests/data/subschema-ipa.demo1.freeipa.org.ldif'>>

This makes the test suite fail if pytest has strict warning checks.

I found this through this build failure for the NixOS python-ldap package with Python 3.14: https://hydra.nixos.org/build/318165407/nixlog/2

See also NixOS/nixpkgs#475732

thunze added a commit to thunze/nixpkgs that referenced this pull request Mar 21, 2026
thunze added a commit to thunze/nixpkgs that referenced this pull request Mar 21, 2026

@mistotebe mistotebe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi thanks for the patch, can you do the same in LDIFParser in ldif.py?

@spaceone

spaceone commented May 6, 2026

Copy link
Copy Markdown
Contributor

Hi thanks for the patch, can you do the same in LDIFParser in ldif.py?

I could do it in a separate merge request, if that's faster than waiting for somebody else, if you want.

@spaceone

spaceone commented May 6, 2026

Copy link
Copy Markdown
Contributor

→ here you go: #610

@mistotebe

Copy link
Copy Markdown
Contributor

Closed via 7ab1fa9

@mistotebe mistotebe closed this May 7, 2026
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.

3 participants