Properly close providers.json file stream. (#12794)

rav/faster_joins/work
Petr Vaněk 2022-05-19 16:23:59 +02:00 committed by GitHub
parent 66a5f6c400
commit 684feeaf2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

1
changelog.d/12794.bugfix Normal file
View File

@ -0,0 +1 @@
Fix a bug introduced in 1.43.0 where a file (`providers.json`) was never closed. Contributed by @arkamar.

View File

@ -57,9 +57,9 @@ class OembedConfig(Config):
"""
# Whether to use the packaged providers.json file.
if not oembed_config.get("disable_default_providers") or False:
providers = json.load(
pkg_resources.resource_stream("synapse", "res/providers.json")
)
with pkg_resources.resource_stream("synapse", "res/providers.json") as s:
providers = json.load(s)
yield from self._parse_and_validate_provider(
providers, config_path=("oembed",)
)