Skip to content

Commit

Permalink
don't use ast.literal_eval, just directly convert to the desired type
Browse files Browse the repository at this point in the history
It's slow and unnecessary
  • Loading branch information
qubesuser committed Nov 10, 2017
1 parent 6eb828f commit 10c4c2f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions qubesadmin/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import traceback
import re

import ast
import qubesadmin.exc

DEFAULT = object()
Expand Down Expand Up @@ -260,13 +259,13 @@ def _decode_value(self, value, prop_type):
elif prop_type == 'bool':
if value == '':
raise AttributeError
value = ast.literal_eval(value)
value = value == "True"
elif prop_type == 'int':
if value == '':
value = None # hack for stubdom_mem
#raise AttributeError
else:
value = ast.literal_eval(value)
value = int(value)
elif prop_type == 'vm':
if value == '':
value = None
Expand Down Expand Up @@ -296,7 +295,7 @@ def _update_one(self, item):

assert default.startswith(b'default=')
is_default_str = default.split(b'=')[1]
is_default = ast.literal_eval(is_default_str.decode('ascii'))
is_default = is_default_str.decode('ascii') == "True"
assert isinstance(is_default, bool)

prop_type = prop_type.decode('ascii')
Expand Down

0 comments on commit 10c4c2f

Please sign in to comment.