Skip to content

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

@usr-ein

Description

@usr-ein

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions