Currently, some os.path functions when opening repositories may
raise an uncaught TypeError or ValueError if the path is invalid.
Let's catch these exceptions and turn them into an Abort for
convenience.
hg-reviewers |
Currently, some os.path functions when opening repositories may
raise an uncaught TypeError or ValueError if the path is invalid.
Let's catch these exceptions and turn them into an Abort for
convenience.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
+ try:
+ isfile = os.path.isfile(path)
+ # Python 2 raises TypeError, Python 3 ValueError.
+ except (TypeError, ValueError) as e:
+ raise error.Abort(_('invalid path %s: %s') % (
+ path, pycompat.bytestr(e)))
I don't know if the path is included in the exception message, but it's
probably safer to use stringutil.forcebytestr(e) to get around possible
UnicodeError.
Currently, some os.path functions when opening repositories may
raise an uncaught TypeError or ValueError if the path is invalid.
What kind of "invalid"? If the path doesn't exist? Or only if the path variable is of the wrong type (not bytes? not unicode? neither?)?
> Currently, some os.path functions when opening repositories may > raise an uncaught TypeError or ValueError if the path is invalid. What kind of "invalid"? If the path doesn't exist? Or only if the path variable is of the wrong type (not bytes? not unicode? neither?)?
It's NUL byte in path string.