# HG changeset patch # User Matt Harbison # Date 1632162078 14400 # Node ID 5caec48d9a01feafb78d6628c6748fc673276989 # Parent a9bedc56f025607fca477ffa1bc06d7b101deb07 extensions: prevent a crash on py3 with a `minimumhgversion` str value The expectation is that this field is bytes, but unported extensions are a thing and it shouldn't explode on a bad value. We already do this transformation in the version reporting mechanism. Differential Revision: https://phab.mercurial-scm.org/D11476 diff -r a9bedc56f025 -r 5caec48d9a01 mercurial/extensions.py --- a/mercurial/extensions.py Mon Sep 20 14:16:10 2021 -0400 +++ b/mercurial/extensions.py Mon Sep 20 14:21:18 2021 -0400 @@ -224,7 +224,7 @@ minver = getattr(mod, 'minimumhgversion', None) if minver: curver = util.versiontuple(n=2) - extmin = util.versiontuple(minver, 2) + extmin = util.versiontuple(stringutil.forcebytestr(minver), 2) if None in extmin: extmin = (extmin[0] or 0, extmin[1] or 0) diff -r a9bedc56f025 -r 5caec48d9a01 tests/test-extension.t --- a/tests/test-extension.t Mon Sep 20 14:16:10 2021 -0400 +++ b/tests/test-extension.t Mon Sep 20 14:21:18 2021 -0400 @@ -1692,12 +1692,13 @@ $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third' [1] -Don't explode on py3 with a bad version number +Don't explode on py3 with a bad version number (both str vs bytes, and not enough +parts) $ cat > minversion4.py << EOF > from mercurial import util > util.version = lambda: b'3.5' - > minimumhgversion = b'3' + > minimumhgversion = '3' > EOF $ hg --config extensions.minversion=minversion4.py version -v Mercurial Distributed SCM (version 3.5)