Modify

Ticket #116 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

the order of keys is important

Reported by: Andrey Somov <py4fun@…> Owned by: xi
Priority: low Component: pyyaml
Severity: minor Keywords:
Cc:

Description

When PyYAML is run on alternative VM (jython for instance) the order of the dictionary keys may be different. Unfortunately PyYAML relies on the order in some cases. The attached patches show that tests fail only when the sequence of the keys is reversed. These cases were found under Java 5. (for Java 6 the order is the same as for CPython). To avoid unexpected bugs in future it would be safe to change the implementation to use a kind of an ordered dictionary.(or to respect the order in some other way). There is no guarantee the list is complete. This is just a coincidence it was found.

Attachments

ordered_map_emitter.txt Download (626 bytes) - added by Andrey Somov <py4fun@…> 5 years ago.
ordered_map_scanner.txt Download (775 bytes) - added by Andrey Somov <py4fun@…> 5 years ago.

Change History

Changed 5 years ago by Andrey Somov <py4fun@…>

Changed 5 years ago by Andrey Somov <py4fun@…>

comment:1 Changed 5 years ago by xi

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

It appears that emitter.py has indeed a very subtle bug, I think I fixed in [345]. Thank you for reporting it.

I can't see any problem with the code in scanner.py. Once i fixed the obvious error in

keys_rev = keys_rev.reverse()

the tests pass fine.

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.