1
1
mirror of https://github.com/KenanZhu/AutoLibrary.git synced 2026-08-02 14:19:35 +08:00

fix(config): ConfigManager.get() 返回深拷贝,消除跨模块字典原地修改

This commit is contained in:
2026-06-26 11:10:28 +08:00
parent 06740776a9
commit dfa9ae1a0c
6 changed files with 18 additions and 6 deletions
+3 -2
View File
@@ -7,6 +7,7 @@ This software is provided "as is", without any warranty of any kind.
You may use, modify, and distribute this file under the terms of the MIT License.
See the LICENSE file for details.
"""
import copy
import os
import threading
@@ -124,13 +125,13 @@ class ConfigManager:
with self.__lock:
config_data = self.__config_data[key.config_type.value]
if key.key == "":
return config_data
return copy.deepcopy(config_data)
keys = key.key.split('.')
for k in keys[:-1]:
config_data = config_data.get(k, None)
if config_data is None:
return default
return config_data.get(keys[-1], default)
return copy.deepcopy(config_data.get(keys[-1], default))
def set(
self,