Skip to content

Commit

Permalink
Merge 552f027 into 425fd97
Browse files Browse the repository at this point in the history
  • Loading branch information
wimglenn committed Mar 28, 2019
2 parents 425fd97 + 552f027 commit 2dd9230
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions oyaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ def map_representer(dumper, data):


def map_constructor(loader, node):
if not _std_dict_is_order_preserving:
# trigger any contextual error
loader.construct_mapping(node)
loader.flatten_mapping(node)
return OrderedDict(loader.construct_pairs(node))

Expand Down
7 changes: 7 additions & 0 deletions test_oyaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from types import GeneratorType

import pytest
from yaml.constructor import ConstructorError
from yaml.representer import RepresenterError

import oyaml as yaml
Expand Down Expand Up @@ -186,3 +187,9 @@ def test_merge():
assert map2 == expected
assert map3 == expected
assert map4 == expected


@pytest.mark.skipif(_std_dict_is_order_preserving, reason="requires old dict impl")
def test_unhashable_error_context():
with pytest.raises(ConstructorError, match=r".*line.*column.*"):
yaml.safe_load("{foo: bar}: baz")

0 comments on commit 2dd9230

Please sign in to comment.