Skip to main content

Bare except + mutable default

Looks defensive. Has TWO production-grade bugs hiding in five lines. What's the worst?

The snippet

# Defensive code that swallows the wrong things.

def parse_lines(raw, results=[]):
    for line in raw.split("\n"):
        try:
            results.append(int(line))
        except:
            pass
    return results

What would a senior flag FIRST?