aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/utils
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-11-16 19:20:33 -0500
committerDylan Baker <dylan@pnwbakers.com>2022-11-17 12:56:04 -0800
commit0d3be23377c82f844aa7f9e9cb6074a8813400a4 (patch)
treed3a1968dc78e080616e4986c57a271c1e2d498a0 /mesonbuild/utils
parent3a4aa109b4932d13c1a620575510c41eae6cb048 (diff)
downloadmeson-0d3be23377c82f844aa7f9e9cb6074a8813400a4.zip
meson-0d3be23377c82f844aa7f9e9cb6074a8813400a4.tar.gz
meson-0d3be23377c82f844aa7f9e9cb6074a8813400a4.tar.bz2
build: use the unified pickle loader to handle more edge cases
We have divergent implementations of loading a pickled *.dat file. The Build class loader has a better error message. But the generic loader handles TypeError and ModuleNotFoundError. Merge the implementations, and use it for Build as well. Fixes #11051
Diffstat (limited to 'mesonbuild/utils')
-rw-r--r--mesonbuild/utils/universal.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py
index 570edd6..b1a301a 100644
--- a/mesonbuild/utils/universal.py
+++ b/mesonbuild/utils/universal.py
@@ -2289,16 +2289,21 @@ def pickle_load(filename: str, object_name: str, object_type: T.Type) -> T.Any:
except (pickle.UnpicklingError, EOFError):
raise MesonException(load_fail_msg)
except (TypeError, ModuleNotFoundError, AttributeError):
+ build_dir = os.path.dirname(os.path.dirname(filename))
raise MesonException(
f"{object_name} file {filename!r} references functions or classes that don't "
"exist. This probably means that it was generated with an old "
- "version of meson.")
+ "version of meson. Try running from the source directory "
+ f'meson setup {build_dir} --wipe')
if not isinstance(obj, object_type):
raise MesonException(load_fail_msg)
from ..coredata import version as coredata_version
from ..coredata import major_versions_differ, MesonVersionMismatchException
- if major_versions_differ(obj.version, coredata_version):
- raise MesonVersionMismatchException(obj.version, coredata_version)
+ version = getattr(obj, 'version', None)
+ if version is None:
+ version = obj.environment.coredata.version
+ if major_versions_differ(version, coredata_version):
+ raise MesonVersionMismatchException(version, coredata_version)
return obj