lbenitez000 / trparse

Parses the output of a traceroute execution into an AST
MIT License
13 stars 14 forks source link

Bug with list of a filter object (Python3) #6

Open usr-ein opened 7 years ago

usr-ein commented 7 years ago

Hello, I've just found a bug whilst using your module:

# Parse probes data: <name> | <(IP)> | <rtt> | 'ms' | '*'
        probes_data = match_hop[2].split()
        # Get rid of 'ms': <name> | <(IP)> | <rtt> | '*'
        probes_data = filter(lambda s: s.lower() != 'ms', probes_data)

        i = 0
        while i < len(probes_data):
            # For each hop parse probes
            name = None
            ip = None
            rtt = None
            anno = ''

Here (line 118 of trparse.py), you try to iterate through the result of a filter, which is returning me:

File "/usr/local/lib/python3.6/site-packages/trparse.py", line 118, in loads
    while i < len(probes_data):
TypeError: object of type 'filter' has no len()

So to fix this I had to simply modify this on line 115: From : probes_data = filter(lambda s: s.lower() != 'ms', probes_data) to probes_data = list(filter(lambda s: s.lower() != 'ms', probes_data)) .

It all works perfectly fine now, thanks for creating this module, it make my code much cleaner and my life easier so I thought I'd help you with that.

Cheers.

rarylson commented 6 years ago

Confirm pull #8 will partially fix Python3 support (ok for production use).

This is only a partial fix because the project cannot still be used in development (test.py also is not compatible with Python3).

I proposed some changes to the pull request owner. With this changes, the pull will fully add Python3 support.

rarylson commented 4 years ago

This bug doesn't exist anymore in latest version (v0.3.0).

The implementation now passes in all test cases (tests/tests.py) in both Python2 and Python3.

@gleichda or @lbenitez000 , I think you can close them now.