fix: replace bare except clauses with except Exception
Bare `except:` catches BaseException including KeyboardInterrupt and SystemExit. Replaced 4 instances with `except Exception:`.
This commit is contained in:
parent
d30a0a23ef
commit
1612dfe017
|
|
@ -962,7 +962,7 @@ def get_simulation_history():
|
||||||
try:
|
try:
|
||||||
created_date = sim_dict.get("created_at", "")[:10]
|
created_date = sim_dict.get("created_at", "")[:10]
|
||||||
sim_dict["created_date"] = created_date
|
sim_dict["created_date"] = created_date
|
||||||
except:
|
except Exception:
|
||||||
sim_dict["created_date"] = ""
|
sim_dict["created_date"] = ""
|
||||||
|
|
||||||
enriched_simulations.append(sim_dict)
|
enriched_simulations.append(sim_dict)
|
||||||
|
|
|
||||||
|
|
@ -642,7 +642,7 @@ class OasisProfileGenerator:
|
||||||
result = json.loads(json_str)
|
result = json.loads(json_str)
|
||||||
result["_fixed"] = True
|
result["_fixed"] = True
|
||||||
return result
|
return result
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# 6. 尝试从内容中提取部分信息
|
# 6. 尝试从内容中提取部分信息
|
||||||
|
|
|
||||||
|
|
@ -520,13 +520,13 @@ class SimulationConfigGenerator:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return json.loads(json_str)
|
return json.loads(json_str)
|
||||||
except:
|
except Exception:
|
||||||
# 尝试移除所有控制字符
|
# 尝试移除所有控制字符
|
||||||
json_str = re.sub(r'[\x00-\x1f\x7f-\x9f]', ' ', json_str)
|
json_str = re.sub(r'[\x00-\x1f\x7f-\x9f]', ' ', json_str)
|
||||||
json_str = re.sub(r'\s+', ' ', json_str)
|
json_str = re.sub(r'\s+', ' ', json_str)
|
||||||
try:
|
try:
|
||||||
return json.loads(json_str)
|
return json.loads(json_str)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue