LGTM, thanks.

On Tue, Dec 17, 2013 at 10:28 AM, Santi Raffa <[email protected]> wrote:

> PathJoin fails with an unclear message if only one argument is passed
> to it. Calling PathJoin("/foo") causes this exception:
>
>     Error: path joining resulted in different prefix (/foo != /foo)
>
> However, /foo and /foo obviously share prefixes: what this function
> really checks is that the resulting path should be inside the first
> argument and, in that sense, /foo is not a "real" prefix of /foo.
>
> Given that PathJoin already asserts that it received any arguments
> at all, this commit discards the assertion for an error to be raised
> if 0 or 1 arguments are received. The semantics don't change, but
> the error message is clearer.
>
> Signed-off-by: Santi Raffa <[email protected]>
> ---
>  lib/utils/io.py |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/lib/utils/io.py b/lib/utils/io.py
> index 808751c..7d3ff91 100644
> --- a/lib/utils/io.py
> +++ b/lib/utils/io.py
> @@ -681,8 +681,9 @@ def PathJoin(*args):
>    @raise ValueError: for invalid paths
>
>    """
> -  # ensure we're having at least one path passed in
> -  assert args
> +  # ensure we're having at least two paths passed in
> +  if len(args) <= 1:
> +    raise errors.ProgrammerError("PathJoin requires two arguments")
>    # ensure the first component is an absolute and normalized path name
>    root = args[0]
>    if not IsNormAbsPath(root):
> --
> 1.7.10.4
>
>


-- 
Thomas Thrainer | Software Engineer | [email protected] |

Google Germany GmbH
Dienerstr. 12
80331 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores

Reply via email to