[ovs-dev] [gc 01/13] python/ovs/ovsuuid: Fix behavior of UUID.from_json() with no symbol table.
Ethan Jackson
ethan at nicira.com
Wed Mar 2 19:14:50 UTC 2011
Looks Good.
On Tue, Mar 1, 2011 at 2:19 PM, Ben Pfaff <blp at nicira.com> wrote:
> UUID.from_json(['named-uuid', 'x'], None) should raise an error about
> invalid syntax, but instead it was raising a TypeError because it would
> try to evaluate "'x' not in None". This fixes the problem and adds a test.
> ---
> python/ovs/ovsuuid.py | 4 +++-
> tests/ovsdb-data.at | 4 ++++
> 2 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/python/ovs/ovsuuid.py b/python/ovs/ovsuuid.py
> index 98c65f3..8a76d3a 100644
> --- a/python/ovs/ovsuuid.py
> +++ b/python/ovs/ovsuuid.py
> @@ -1,4 +1,4 @@
> -# Copyright (c) 2009, 2010 Nicira Networks
> +# Copyright (c) 2009, 2010, 2011 Nicira Networks
> #
> # Licensed under the Apache License, Version 2.0 (the "License");
> # you may not use this file except in compliance with the License.
> @@ -51,6 +51,8 @@ class UUID(uuid.UUID):
> raise error.Error("\"%s\" is not a valid UUID" % s, json)
> return UUID(s)
> except error.Error, e:
> + if not symtab:
> + raise e
> try:
> name = ovs.db.parser.unwrap_json(json, "named-uuid", unicode)
> except error.Error:
> diff --git a/tests/ovsdb-data.at b/tests/ovsdb-data.at
> index 9736961..d45e07b 100644
> --- a/tests/ovsdb-data.at
> +++ b/tests/ovsdb-data.at
> @@ -260,6 +260,10 @@ OVSDB_CHECK_POSITIVE_CPY([uuid atom must be expressed as JSON array],
> [[parse-atoms '["uuid"]' '["550e8400-e29b-41d4-a716-446655440000"]']],
> [[syntax ""550e8400-e29b-41d4-a716-446655440000"": syntax error: expected ["uuid", <string>]]])
>
> +OVSDB_CHECK_POSITIVE_CPY([named-uuid requires symbol table],
> + [parse-atoms '[["uuid"]]' '[["named-uuid", "x"]]'],
> + [[syntax "["named-uuid","x"]": syntax error: expected ["uuid", <string>]]])
> +
> OVSDB_CHECK_NEGATIVE([empty string atom must be quoted],
> [[parse-atom-strings '["string"]' '']],
> [An empty string is not valid as input; use "" to represent the empty string])
> --
> 1.7.1
>
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org
>
More information about the dev
mailing list