[blivet f20/master 1/5] Allow non-ASCII characters in the size spec

David Shea dshea at redhat.com
Fri Nov 22 18:18:59 UTC 2013


---
 blivet/size.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/blivet/size.py b/blivet/size.py
index 6c3eb90..d6a728b 100644
--- a/blivet/size.py
+++ b/blivet/size.py
@@ -75,7 +75,11 @@ def _parseSpec(spec):
     if not spec:
         raise ValueError("invalid size specification", spec)
 
-    m = re.match(r'(-?\s*[0-9.]+)\s*([A-Za-z]*)$', spec.strip())
+    # This regex isn't ideal, since \w matches both letters and digits,
+    # but python doesn't provide a means to match only Unicode letters.
+    # Probably the worst that will come of it is that bad specs will fail
+    # more confusingly.
+    m = re.match(r'(-?\s*[0-9.]+)\s*(\w*)$', spec.decode("utf-8").strip(), flags=re.UNICODE)
     if not m:
         raise ValueError("invalid size specification", spec)
 
-- 
1.8.3.1



More information about the anaconda-patches mailing list