Ticket #179 (closed defect: duplicate)

Opened 3 years ago

Last modified 27 hours ago

Python-yaml crashes on unhashable key

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

Description (last modified by xi) (diff)


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/", line 58, in load
    return loader.get_single_data()
  File "/usr/lib/python2.6/dist-packages/yaml/", line 44, in get_single_data
    return self.construct_document(node)
  File "/usr/lib/python2.6/dist-packages/yaml/", line 53, in construct_document
    for dummy in generator:
  File "/usr/lib/python2.6/dist-packages/yaml/", line 403, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/usr/lib/python2.6/dist-packages/yaml/", line 213, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
  File "/usr/lib/python2.6/dist-packages/yaml/", 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


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.

comment:3 Changed 27 hours ago by maskodok <galihadiputro87@…>

The only thing more I could hope for is documentation of all these features (other than reading through the code).  Cipto Junaedy Is this in process? Can I help? About  Unit Link Terbaik di Indonesia Commonwealth Life Investra Link


Add a comment

Modify Ticket

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

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

Note: See TracTickets for help on using tickets.