Skip to content

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

Open
iwanb wants to merge 1 commit intopython-ldap:mainfrom
iwanb:patch-1
Open

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

Conversation

@iwanb
Copy link

@iwanb iwanb commented Jan 17, 2026

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

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