##// END OF EJS Templates
extensions: avoid a crash when the version isn't properly byteified on py3...
Matt Harbison -
r46629:27c23c8f stable
parent child Browse files
Show More
@@ -936,6 +936,10 b' def moduleversion(module):'
936 936 version = b''
937 937 if isinstance(version, (list, tuple)):
938 938 version = b'.'.join(pycompat.bytestr(o) for o in version)
939 else:
940 # version data should be bytes, but not all extensions are ported
941 # to py3.
942 version = stringutil.forcebytestr(version)
939 943 return version
940 944
941 945
@@ -1399,12 +1399,20 b' Broken disabled extension and command:'
1399 1399 > cmdtable = {}
1400 1400 > command = registrar.command(cmdtable)
1401 1401 > class Bogon(Exception): pass
1402 > # NB: version should be bytes; simulating extension not ported to py3
1403 > __version__ = '1.0.0'
1402 1404 > @command(b'throw', [], b'hg throw', norepo=True)
1403 1405 > def throw(ui, **opts):
1404 1406 > """throws an exception"""
1405 1407 > raise Bogon()
1406 1408 > EOF
1407 1409
1410 Test extension without proper byteification of key attributes doesn't crash when
1411 accessed.
1412
1413 $ hg version -v --config extensions.throw=throw.py | grep '^ '
1414 throw external 1.0.0
1415
1408 1416 No declared supported version, extension complains:
1409 1417 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1410 1418 ** Unknown exception encountered with possibly-broken third-party extension throw
General Comments 0
You need to be logged in to leave comments. Login now