Modify

Ticket #119 (new defect)

Opened 5 years ago

Last modified 21 months ago

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

Change History

comment:1 Changed 21 months ago by anonymous

This can be fixed by changing resolver.py: replace the line

resolvers += self.yaml_implicit_resolvers.get(None, [])

with:

resolvers = self.yaml_implicit_resolvers.get(None, []) + resolvers

-Lev Berlin

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will be changed from xi. Next status will be 'new'
The owner will be changed from xi to anonymous. Next status will be 'assigned'
Author


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

 
Note: See TracTickets for help on using tickets.