[et-mgmt-tools] [PATCH]: give a sensible diagnostic for an empty name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Dan,

I noticed that get_name doesn't diagnose an empty name properly.
Instead, it says it must not be numeric only.

	Give a sensible diagnostic for an empty name.
	Even though the code now detects an empty name early, don't let
	subsequent tests for digit-only and non-alphanumeric names match
	on an empty name.

diff -r 982e9920511c -r c97207424b57 virtinst/Guest.py
--- a/virtinst/Guest.py	Wed Feb 21 11:42:53 2007 -0500
+++ b/virtinst/Guest.py	Fri Feb 23 14:42:50 2007 +0100
@@ -243,9 +243,11 @@ class Guest(object):
     def get_name(self):
         return self._name
     def set_name(self, val):
-        if re.match("^[0-9]*$", val):
+        if len(val) == 0:
+            raise ValueError, "Domain name must be nonempty"
+        if re.match("^[0-9]+$", val):
             raise ValueError, "Domain name must not be numeric only"
-        if re.match("^[a-zA-Z0-9_]*$", val) == None:
+        if re.match("^[a-zA-Z0-9_]+$", val) == None:
             raise ValueError, "Domain name must be alphanumeric or _"
         if len(val) > 50:
             raise ValueError, "Domain name must be less than 50 characters"


[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux