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:


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(",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: test1 (java.TestJava)
Traceback (most recent call last):
  File "C:/projects/py-workspace/imp-resolver/tests\", line 15, in test1
    self.assertEquals('1.00', t['version'])
AssertionError: '1.00' != 1.0


Change History

comment:1 Changed 21 months ago by anonymous

This can be fixed by changing replace the line

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


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

-Lev Berlin


Add a comment

Modify Ticket

Change Properties
<Author field>
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'

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

Note: See TracTickets for help on using tickets.