##// END OF EJS Templates
extensions: avoid a crash when the version isn't properly byteified on py3...
Matt Harbison -
r46559:3db545fc default
parent child Browse files
Show More
@@ -936,6 +936,10 def moduleversion(module):
936 version = b''
936 version = b''
937 if isinstance(version, (list, tuple)):
937 if isinstance(version, (list, tuple)):
938 version = b'.'.join(pycompat.bytestr(o) for o in version)
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 return version
943 return version
940
944
941
945
@@ -1399,12 +1399,20 Broken disabled extension and command:
1399 > cmdtable = {}
1399 > cmdtable = {}
1400 > command = registrar.command(cmdtable)
1400 > command = registrar.command(cmdtable)
1401 > class Bogon(Exception): pass
1401 > class Bogon(Exception): pass
1402 > # NB: version should be bytes; simulating extension not ported to py3
1403 > __version__ = '1.0.0'
1402 > @command(b'throw', [], b'hg throw', norepo=True)
1404 > @command(b'throw', [], b'hg throw', norepo=True)
1403 > def throw(ui, **opts):
1405 > def throw(ui, **opts):
1404 > """throws an exception"""
1406 > """throws an exception"""
1405 > raise Bogon()
1407 > raise Bogon()
1406 > EOF
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 No declared supported version, extension complains:
1416 No declared supported version, extension complains:
1409 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1417 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1410 ** Unknown exception encountered with possibly-broken third-party extension throw
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