Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/debugcommands.py @ 43726:1fb19665c166
debuginstall: gracefully handle missing __file__ attributes
This was crashing PyOxidizer. While here, point "Python lib" and "installed
modules" to the oxidized binary when read from memory instead of pretending
their location is unknown.
Differential Revision: https://phab.mercurial-scm.org/D7451
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 17 Nov 2019 01:00:06 -0500 |
parents | 72b454fae92e |
children | f1dabf99db17 |
comparison
equal
deleted
inserted
replaced
43725:da925257a39e | 43726:1fb19665c166 |
---|---|
1468 _(b" %s\n (check that your locale is properly set)\n"), | 1468 _(b" %s\n (check that your locale is properly set)\n"), |
1469 err, | 1469 err, |
1470 ) | 1470 ) |
1471 | 1471 |
1472 # Python | 1472 # Python |
1473 pythonlib = None | |
1474 if util.safehasattr(os, '__file__'): | |
1475 pythonlib = os.path.dirname(pycompat.fsencode(os.__file__)) | |
1476 elif getattr(sys, 'oxidized', False): | |
1477 pythonlib = pycompat.sysexecutable | |
1478 | |
1473 fm.write( | 1479 fm.write( |
1474 b'pythonexe', | 1480 b'pythonexe', |
1475 _(b"checking Python executable (%s)\n"), | 1481 _(b"checking Python executable (%s)\n"), |
1476 pycompat.sysexecutable or _(b"unknown"), | 1482 pycompat.sysexecutable or _(b"unknown"), |
1477 ) | 1483 ) |
1481 (b"%d.%d.%d" % sys.version_info[:3]), | 1487 (b"%d.%d.%d" % sys.version_info[:3]), |
1482 ) | 1488 ) |
1483 fm.write( | 1489 fm.write( |
1484 b'pythonlib', | 1490 b'pythonlib', |
1485 _(b"checking Python lib (%s)...\n"), | 1491 _(b"checking Python lib (%s)...\n"), |
1486 os.path.dirname(pycompat.fsencode(os.__file__)), | 1492 pythonlib or _(b"unknown"), |
1487 ) | 1493 ) |
1488 | 1494 |
1489 security = set(sslutil.supportedprotocols) | 1495 security = set(sslutil.supportedprotocols) |
1490 if sslutil.hassni: | 1496 if sslutil.hassni: |
1491 security.add(b'sni') | 1497 security.add(b'sni') |
1525 _(b"checking Mercurial custom build (%s)\n"), | 1531 _(b"checking Mercurial custom build (%s)\n"), |
1526 b'+'.join(hgver.split(b'+')[1:]), | 1532 b'+'.join(hgver.split(b'+')[1:]), |
1527 ) | 1533 ) |
1528 | 1534 |
1529 # compiled modules | 1535 # compiled modules |
1536 hgmodules = None | |
1537 if util.safehasattr(sys.modules[__name__], '__file__'): | |
1538 hgmodules = os.path.dirname(pycompat.fsencode(__file__)) | |
1539 elif getattr(sys, 'oxidized', False): | |
1540 hgmodules = pycompat.sysexecutable | |
1541 | |
1530 fm.write( | 1542 fm.write( |
1531 b'hgmodulepolicy', _(b"checking module policy (%s)\n"), policy.policy | 1543 b'hgmodulepolicy', _(b"checking module policy (%s)\n"), policy.policy |
1532 ) | 1544 ) |
1533 fm.write( | 1545 fm.write( |
1534 b'hgmodules', | 1546 b'hgmodules', |
1535 _(b"checking installed modules (%s)...\n"), | 1547 _(b"checking installed modules (%s)...\n"), |
1536 os.path.dirname(pycompat.fsencode(__file__)), | 1548 hgmodules or _(b"unknown"), |
1537 ) | 1549 ) |
1538 | 1550 |
1539 rustandc = policy.policy in (b'rust+c', b'rust+c-allow') | 1551 rustandc = policy.policy in (b'rust+c', b'rust+c-allow') |
1540 rustext = rustandc # for now, that's the only case | 1552 rustext = rustandc # for now, that's the only case |
1541 cext = policy.policy in (b'c', b'allow') or rustandc | 1553 cext = policy.policy in (b'c', b'allow') or rustandc |