fix 'OrderedDict' object has no attribute 'append' stack trace in _handle_iorder in case of syntax error

This should fix #8114 and #7905