Modify

Ticket #179 (closed defect: duplicate)

Opened 3 years ago

Last modified 2 years ago

Python-yaml crashes on unhashable key

Reported by: Samuel.Hym@… Owned by: xi
Priority: normal Component: pyyaml
Severity: normal Keywords:
Cc:

Description (last modified by xi) (diff)

Hello,

Python-yaml (debian version 3.09-5 of python-yaml, on python 2.6.6) refuses to load a yaml document containing a unhashable element as a key.

For example :

>>> yaml.load('[]: a')

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/dist-packages/yaml/__init__.py", line 58, in load
    return loader.get_single_data()
  File "/usr/lib/python2.6/dist-packages/yaml/constructor.py", line 44, in get_single_data
    return self.construct_document(node)
  File "/usr/lib/python2.6/dist-packages/yaml/constructor.py", line 53, in construct_document
    for dummy in generator:
  File "/usr/lib/python2.6/dist-packages/yaml/constructor.py", line 403, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/usr/lib/python2.6/dist-packages/yaml/constructor.py", line 213, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
  File "/usr/lib/python2.6/dist-packages/yaml/constructor.py", line 137, in construct_mapping
    "found unacceptable key (%s)" % exc, key_node.start_mark)
yaml.constructor.ConstructorError: while constructing a mapping
found unacceptable key (unhashable type: 'list')
  in "<string>", line 1, column 1:
    []: a
    ^

I don't know what would be the most desirable python object to build for that kind of yaml source, though :/

Best regards

Samuel Hym

Attachments

Change History

comment:1 Changed 3 years ago by xi

  • Description modified (diff)

comment:2 Changed 2 years ago by anonymous

  • Status changed from new to closed
  • Resolution set to duplicate

This is a dupe of #169.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.