Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on parsing list nested in dict #61

Closed
mbollmann opened this issue Mar 16, 2015 · 4 comments · Fixed by #100
Closed

Crash on parsing list nested in dict #61

mbollmann opened this issue Mar 16, 2015 · 4 comments · Fixed by #100
Labels
Milestone

Comments

@mbollmann
Copy link

When parsing a line containing a dict that has a list (or tuple) as a value, xonsh crashes.

bollmann@underberg ~/repositories/xonsh master >>> {'foo': ['a', 'b']}
Traceback (most recent call last):
  File "/usr/local/bin/xonsh", line 12, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/home/bollmann/repositories/xonsh/scripts/xonsh", line 3, in <module>
    main()
  File "/home/bollmann/repositories/xonsh/xonsh/main.py", line 25, in main
    shell.cmdloop()
  File "/home/bollmann/repositories/xonsh/xonsh/shell.py", line 152, in cmdloop
    super(Shell, self).cmdloop(intro=intro)
  File "/usr/lib/python3.4/cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib/python3.4/cmd.py", line 211, in onecmd
    return self.default(line)
  File "/home/bollmann/repositories/xonsh/xonsh/shell.py", line 105, in default
    code = self.push(line)
  File "/home/bollmann/repositories/xonsh/xonsh/shell.py", line 126, in push
    locs=self.ctx)
  File "/home/bollmann/repositories/xonsh/xonsh/execer.py", line 87, in compile
    code = compile(tree, self.filename, mode)
ValueError: Dict doesn't have the same number of keys as values
bollmann@underberg ~/repositories/xonsh (master) $ 

Other nested structures seem to work fine. Putting the list in a variable first and then constructing the dict also works fine.

bollmann@underberg ~/repositories/xonsh master >>> x = ['a', 'b']
bollmann@underberg ~/repositories/xonsh master >>> {'foo': x}
{'foo': ['a', 'b']}
bollmann@underberg ~/repositories/xonsh master >>> {'a': {'b': 'c', 'd': 'e'}}
{'a': {'b': 'c', 'd': 'e'}}
bollmann@underberg ~/repositories/xonsh master >>> [{'a': 'b', 'c': 'd'}]
[{'a': 'b', 'c': 'd'}]
bollmann@underberg ~/repositories/xonsh master >>> [{'a': 'b'}, {'c': 'd'}]
[{'a': 'b'}, {'c': 'd'}]
bollmann@underberg ~/repositories/xonsh master >>> {'a': {'b': 'c', 'd': 'e'}}
{'a': {'b': 'c', 'd': 'e'}}
@scopatz scopatz added the bug label Mar 16, 2015
@scopatz scopatz added this to the v0.2 milestone Mar 16, 2015
@scopatz
Copy link
Member

scopatz commented Mar 16, 2015

Thanks for reporting @mbollmann!

@scopatz
Copy link
Member

scopatz commented Mar 19, 2015

Hey @mbollmann, I have put in #100. If you could take a look at that branch and let me know if it works for you, that'd be great! thanks.

@mbollmann
Copy link
Author

Fixes the cases that I described above, but still doesn't get everything right as mentioned here:
#100 (comment)

(I'm duplicating this info here since I got confused myself that I supposedly hadn't answered this yet...)

@mbollmann
Copy link
Author

Nevermind, just saw there is a separate issue for that problem.

The specific bug described here is fixed. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants