mandatory or type error raised
This commit is contained in:
parent
c6ad86bd81
commit
e2bcac1c01
|
@ -1,258 +1,258 @@
|
|||
#just a proof of concept with a lot of options and option groups
|
||||
import autopath
|
||||
from tiramisu.config import *
|
||||
from tiramisu.option import *
|
||||
##just a proof of concept with a lot of options and option groups
|
||||
#import autopath
|
||||
#from tiramisu.config import *
|
||||
#from tiramisu.option import *
|
||||
|
||||
all_modules = ['amon', 'sphynx', 'zephir']
|
||||
#all_modules = ['amon', 'sphynx', 'zephir']
|
||||
|
||||
example__optiondescription = OptionDescription("objspace", "Object Space Options", [
|
||||
ChoiceOption("name", "Object Space name",
|
||||
["std", "flow", "thunk", "dump", "taint"],
|
||||
"std"),
|
||||
#example__optiondescription = OptionDescription("objspace", "Object Space Options", [
|
||||
# ChoiceOption("name", "Object Space name",
|
||||
# ["std", "flow", "thunk", "dump", "taint"],
|
||||
# "std"),
|
||||
|
||||
OptionDescription("opcodes", "opcodes to enable in the interpreter", [
|
||||
BoolOption("CALL_LIKELY_BUILTIN", "emit a special bytecode for likely calls to builtin functions",
|
||||
default=False,
|
||||
requires=[("translation.stackless", False)]),
|
||||
BoolOption("CALL_METHOD", "emit a special bytecode for expr.name()",
|
||||
default=False),
|
||||
]),
|
||||
# OptionDescription("opcodes", "opcodes to enable in the interpreter", [
|
||||
# BoolOption("CALL_LIKELY_BUILTIN", "emit a special bytecode for likely calls to builtin functions",
|
||||
# default=False,
|
||||
# requires=[("translation.stackless", False)]),
|
||||
# BoolOption("CALL_METHOD", "emit a special bytecode for expr.name()",
|
||||
# default=False),
|
||||
# ]),
|
||||
|
||||
BoolOption("nofaking", "disallow faking in the object space",
|
||||
default=False,
|
||||
requires=[
|
||||
("objspace.usemodules.posix", True),
|
||||
("objspace.usemodules.time", True),
|
||||
("objspace.usemodules.errno", True)],
|
||||
),
|
||||
# BoolOption("nofaking", "disallow faking in the object space",
|
||||
# default=False,
|
||||
# requires=[
|
||||
# ("objspace.usemodules.posix", True),
|
||||
# ("objspace.usemodules.time", True),
|
||||
# ("objspace.usemodules.errno", True)],
|
||||
# ),
|
||||
|
||||
OptionDescription("usemodules", "Which Modules should be used", [
|
||||
BoolOption(modname, "use module %s" % (modname, ),
|
||||
default=True,
|
||||
requires= ['amon'],
|
||||
)
|
||||
for modname in all_modules]),
|
||||
# OptionDescription("usemodules", "Which Modules should be used", [
|
||||
# BoolOption(modname, "use module %s" % (modname, ),
|
||||
# default=True,
|
||||
# requires= [('amon', False)],
|
||||
# )
|
||||
# for modname in all_modules]),
|
||||
|
||||
BoolOption("allworkingmodules", "use as many working modules as possible",
|
||||
default=True,
|
||||
),
|
||||
# BoolOption("allworkingmodules", "use as many working modules as possible",
|
||||
# default=True,
|
||||
# ),
|
||||
|
||||
BoolOption("translationmodules",
|
||||
"use only those modules that are needed to run translate.py on pypy",
|
||||
default=False,
|
||||
),
|
||||
# BoolOption("translationmodules",
|
||||
# "use only those modules that are needed to run translate.py on pypy",
|
||||
# default=False,
|
||||
# ),
|
||||
|
||||
BoolOption("geninterp", "specify whether geninterp should be used",
|
||||
default=True),
|
||||
# BoolOption("geninterp", "specify whether geninterp should be used",
|
||||
# default=True),
|
||||
|
||||
BoolOption("logbytecodes",
|
||||
"keep track of bytecode usage",
|
||||
default=False),
|
||||
# BoolOption("logbytecodes",
|
||||
# "keep track of bytecode usage",
|
||||
# default=False),
|
||||
|
||||
BoolOption("usepycfiles", "Write and read pyc files when importing",
|
||||
default=True),
|
||||
# BoolOption("usepycfiles", "Write and read pyc files when importing",
|
||||
# default=True),
|
||||
|
||||
BoolOption("lonepycfiles", "Import pyc files with no matching py file",
|
||||
default=False,
|
||||
requires=[("objspace.usepycfiles", True)]),
|
||||
# BoolOption("lonepycfiles", "Import pyc files with no matching py file",
|
||||
# default=False,
|
||||
# requires=[("objspace.usepycfiles", True)]),
|
||||
|
||||
StrOption("soabi",
|
||||
"Tag to differentiate extension modules built for different Python interpreters",
|
||||
default=None),
|
||||
# StrOption("soabi",
|
||||
# "Tag to differentiate extension modules built for different Python interpreters",
|
||||
# default=None),
|
||||
|
||||
BoolOption("honor__builtins__",
|
||||
"Honor the __builtins__ key of a module dictionary",
|
||||
default=False),
|
||||
# BoolOption("honor__builtins__",
|
||||
# "Honor the __builtins__ key of a module dictionary",
|
||||
# default=False),
|
||||
|
||||
BoolOption("disable_call_speedhacks",
|
||||
"make sure that all calls go through space.call_args",
|
||||
default=False),
|
||||
# BoolOption("disable_call_speedhacks",
|
||||
# "make sure that all calls go through space.call_args",
|
||||
# default=False),
|
||||
|
||||
BoolOption("timing",
|
||||
"timing of various parts of the interpreter (simple profiling)",
|
||||
default=False),
|
||||
# BoolOption("timing",
|
||||
# "timing of various parts of the interpreter (simple profiling)",
|
||||
# default=False),
|
||||
|
||||
OptionDescription("std", "Standard Object Space Options", [
|
||||
BoolOption("withtproxy", "support transparent proxies",
|
||||
default=True),
|
||||
# OptionDescription("std", "Standard Object Space Options", [
|
||||
# BoolOption("withtproxy", "support transparent proxies",
|
||||
# default=True),
|
||||
|
||||
BoolOption("withsmallint", "use tagged integers",
|
||||
default=False,
|
||||
requires=[("objspace.std.withprebuiltint", False),
|
||||
("translation.taggedpointers", True)]),
|
||||
# BoolOption("withsmallint", "use tagged integers",
|
||||
# default=False,
|
||||
# requires=[("objspace.std.withprebuiltint", False),
|
||||
# ("translation.taggedpointers", True)]),
|
||||
|
||||
BoolOption("withprebuiltint", "prebuild commonly used int objects",
|
||||
default=False),
|
||||
# BoolOption("withprebuiltint", "prebuild commonly used int objects",
|
||||
# default=False),
|
||||
|
||||
IntOption("prebuiltintfrom", "lowest integer which is prebuilt",
|
||||
default=-5),
|
||||
# IntOption("prebuiltintfrom", "lowest integer which is prebuilt",
|
||||
# default=-5),
|
||||
|
||||
IntOption("prebuiltintto", "highest integer which is prebuilt",
|
||||
default=100),
|
||||
# IntOption("prebuiltintto", "highest integer which is prebuilt",
|
||||
# default=100),
|
||||
|
||||
BoolOption("withstrjoin", "use strings optimized for addition",
|
||||
default=False),
|
||||
# BoolOption("withstrjoin", "use strings optimized for addition",
|
||||
# default=False),
|
||||
|
||||
BoolOption("withstrslice", "use strings optimized for slicing",
|
||||
default=False),
|
||||
# BoolOption("withstrslice", "use strings optimized for slicing",
|
||||
# default=False),
|
||||
|
||||
BoolOption("withstrbuf", "use strings optimized for addition (ver 2)",
|
||||
default=False),
|
||||
# BoolOption("withstrbuf", "use strings optimized for addition (ver 2)",
|
||||
# default=False),
|
||||
|
||||
BoolOption("withprebuiltchar",
|
||||
"use prebuilt single-character string objects",
|
||||
default=False),
|
||||
# BoolOption("withprebuiltchar",
|
||||
# "use prebuilt single-character string objects",
|
||||
# default=False),
|
||||
|
||||
BoolOption("sharesmallstr",
|
||||
"always reuse the prebuilt string objects "
|
||||
"(the empty string and potentially single-char strings)",
|
||||
default=False),
|
||||
# BoolOption("sharesmallstr",
|
||||
# "always reuse the prebuilt string objects "
|
||||
# "(the empty string and potentially single-char strings)",
|
||||
# default=False),
|
||||
|
||||
BoolOption("withrope", "use ropes as the string implementation",
|
||||
default=False,
|
||||
requires=[("objspace.std.withstrslice", False),
|
||||
("objspace.std.withstrjoin", False),
|
||||
("objspace.std.withstrbuf", False)],
|
||||
),
|
||||
# BoolOption("withrope", "use ropes as the string implementation",
|
||||
# default=False,
|
||||
# requires=[("objspace.std.withstrslice", False),
|
||||
# ("objspace.std.withstrjoin", False),
|
||||
# ("objspace.std.withstrbuf", False)],
|
||||
# ),
|
||||
|
||||
BoolOption("withropeunicode", "use ropes for the unicode implementation",
|
||||
default=False,
|
||||
requires=[("objspace.std.withrope", True)]),
|
||||
# BoolOption("withropeunicode", "use ropes for the unicode implementation",
|
||||
# default=False,
|
||||
# requires=[("objspace.std.withrope", True)]),
|
||||
|
||||
BoolOption("withcelldict",
|
||||
"use dictionaries that are optimized for being used as module dicts",
|
||||
default=False,
|
||||
requires=[("objspace.opcodes.CALL_LIKELY_BUILTIN", False),
|
||||
("objspace.honor__builtins__", False)]),
|
||||
# BoolOption("withcelldict",
|
||||
# "use dictionaries that are optimized for being used as module dicts",
|
||||
# default=False,
|
||||
# requires=[("objspace.opcodes.CALL_LIKELY_BUILTIN", False),
|
||||
# ("objspace.honor__builtins__", False)]),
|
||||
|
||||
BoolOption("withdictmeasurement",
|
||||
"create huge files with masses of information "
|
||||
"about dictionaries",
|
||||
default=False),
|
||||
# BoolOption("withdictmeasurement",
|
||||
# "create huge files with masses of information "
|
||||
# "about dictionaries",
|
||||
# default=False),
|
||||
|
||||
BoolOption("withmapdict",
|
||||
"make instances really small but slow without the JIT",
|
||||
default=False,
|
||||
requires=[("objspace.std.getattributeshortcut", True),
|
||||
("objspace.std.withtypeversion", True),
|
||||
]),
|
||||
# BoolOption("withmapdict",
|
||||
# "make instances really small but slow without the JIT",
|
||||
# default=False,
|
||||
# requires=[("objspace.std.getattributeshortcut", True),
|
||||
# ("objspace.std.withtypeversion", True),
|
||||
# ]),
|
||||
|
||||
BoolOption("withrangelist",
|
||||
"enable special range list implementation that does not "
|
||||
"actually create the full list until the resulting "
|
||||
"list is mutated",
|
||||
default=False),
|
||||
# BoolOption("withrangelist",
|
||||
# "enable special range list implementation that does not "
|
||||
# "actually create the full list until the resulting "
|
||||
# "list is mutated",
|
||||
# default=False),
|
||||
|
||||
BoolOption("withtypeversion",
|
||||
"version type objects when changing them",
|
||||
default=False,
|
||||
# weakrefs needed, because of get_subclasses()
|
||||
requires=[("translation.rweakref", True)]),
|
||||
# BoolOption("withtypeversion",
|
||||
# "version type objects when changing them",
|
||||
# default=False,
|
||||
# # weakrefs needed, because of get_subclasses()
|
||||
# requires=[("translation.rweakref", True)]),
|
||||
|
||||
BoolOption("withmethodcache",
|
||||
"try to cache method lookups",
|
||||
default=False,
|
||||
requires=[("objspace.std.withtypeversion", True),
|
||||
("translation.rweakref", True)]),
|
||||
BoolOption("withmethodcachecounter",
|
||||
"try to cache methods and provide a counter in __pypy__. "
|
||||
"for testing purposes only.",
|
||||
default=False,
|
||||
requires=[("objspace.std.withmethodcache", True)]),
|
||||
IntOption("methodcachesizeexp",
|
||||
" 2 ** methodcachesizeexp is the size of the of the method cache ",
|
||||
default=11),
|
||||
BoolOption("optimized_int_add",
|
||||
"special case the addition of two integers in BINARY_ADD",
|
||||
default=False),
|
||||
BoolOption("optimized_comparison_op",
|
||||
"special case the comparison of integers",
|
||||
default=False),
|
||||
BoolOption("optimized_list_getitem",
|
||||
"special case the 'list[integer]' expressions",
|
||||
default=False),
|
||||
BoolOption("builtinshortcut",
|
||||
"a shortcut for operations between built-in types",
|
||||
default=False),
|
||||
BoolOption("getattributeshortcut",
|
||||
"track types that override __getattribute__",
|
||||
default=False),
|
||||
BoolOption("newshortcut",
|
||||
"cache and shortcut calling __new__ from builtin types",
|
||||
default=False),
|
||||
# BoolOption("withmethodcache",
|
||||
# "try to cache method lookups",
|
||||
# default=False,
|
||||
# requires=[("objspace.std.withtypeversion", True),
|
||||
# ("translation.rweakref", True)]),
|
||||
# BoolOption("withmethodcachecounter",
|
||||
# "try to cache methods and provide a counter in __pypy__. "
|
||||
# "for testing purposes only.",
|
||||
# default=False,
|
||||
# requires=[("objspace.std.withmethodcache", True)]),
|
||||
# IntOption("methodcachesizeexp",
|
||||
# " 2 ** methodcachesizeexp is the size of the of the method cache ",
|
||||
# default=11),
|
||||
# BoolOption("optimized_int_add",
|
||||
# "special case the addition of two integers in BINARY_ADD",
|
||||
# default=False),
|
||||
# BoolOption("optimized_comparison_op",
|
||||
# "special case the comparison of integers",
|
||||
# default=False),
|
||||
# BoolOption("optimized_list_getitem",
|
||||
# "special case the 'list[integer]' expressions",
|
||||
# default=False),
|
||||
# BoolOption("builtinshortcut",
|
||||
# "a shortcut for operations between built-in types",
|
||||
# default=False),
|
||||
# BoolOption("getattributeshortcut",
|
||||
# "track types that override __getattribute__",
|
||||
# default=False),
|
||||
# BoolOption("newshortcut",
|
||||
# "cache and shortcut calling __new__ from builtin types",
|
||||
# default=False),
|
||||
|
||||
BoolOption("logspaceoptypes",
|
||||
"a instrumentation option: before exit, print the types seen by "
|
||||
"certain simpler bytecodes",
|
||||
default=False),
|
||||
ChoiceOption("multimethods", "the multimethod implementation to use",
|
||||
["doubledispatch", "mrd"],
|
||||
default="mrd"),
|
||||
BoolOption("immutable_builtintypes",
|
||||
"Forbid the changing of builtin types", default=True),
|
||||
]),
|
||||
])
|
||||
# BoolOption("logspaceoptypes",
|
||||
# "a instrumentation option: before exit, print the types seen by "
|
||||
# "certain simpler bytecodes",
|
||||
# default=False),
|
||||
# ChoiceOption("multimethods", "the multimethod implementation to use",
|
||||
# ["doubledispatch", "mrd"],
|
||||
# default="mrd"),
|
||||
# BoolOption("immutable_builtintypes",
|
||||
# "Forbid the changing of builtin types", default=True),
|
||||
# ]),
|
||||
#])
|
||||
|
||||
# ____________________________________________________________
|
||||
## ____________________________________________________________
|
||||
|
||||
def get_combined_translation_config(other_optdescr=None,
|
||||
existing_config=None,
|
||||
overrides=None,
|
||||
translating=False):
|
||||
if overrides is None:
|
||||
overrides = {}
|
||||
d = BoolOption("translating",
|
||||
"indicates whether we are translating currently",
|
||||
default=False)
|
||||
if other_optdescr is None:
|
||||
children = []
|
||||
newname = ""
|
||||
else:
|
||||
children = [other_optdescr]
|
||||
newname = other_optdescr._name
|
||||
descr = OptionDescription("eole", "all options", children)
|
||||
config = Config(descr, **overrides)
|
||||
if translating:
|
||||
config.translating = True
|
||||
if existing_config is not None:
|
||||
for child in existing_config._cfgimpl_descr._children:
|
||||
if child._name == newname:
|
||||
continue
|
||||
value = getattr(existing_config, child._name)
|
||||
config._cfgimpl_values[child._name] = value
|
||||
return config
|
||||
#def get_combined_translation_config(other_optdescr=None,
|
||||
# existing_config=None,
|
||||
# overrides=None,
|
||||
# translating=False):
|
||||
# if overrides is None:
|
||||
# overrides = {}
|
||||
# d = BoolOption("translating",
|
||||
# "indicates whether we are translating currently",
|
||||
# default=False)
|
||||
# if other_optdescr is None:
|
||||
# children = []
|
||||
# newname = ""
|
||||
# else:
|
||||
# children = [other_optdescr]
|
||||
# newname = other_optdescr._name
|
||||
# descr = OptionDescription("eole", "all options", children)
|
||||
# config = Config(descr, **overrides)
|
||||
# if translating:
|
||||
# config.translating = True
|
||||
# if existing_config is not None:
|
||||
# for child in existing_config._cfgimpl_descr._children:
|
||||
# if child._name == newname:
|
||||
# continue
|
||||
# value = getattr(existing_config, child._name)
|
||||
# config._cfgimpl_values[child._name] = value
|
||||
# return config
|
||||
|
||||
def get_example_config(overrides=None, translating=False):
|
||||
return get_combined_translation_config(
|
||||
example__optiondescription, overrides=overrides,
|
||||
translating=translating)
|
||||
#def get_example_config(overrides=None, translating=False):
|
||||
# return get_combined_translation_config(
|
||||
# example__optiondescription, overrides=overrides,
|
||||
# translating=translating)
|
||||
|
||||
# ____________________________________________________________
|
||||
## ____________________________________________________________
|
||||
|
||||
def test_example_option():
|
||||
config = get_example_config()
|
||||
result = ['objspace.name', 'objspace.opcodes.CALL_LIKELY_BUILTIN',
|
||||
'objspace.opcodes.CALL_METHOD', 'objspace.nofaking',
|
||||
'objspace.usemodules.amon', 'objspace.usemodules.sphynx',
|
||||
'objspace.usemodules.zephir', 'objspace.allworkingmodules',
|
||||
'objspace.translationmodules', 'objspace.geninterp',
|
||||
'objspace.logbytecodes', 'objspace.usepycfiles', 'objspace.lonepycfiles',
|
||||
'objspace.soabi', 'objspace.honor__builtins__',
|
||||
'objspace.disable_call_speedhacks', 'objspace.timing',
|
||||
'objspace.std.withtproxy', 'objspace.std.withsmallint',
|
||||
'objspace.std.withprebuiltint', 'objspace.std.prebuiltintfrom',
|
||||
'objspace.std.prebuiltintto', 'objspace.std.withstrjoin',
|
||||
'objspace.std.withstrslice', 'objspace.std.withstrbuf',
|
||||
'objspace.std.withprebuiltchar', 'objspace.std.sharesmallstr',
|
||||
'objspace.std.withrope', 'objspace.std.withropeunicode',
|
||||
'objspace.std.withcelldict', 'objspace.std.withdictmeasurement',
|
||||
'objspace.std.withmapdict', 'objspace.std.withrangelist',
|
||||
'objspace.std.withtypeversion', 'objspace.std.withmethodcache',
|
||||
'objspace.std.withmethodcachecounter', 'objspace.std.methodcachesizeexp',
|
||||
'objspace.std.optimized_int_add', 'objspace.std.optimized_comparison_op',
|
||||
'objspace.std.optimized_list_getitem', 'objspace.std.builtinshortcut',
|
||||
'objspace.std.getattributeshortcut', 'objspace.std.newshortcut',
|
||||
'objspace.std.logspaceoptypes', 'objspace.std.multimethods',
|
||||
'objspace.std.immutable_builtintypes']
|
||||
#def test_example_option():
|
||||
# config = get_example_config()
|
||||
# result = ['objspace.name', 'objspace.opcodes.CALL_LIKELY_BUILTIN',
|
||||
# 'objspace.opcodes.CALL_METHOD', 'objspace.nofaking',
|
||||
# 'objspace.usemodules.amon', 'objspace.usemodules.sphynx',
|
||||
# 'objspace.usemodules.zephir', 'objspace.allworkingmodules',
|
||||
# 'objspace.translationmodules', 'objspace.geninterp',
|
||||
# 'objspace.logbytecodes', 'objspace.usepycfiles', 'objspace.lonepycfiles',
|
||||
# 'objspace.soabi', 'objspace.honor__builtins__',
|
||||
# 'objspace.disable_call_speedhacks', 'objspace.timing',
|
||||
# 'objspace.std.withtproxy', 'objspace.std.withsmallint',
|
||||
# 'objspace.std.withprebuiltint', 'objspace.std.prebuiltintfrom',
|
||||
# 'objspace.std.prebuiltintto', 'objspace.std.withstrjoin',
|
||||
# 'objspace.std.withstrslice', 'objspace.std.withstrbuf',
|
||||
# 'objspace.std.withprebuiltchar', 'objspace.std.sharesmallstr',
|
||||
# 'objspace.std.withrope', 'objspace.std.withropeunicode',
|
||||
# 'objspace.std.withcelldict', 'objspace.std.withdictmeasurement',
|
||||
# 'objspace.std.withmapdict', 'objspace.std.withrangelist',
|
||||
# 'objspace.std.withtypeversion', 'objspace.std.withmethodcache',
|
||||
# 'objspace.std.withmethodcachecounter', 'objspace.std.methodcachesizeexp',
|
||||
# 'objspace.std.optimized_int_add', 'objspace.std.optimized_comparison_op',
|
||||
# 'objspace.std.optimized_list_getitem', 'objspace.std.builtinshortcut',
|
||||
# 'objspace.std.getattributeshortcut', 'objspace.std.newshortcut',
|
||||
# 'objspace.std.logspaceoptypes', 'objspace.std.multimethods',
|
||||
# 'objspace.std.immutable_builtintypes']
|
||||
|
||||
assert config.getpaths(allpaths=True) == result
|
||||
# assert config.getpaths(allpaths=True) == result
|
||||
|
|
|
@ -71,15 +71,16 @@ def test_has_callback():
|
|||
# here the owner is 'default'
|
||||
config = Config(descr, bool=False)
|
||||
# because dummy has a callback
|
||||
raises(ConflictConfigError, "config.gc.dummy = True")
|
||||
raises(TypeError, "config.gc.dummy = True")
|
||||
|
||||
#____________________________________________________________
|
||||
def test_has_callback_with_setoption():
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
raises(ConflictConfigError, "config.gc.setoption('dummy', True, 'gen_config')")
|
||||
raises(TypeError, "config.gc.setoption('dummy', True, 'gen_config')")
|
||||
|
||||
def test_cannot_override_special_owners():
|
||||
def test_cannot_override():
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
raises(ConflictConfigError, "config.override({'gc.dummy': True})")
|
||||
raises(TypeError, "config.override({'gc.dummy': True})")
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ def test_freeze_one_option():
|
|||
#freeze only one option
|
||||
conf.gc._cfgimpl_descr.dummy.freeze()
|
||||
assert conf.gc.dummy == False
|
||||
raises(ConflictConfigError, "conf.gc.dummy = True")
|
||||
raises(TypeError, "conf.gc.dummy = True")
|
||||
|
||||
def test_frozen_value():
|
||||
"setattr a frozen value at the config level"
|
||||
|
@ -75,14 +75,14 @@ def test_frozen_value():
|
|||
descr = OptionDescription("options", "", [s])
|
||||
config = Config(descr)
|
||||
s.freeze()
|
||||
raises(ConfigError, 'config.string = "egg"')
|
||||
raises(TypeError, 'config.string = "egg"')
|
||||
|
||||
def test_freeze():
|
||||
"freeze a whole configuration object"
|
||||
descr = make_description()
|
||||
conf = Config(descr)
|
||||
conf.cfgimpl_freeze()
|
||||
raises(ConfigError, "conf.gc.name = 'try to modify'")
|
||||
raises(TypeError, "conf.gc.name = 'try to modify'")
|
||||
# ____________________________________________________________
|
||||
def test_is_hidden():
|
||||
descr = make_description()
|
||||
|
|
|
@ -189,10 +189,10 @@ class Config(object):
|
|||
if self.is_frozen() and getattr(self, name) != value:
|
||||
raise TypeError("trying to change a value in a frozen config"
|
||||
": {0} {1}".format(name, value))
|
||||
if self.is_mandatory() and value == None:
|
||||
raise MandatoryError("trying to reset option: {0} wich lives in a"
|
||||
" mandatory group: {1}".format(name,
|
||||
self._cfgimpl_descr._name))
|
||||
# if self.is_mandatory() and value == None:
|
||||
# raise MandatoryError("trying to reset option: {0} wich lives in a"
|
||||
# " mandatory group: {1}".format(name,
|
||||
# self._cfgimpl_descr._name))
|
||||
if type(getattr(self._cfgimpl_descr, name)) != SymLinkOption:
|
||||
self._validate(name, getattr(self._cfgimpl_descr, name))
|
||||
self.setoption(name, value, self._cfgimpl_owner)
|
||||
|
|
|
@ -190,12 +190,11 @@ class Option(HiddenBaseType, DisabledBaseType):
|
|||
def setoption(self, config, value, who):
|
||||
"who is **not necessarily** a owner because it cannot be a list"
|
||||
name = self._name
|
||||
|
||||
# the value cannot be changed if a callback is defined
|
||||
if self.has_callback():
|
||||
raise TypeError("trying to change an option with callback: %s" % name)
|
||||
# we want the possibility to reset everything
|
||||
if who == "default" and value is None:
|
||||
self.default = None
|
||||
return
|
||||
if not self.validate(value):
|
||||
if not (who == "default" and value is None) and not self.validate(value):
|
||||
raise ConfigError('invalid value %s for option %s' % (value, name))
|
||||
if self.is_mandatory():
|
||||
# value shall not be '' for a mandatory option
|
||||
|
@ -208,6 +207,9 @@ class Option(HiddenBaseType, DisabledBaseType):
|
|||
(not self.is_multi() and value is None)):
|
||||
raise MandatoryError('cannot override value to %s for '
|
||||
'option %s' % (value, name))
|
||||
if who == "default" and value is None:
|
||||
self.default = None
|
||||
return
|
||||
if name not in config._cfgimpl_values:
|
||||
raise AttributeError('unknown option %s' % (name))
|
||||
if config.is_frozen() and (self.has_callback() or self.isfrozen()):
|
||||
|
|
Loading…
Reference in New Issue