comparison mercurial/extensions.py @ 52399:89126d55e18c

extensions: stop using the `pycompat.open()` shim
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 04 Dec 2024 20:57:35 -0500
parents f4733654f144
children f106d0e629e5
comparison
equal deleted inserted replaced
52398:c9baa3541b20 52399:89126d55e18c
16 import sys 16 import sys
17 17
18 from .i18n import ( 18 from .i18n import (
19 _, 19 _,
20 gettext, 20 gettext,
21 )
22 from .pycompat import (
23 open,
24 ) 21 )
25 22
26 from . import ( 23 from . import (
27 cmdutil, 24 cmdutil,
28 configitems, 25 configitems,
803 800
804 801
805 def _disabledhelp(path): 802 def _disabledhelp(path):
806 '''retrieve help synopsis of a disabled extension (without importing)''' 803 '''retrieve help synopsis of a disabled extension (without importing)'''
807 try: 804 try:
808 with open(path, b'rb') as src: 805 with open(path, 'rb') as src:
809 doc = _moduledoc(src) 806 doc = _moduledoc(src)
810 except IOError: 807 except IOError:
811 return 808 return
812 809
813 if doc: # extracting localized synopsis 810 if doc: # extracting localized synopsis
886 def _disabledcmdtable(path): 883 def _disabledcmdtable(path):
887 """Construct a dummy command table without loading the extension module 884 """Construct a dummy command table without loading the extension module
888 885
889 This may raise IOError or SyntaxError. 886 This may raise IOError or SyntaxError.
890 """ 887 """
891 with open(path, b'rb') as src: 888 with open(path, 'rb') as src:
892 root = ast.parse(src.read(), path) 889 root = ast.parse(src.read(), path)
893 cmdtable = {} 890 cmdtable = {}
894 891
895 # Python 3.12 started removing Bytes and Str and deprecate harder 892 # Python 3.12 started removing Bytes and Str and deprecate harder
896 use_constant = 'Bytes' not in vars(ast) 893 use_constant = 'Bytes' not in vars(ast)