From 66739bc306dbdd091e391673d3f78c9f769ebc09 Mon Sep 17 00:00:00 2001 From: Koa Wells Date: Fri, 7 Jul 2023 22:16:55 -0400 Subject: [PATCH] Fix bug with opening pickle files from a pickle created in another operating system (for Windows and Linux only) --- hub/city_model_structure/city.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hub/city_model_structure/city.py b/hub/city_model_structure/city.py index 1ccc154c..44d72414 100644 --- a/hub/city_model_structure/city.py +++ b/hub/city_model_structure/city.py @@ -12,6 +12,8 @@ import copy import logging import math import pickle +import sys +import pathlib from pathlib import Path from typing import List, Union @@ -293,6 +295,11 @@ class City: :param city_filename: city filename :return: City """ + if sys.platform == 'win32': + pathlib.PosixPath = pathlib.WindowsPath + elif sys.platform == 'linux': + pathlib.WindowsPath = pathlib.PosixPath + with open(city_filename, 'rb') as file: return pickle.load(file)