let conf.define() cast bool and None values to int

This commit is contained in:
Thomas Nagy 2012-06-30 18:15:56 +02:00
parent d2d31c69a0
commit ec3295c1a4
1 changed files with 6 additions and 1 deletions

View File

@ -779,7 +779,7 @@ def check_cc(self, *k, **kw):
@conf
def define(self, key, val, quote=True):
"""
Store a single define and its state into conf.env.DEFINES
Store a single define and its state into conf.env.DEFINES. If the value is True, False or None it is cast to 1 or 0.
:param key: define name
:type key: string
@ -790,6 +790,11 @@ def define(self, key, val, quote=True):
"""
assert key and isinstance(key, str)
if val is True:
val = 1
elif val in (False, None):
val = 0
if isinstance(val, int) or isinstance(val, float):
s = '%s=%s'
else: