# Buggy code
def get_user_requests(self):
    """
    return a list of user requested items.  Each item is a dict with the
    following keys:
    'date': the date and time running the command
    'cmd': a list of argv of the actual command which was run
    'action': install/remove/update
    'specs': the specs being used
    """
    res = []
    com_pat = re.compile(r"#\s*cmd:\s*(.+)")
    spec_pat = re.compile(r"#\s*(\w+)\s*specs:\s*(.+)?")
    for dt, unused_cont, comments in self.parse():
        item = {"date": dt}
        for line in comments:
            m = com_pat.match(line)
            if m:
                argv = m.group(1).split()
                if argv[0].endswith("conda"):
                    argv[0] = "conda"
                item["cmd"] = argv
            m = spec_pat.match(line)
            if m:
                action, specs = m.groups()
                item["action"] = action
                specs = specs or ""
                if specs.startswith("["):
                    specs = literal_eval(specs)
                elif "[" not in specs:
                    specs = specs.split(",")
                specs = [spec for spec in specs if spec and not spec.endswith("@")]
                if specs and action in ("update", "install", "create"):
                    item["update_specs"] = item["specs"] = specs
                elif specs and action in ("remove", "uninstall"):
                    item["remove_specs"] = item["specs"] = specs

        if "cmd" in item:
            res.append(item)
        dists = groupby(itemgetter(0), unused_cont)
        item["unlink_dists"] = dists.get("-", ())
        item["link_dists"] = dists.get("+", ())
    return res


# Traceback (conda.exceptions.CondaValueError)
$ conda --version
conda 4.4.7
$ conda install -vvv numpy
DEBUG conda.gateways.logging:set_verbosity(148): verbosity set to 3
Solving environment: ...working... DEBUG conda.core.solve:solve_final_state(140): solving prefix /scratch/mc3
specs_to_remove: frozenset()
specs_to_add: frozenset({MatchSpec(name=LowerStrMatch('numpy'))})
prune: False
TRACE conda.core.linked_data:_load_single_record(113): loading prefix record /scratch/mc3/conda-meta/appnope-0.1.0-py36hf537a9a_0.json
TRACE conda.core.linked_data:_load_single_record(113): loading prefix record /scratch/mc3/conda-meta/asn1crypto-0.23.0-py36h782d450_0.json
TRACE conda.core.linked_data:_load_single_record(113): loading prefix record /scratch/mc3/conda-meta/bleach-2.1.1-py36h27c13d8_0.json
[...]
TRACE conda.core.linked_data:_load_single_record(113): loading prefix record /scratch/mc3/conda-meta/zeromq-4.2.2-ha360ad0_2.json
TRACE conda.core.linked_data:_load_single_record(113): loading prefix record /scratch/mc3/conda-meta/zlib-1.2.11-hf3cbc9b_2.json
failed
Traceback (most recent call last):
File "/scratch/mc3/lib/python3.6/site-packages/conda/exceptions.py", line 743, in __call__
return func(*args, **kwargs)
File "/scratch/mc3/lib/python3.6/site-packages/conda/cli/main.py", line 78, in _main
exit_code = do_call(args, p)
File "/scratch/mc3/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 76, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "/scratch/mc3/lib/python3.6/site-packages/conda/cli/main_install.py", line 11, in execute
install(args, parser, 'install')
File "/scratch/mc3/lib/python3.6/site-packages/conda/cli/install.py", line 236, in install
force_reinstall=context.force,
File "/scratch/mc3/lib/python3.6/site-packages/conda/core/solve.py", line 504, in solve_for_transaction
force_remove, force_reinstall)
File "/scratch/mc3/lib/python3.6/site-packages/conda/core/solve.py", line 437, in solve_for_diff
final_precs = self.solve_final_state(deps_modifier, prune, ignore_pinned, force_remove)
File "/scratch/mc3/lib/python3.6/site-packages/conda/core/solve.py", line 146, in solve_final_state
specs_from_history_map = History(self.prefix).get_requested_specs_map()
File "/scratch/mc3/lib/python3.6/site-packages/conda/history.py", line 187, in get_requested_specs_map
spec_map.update(((s.name, s) for s in update_specs))
File "/scratch/mc3/lib/python3.6/site-packages/conda/history.py", line 187, in <genexpr>
spec_map.update(((s.name, s) for s in update_specs))
File "/scratch/mc3/lib/python3.6/site-packages/conda/history.py", line 186, in <genexpr>
update_specs = (MatchSpec(spec) for spec in request.get('update_specs', ()))
File "/scratch/mc3/lib/python3.6/site-packages/conda/models/match_spec.py", line 39, in __call__
parsed = _parse_spec_str(spec_arg)
File "/scratch/mc3/lib/python3.6/site-packages/conda/models/match_spec.py", line 556, in _parse_spec_str
raise CondaValueError("Invalid MatchSpec: %s" % spec_str)
conda.exceptions.CondaValueError: Invalid MatchSpec: <2.0

# Fixed code
def get_user_requests(self):
    """
    return a list of user requested items.  Each item is a dict with the
    following keys:
    'date': the date and time running the command
    'cmd': a list of argv of the actual command which was run
    'action': install/remove/update
    'specs': the specs being used
    """
    res = []
    for dt, unused_cont, comments in self.parse():
        item = {"date": dt}
        for line in comments:
            comment_items = self._parse_comment_line(line)
            item.update(comment_items)

        if "cmd" in item:
            res.append(item)

        dists = groupby(itemgetter(0), unused_cont)
        item["unlink_dists"] = dists.get("-", ())
        item["link_dists"] = dists.get("+", ())

    return res