mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2026-02-20 14:44:58 +01:00
fix: Use context manager for file reading in load_user
Ensures proper resource cleanup by using 'with' statement instead of bare open() call when reading user profile files.
This commit is contained in:
parent
212a88a6f5
commit
09a604d47b
|
|
@ -1683,7 +1683,9 @@ def load_user(user_name, name1, user_bio):
|
|||
logger.error(f"Could not find the user \"{user_name}\" inside user_data/users. No user has been loaded.")
|
||||
raise ValueError
|
||||
|
||||
file_contents = open(filepath, 'r', encoding='utf-8').read()
|
||||
with open(filepath, 'r', encoding='utf-8') as f:
|
||||
file_contents = f.read()
|
||||
|
||||
extension = filepath.suffix[1:] # Remove the leading dot
|
||||
data = json.loads(file_contents) if extension == "json" else yaml.safe_load(file_contents)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue