]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
location-query: Translate family only when it is set
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 9 Dec 2019 17:08:59 +0000 (17:08 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 9 Dec 2019 17:08:59 +0000 (17:08 +0000)
Fixes: #12253
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/location-query.in

index 052befb18f005a6936780a20e38a20f9fc814e63..f22b23e954cdb45c0b631478a16d613e6744e17b 100644 (file)
@@ -223,13 +223,14 @@ class CLI(object):
                                % (args.database, e))
                        sys.exit(1)
 
-               # Translate family
-               if args.family == "ipv6":
-                       args.family = socket.AF_INET6
-               elif args.family == "ipv4":
-                       args.family = socket.AF_INET
-               else:
-                       args.family = 0
+               # Translate family (if present)
+               if "family" in args:
+                       if args.family == "ipv6":
+                               args.family = socket.AF_INET6
+                       elif args.family == "ipv4":
+                               args.family = socket.AF_INET
+                       else:
+                               args.family = 0
 
                # Call function
                ret = args.func(db, args)