comparison mercurial/hg.py @ 46691:1099541b6462 stable

hg: convert an exception to bytes in the repo creation exception handler Caught by pytype: File "/mnt/c/Users/Matt/hg/mercurial/hg.py", line 77, in _local: Function _bytestr.__init__ was called with the wrong arguments [wrong-arg-types] Expected: (self, ints: Iterable[int]) Actually passed: (self, ints: Union[TypeError, ValueError]) Differential Revision: https://phab.mercurial-scm.org/D10176
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 11 Mar 2021 18:09:55 -0500
parents 95a615dd77bf
children e2f7b2695ba1
comparison
equal deleted inserted replaced
46690:90a92f041fc6 46691:1099541b6462
39 logexchange, 39 logexchange,
40 merge as mergemod, 40 merge as mergemod,
41 mergestate as mergestatemod, 41 mergestate as mergestatemod,
42 narrowspec, 42 narrowspec,
43 phases, 43 phases,
44 pycompat,
45 requirements, 44 requirements,
46 scmutil, 45 scmutil,
47 sshpeer, 46 sshpeer,
48 statichttprepo, 47 statichttprepo,
49 ui as uimod, 48 ui as uimod,
51 url, 50 url,
52 util, 51 util,
53 verify as verifymod, 52 verify as verifymod,
54 vfs as vfsmod, 53 vfs as vfsmod,
55 ) 54 )
56 from .utils import hashutil 55 from .utils import (
56 hashutil,
57 stringutil,
58 )
59
57 60
58 release = lock.release 61 release = lock.release
59 62
60 # shared features 63 # shared features
61 sharedbookmarks = b'bookmarks' 64 sharedbookmarks = b'bookmarks'
72 st = os.stat(path) 75 st = os.stat(path)
73 isfile = stat.S_ISREG(st.st_mode) 76 isfile = stat.S_ISREG(st.st_mode)
74 # Python 2 raises TypeError, Python 3 ValueError. 77 # Python 2 raises TypeError, Python 3 ValueError.
75 except (TypeError, ValueError) as e: 78 except (TypeError, ValueError) as e:
76 raise error.Abort( 79 raise error.Abort(
77 _(b'invalid path %s: %s') % (path, pycompat.bytestr(e)) 80 _(b'invalid path %s: %s') % (path, stringutil.forcebytestr(e))
78 ) 81 )
79 except OSError: 82 except OSError:
80 isfile = False 83 isfile = False
81 84
82 return isfile and bundlerepo or localrepo 85 return isfile and bundlerepo or localrepo