From 19971e6e71c5c2e209df717c7c615bc64db4dcab Mon Sep 17 00:00:00 2001 From: profitroll Date: Thu, 19 Sep 2024 21:56:24 +0200 Subject: [PATCH] Fixed a rare bug with locals() being changed during iteration --- src/pyrmv/raw/board_arrival.py | 2 +- src/pyrmv/raw/board_departure.py | 2 +- src/pyrmv/raw/him_search.py | 2 +- src/pyrmv/raw/journey_detail.py | 2 +- src/pyrmv/raw/stop_by_coords.py | 2 +- src/pyrmv/raw/stop_by_name.py | 2 +- src/pyrmv/raw/trip_find.py | 2 +- src/pyrmv/raw/trip_recon.py | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pyrmv/raw/board_arrival.py b/src/pyrmv/raw/board_arrival.py index 1e34527..b6674ec 100644 --- a/src/pyrmv/raw/board_arrival.py +++ b/src/pyrmv/raw/board_arrival.py @@ -64,7 +64,7 @@ def board_arrival( payload = {} headers = {"Accept": "application/json"} if json else {"Accept": "application/xml"} - for var, val in locals().items(): + for var, val in locals().copy().items(): if str(var) == "date": if val != None: if isinstance(val, datetime): diff --git a/src/pyrmv/raw/board_departure.py b/src/pyrmv/raw/board_departure.py index e3cef29..dafe1fc 100644 --- a/src/pyrmv/raw/board_departure.py +++ b/src/pyrmv/raw/board_departure.py @@ -65,7 +65,7 @@ def board_departure( payload = {} headers = {"Accept": "application/json"} if json else {"Accept": "application/xml"} - for var, val in locals().items(): + for var, val in locals().copy().items(): if str(var) == "date": if val != None: if isinstance(val, datetime): diff --git a/src/pyrmv/raw/him_search.py b/src/pyrmv/raw/him_search.py index bd6a2c3..535a8e6 100644 --- a/src/pyrmv/raw/him_search.py +++ b/src/pyrmv/raw/him_search.py @@ -97,7 +97,7 @@ def him_search( payload = {} headers = {"Accept": "application/json"} if json else {"Accept": "application/xml"} - for var, val in locals().items(): + for var, val in locals().copy().items(): if str(var) in {"dateB", "dateE"}: if val != None: if isinstance(val, datetime): diff --git a/src/pyrmv/raw/journey_detail.py b/src/pyrmv/raw/journey_detail.py index 81235c2..39236d8 100644 --- a/src/pyrmv/raw/journey_detail.py +++ b/src/pyrmv/raw/journey_detail.py @@ -55,7 +55,7 @@ def journey_detail( payload = {} headers = {"Accept": "application/json"} if json else {"Accept": "application/xml"} - for var, val in locals().items(): + for var, val in locals().copy().items(): if str(var) == "rtMode": if val != None: payload["rtMode"] = val.upper() diff --git a/src/pyrmv/raw/stop_by_coords.py b/src/pyrmv/raw/stop_by_coords.py index b8c7f05..b4fbdf4 100644 --- a/src/pyrmv/raw/stop_by_coords.py +++ b/src/pyrmv/raw/stop_by_coords.py @@ -54,7 +54,7 @@ def stop_by_coords( payload = {} headers = {"Accept": "application/json"} if json else {"Accept": "application/xml"} - for var, val in locals().items(): + for var, val in locals().copy().items(): if str(var) == "stopType": if val != None: payload["type"] = val.upper() diff --git a/src/pyrmv/raw/stop_by_name.py b/src/pyrmv/raw/stop_by_name.py index 5355a0b..5ac372c 100644 --- a/src/pyrmv/raw/stop_by_name.py +++ b/src/pyrmv/raw/stop_by_name.py @@ -65,7 +65,7 @@ def stop_by_name( payload = {} headers = {"Accept": "application/json"} if json else {"Accept": "application/xml"} - for var, val in locals().items(): + for var, val in locals().copy().items(): if str(var) == "inputString": if val != None: payload["input"] = val diff --git a/src/pyrmv/raw/trip_find.py b/src/pyrmv/raw/trip_find.py index 8465074..887b2cd 100644 --- a/src/pyrmv/raw/trip_find.py +++ b/src/pyrmv/raw/trip_find.py @@ -201,7 +201,7 @@ def trip_find( payload = {} headers = {"Accept": "application/json"} if json else {"Accept": "application/xml"} - for var, val in locals().items(): + for var, val in locals().copy().items(): if str(var) == "date": if val != None: if isinstance(val, datetime): diff --git a/src/pyrmv/raw/trip_recon.py b/src/pyrmv/raw/trip_recon.py index e916e1e..ccb0941 100644 --- a/src/pyrmv/raw/trip_recon.py +++ b/src/pyrmv/raw/trip_recon.py @@ -87,7 +87,7 @@ def trip_recon( payload = {} headers = {"Accept": "application/json"} if json else {"Accept": "application/xml"} - for var, val in locals().items(): + for var, val in locals().copy().items(): if str(var) == "date": if val != None: if isinstance(val, datetime):