promptdojo_
the wedge

python bugs ai writes (and how to catch them).

updated 2026-05-11 · 7 entries

every bug below is one your ai coding assistant will ship to you. most of them, more than once. each entry names the bug, shows where it shows up, and links to a runnable chapter on the fix when one exists.

send a bug to @TFisPython. the best ones land here, anonymized.

#01 · claude code, cursor, copilot

filters falsy values out of a list, deletes valid zeros

why:asked to filter `None` from `[0, 1, None, 2]`, the ai writes `[x for x in xs if x]` and silently drops `0`. shipped a `user_id` outage at one company.

fix:use `if x is not None` for nullable checks. never use truthiness for nullable id checks.

#05 · claude code

claims a function is a generator, returns a list

why:asks for a streaming generator, gets a function that builds the full list in memory and returns it. memory blows up at scale.

fix:look for `yield`. no yield, not a generator.

chapter coming
#06 · cursor, copilot

modifies a dict while iterating over it

why:`for k in d:` then `del d[k]` raises `RuntimeError: dictionary changed size during iteration`. ai writes it confidently anyway.

fix:iterate over `list(d.keys())` if you need to mutate while looping. or build a new dict.

what's next