Modify ↓
Ticket #119 (new defect)
Implicit resolver is not respected (the order is important)
| Reported by: | py4fun@… | Owned by: | xi |
|---|---|---|---|
| Priority: | normal | Component: | pyyaml |
| Severity: | normal | Keywords: | |
| Cc: |
Description
The order in which the implicit resolvers are applied is important. The user defined implicit resolvers should be checked first.
In the test below '1.00' should parsed as string but instead it is parsed as float:
def test1(self):
pattern = re.compile(r"\d\.\d\d")
yaml.add_implicit_resolver("tag:yaml.org,2002:str", pattern, "123")
t = yaml.load("version: 1.00")
print t
self.assertEquals('1.00', t['version'])
test1 (java.TestJava) ... {'version': 1.0}
FAIL
======================================================================
FAIL: test1 (java.TestJava)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:/projects/py-workspace/imp-resolver/tests\java.py", line 15, in test1
self.assertEquals('1.00', t['version'])
AssertionError: '1.00' != 1.0
Attachments
Note: See
TracTickets for help on using
tickets.

This can be fixed by changing resolver.py: replace the line
with:
-Lev Berlin