bnjones/Mathics — pull request #1 by sn6uv (2014-03-25 03:18:12+00:00)
Title: implement contexts for autoload import/export

I've implemented Packages for the import and export code. It doesn't seem to be working properly though.

When I try running this the Mathics interpreter fails to start:

Traceback (most recent call last):
File "mathics/main.py", line 277, in
main()
File "mathics/main.py", line 220, in main
definitions = Definitions(add_builtin=True)
File "/home/angus/Mathics/mathics/core/definitions.py", line 87, in __init__
Evaluation(stream.read(), self, timeout=30)
File "/home/angus/Mathics/mathics/core/evaluation.py", line 210, in __init__
result = evaluate()
File "/home/angus/Mathics/mathics/core/evaluation.py", line 192, in evaluate
result = query.evaluate(self)
File "/home/angus/Mathics/mathics/core/expression.py", line 770, in evaluate
result = result.evaluate(evaluation)
File "/home/angus/Mathics/mathics/core/expression.py", line 767, in evaluate
result = rule.apply(new, evaluation, fully=False)
File "/home/angus/Mathics/mathics/core/rules.py", line 116, in apply
yield_match, expression, {}, evaluation, fully=fully)
File "/home/angus/Mathics/mathics/core/pattern.py", line 224, in match
yield_head, expression.get_head(), vars, evaluation)
File "/home/angus/Mathics/mathics/core/pattern.py", line 152, in match
yield_func(vars, None)
File "/home/angus/Mathics/mathics/core/pattern.py", line 216, in yield_head
yield_choice, expression, attributes, head_vars)
File "/home/angus/Mathics/mathics/core/pattern.py", line 340, in get_pre_choices
yield_func(vars)
File "/home/angus/Mathics/mathics/core/pattern.py", line 205, in yield_choice
wrap_oneid=expression.get_head_name() != 'System`MakeBoxes')
File "/home/angus/Mathics/mathics/core/pattern.py", line 506, in match_leaf
include_flattened=include_flattened)
File "/home/angus/Mathics/mathics/core/pattern.py", line 360, in get_wrappings
yield_func(items[0])
File "/home/angus/Mathics/mathics/core/pattern.py", line 502, in yield_wrapping
leaf_count=leaf_count, wrap_oneid=wrap_oneid)
File "/home/angus/Mathics/mathics/builtin/patterns.py", line 539, in match
self.pattern.match(yield_func, expression, new_vars, evaluation)
File "/home/angus/Mathics/mathics/builtin/patterns.py", line 701, in match
yield_func(vars, None)
File "/home/angus/Mathics/mathics/core/pattern.py", line 494, in match_yield
leaf_count=leaf_count, wrap_oneid=wrap_oneid)
File "/home/angus/Mathics/mathics/core/pattern.py", line 506, in match_leaf
include_flattened=include_flattened)
File "/home/angus/Mathics/mathics/core/pattern.py", line 360, in get_wrappings
yield_func(items[0])
File "/home/angus/Mathics/mathics/core/pattern.py", line 502, in yield_wrapping
leaf_count=leaf_count, wrap_oneid=wrap_oneid)
File "/home/angus/Mathics/mathics/builtin/patterns.py", line 539, in match
self.pattern.match(yield_func, expression, new_vars, evaluation)
File "/home/angus/Mathics/mathics/builtin/patterns.py", line 701, in match
yield_func(vars, None)
File "/home/angus/Mathics/mathics/core/pattern.py", line 497, in match_yield
yield_func(new_vars, items_rest)
File "/home/angus/Mathics/mathics/core/pattern.py", line 486, in leaf_yield
(rest_expression[0] + items_rest[0], next_rest[1]))
File "/home/angus/Mathics/mathics/core/rules.py", line 74, in yield_match
new_expression = self.do_replace(vars, options, evaluation)
File "/home/angus/Mathics/mathics/core/rules.py", line 164, in do_replace
return self.function(evaluation=evaluation, **vars_noctx)
File "/home/angus/Mathics/mathics/builtin/scoping.py", line 102, in apply
result = dynamic_scoping(expr.evaluate, vars, evaluation)
File "/home/angus/Mathics/mathics/builtin/scoping.py", line 43, in dynamic_scoping
evaluation.definitions.reset_user_definition(var_name)
File "/home/angus/Mathics/mathics/core/definitions.py", line 339, in reset_user_definition
del self.user[self.lookup_name(name)]
KeyError: 'System`old'