Skip to content

Add 14 leaky-abstraction pitfalls (#60–#73), 100% example coverage, and linter guardrails - #5

Merged
EMRahman merged 2 commits into
mainfrom
docs/leaky-abstractions-and-guardrails
Nov 2, 2026
Merged

EMRahman merged 2 commits into
mainfrom
docs/leaky-abstractions-and-guardrails

Conversation

@EMRahman

Copy link
Copy Markdown
Owner

Summary

Expands the catalog from 59 to 73 verified pitfalls with 100% runnable example coverage (01–73), tightens existing entries, adds a copy-paste static/runtime guardrail reference, and adds free-threaded CPython (3.13t / 3.14t) to CI.

1. New Pitfalls & Self-Checking Examples (#60–#73)

  • Fundamentals (README.md)
    • #60 all([]) vacuous truth in authorization/validation (especially dangerous after iterator exhaustion) (examples/60_all_empty_vacuous_truth.py)
    • #61 itertools.groupby only groups consecutive runs and drains prior group iterators (examples/61_groupby_unsorted_and_shared.py)
    • #62 Chained comparison expansion across in, is, and == ("a" in d == True → False) (examples/62_chained_comparison_trap.py)
    • #63 Bare names in match/case act as capture patterns rather than constant checks (examples/63_match_case_bare_name.py)
  • Concurrency & Subprocesses (docs/concurrency.md)
    • #64 Early break from async for suspends finally cleanup without contextlib.aclosing() (examples/64_async_generator_cleanup.py)
    • #65 asyncio.gather() propagates the first exception while leaving sibling tasks running (examples/65_asyncio_gather_orphans.py)
    • #66 subprocess.Popen(..., stdout=PIPE).wait() deadlocks once the OS pipe buffer fills (examples/66_subprocess_pipe_deadlock.py)
    • #67 "The GIL makes dict safe" fails on check-then-set, concurrent iteration, and free-threaded builds (examples/67_freethreaded_gil_assumptions.py)
  • Object Model (docs/object-model.md)
    • #68 Built-in dict/list C fast-paths bypass overridden dunder methods on subclasses (examples/68_builtin_subclass_bypass.py)
    • #69 Subclassing a __slots__ class without declaring __slots__ silently restores __dict__ (examples/69_slots_inheritance_dict.py)
    • #70 Defining __len__ without __bool__ makes valid zero-length objects falsy (examples/70_bool_falls_back_to_len.py)
  • Interpreter Internals (docs/interpreter.md)
    • #71 from __future__ import annotations / deferred annotations vs naive __annotations__ inspection and local scopes (examples/71_stringified_annotations.py)
  • Data Systems (docs/data-systems.md)
    • #72 urllib.parse.urljoin drops base path segments without / and swaps origins on //host (examples/72_urljoin_drops_path.py)
    • #73 Visually identical NFC/NFD Unicode strings fail ==/dict lookup, and .lower() misses .casefold() mappings (examples/73_unicode_normalization_casing.py)

2. Refinements & Tooling Improvements

  • 100% runnable example coverage (73/73): Added benign stdlib demonstrations for #58 (examples/58_pickle_deserialization_exec.py) and #59 (examples/59_key_algorithm_confusion.py).
  • Sharpened existing entries:
    • #14: Highlighted isinstance(True, int) accepting JSON booleans in runtime integer validation (examples/14_bool_is_int.py).
    • #44: Added set/dict duplicate un-findable NaN key growth (examples/44_nan_breaks_containers.py).
    • #53: Cross-linked safe_join symlink resolution to the local TOCTOU filelock advisories in docs/dependency-risk.md and clarified 444 (CWE-22) vs 507 (incl. variants) in docs/security.md.
  • Guardrail reference (README.md): Added a copy-paste [tool.ruff.lint] config + type-checker and python -X dev checklist mapping pitfalls to automated checks.
  • Free-threaded CI (.github/workflows/verify.yml): Added "3.13t" and "3.14t" alongside CPython 3.10–3.14.

Verification

  • Verified all 73 examples/*.py scripts under CPython 3.14 and python3.14 -X dev.
  • Verified Python 3.10 grammar compatibility across all 73 scripts via ast.parse(..., feature_version=(3, 10)).
  • Validated all internal markdown file links and GitHub heading anchors across README.md, CONTRIBUTING.md, and docs/*.md.

…nd linter guardrails

- New pitfalls & verified examples (#60–#73):
  - Fundamentals (README.md): #60 all([]) vacuous truth, #61 itertools.groupby
    unsorted runs & shared cursor, #62 chained comparisons with in/is/==,
    #63 match/case bare-name capture.
  - Concurrency (docs/concurrency.md): #64 async for early-break cleanup leaks
    (contextlib.aclosing), #65 asyncio.gather() orphaned sibling tasks,
    #66 subprocess.Popen.wait() pipe buffer deadlocks, #67 GIL dict compound-op
    & free-threaded assumptions.
  - Object model (docs/object-model.md): #68 built-in dict/list C fast-path
    method bypasses, #69 __slots__ lost in subclasses, #70 __len__ falsiness.
  - Interpreter (docs/interpreter.md): #71 deferred/stringified annotations vs
    runtime introspection.
  - Data systems (docs/data-systems.md): #72 urllib.parse.urljoin path/origin
    pitfalls, #73 Unicode normalization & .casefold() vs .lower().
- Improvements to existing entries & repo tooling:
  - Add benign stdlib runnable examples for #58 and #59 (73/73 coverage).
  - Highlight isinstance(True, int) JSON validation trap in #14.
  - Add set/dict un-findable NaN key growth to #44.
  - Link #53 safe_join TOCTOU discussion to filelock advisories & clarify
    CWE-22 counts in docs/security.md.
  - Add copy-paste Ruff/type-checker/runtime guardrail section to README.md.
  - Add free-threaded CPython 3.13t and 3.14t to .github/workflows/verify.yml.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T00:39:31.349876Z a7fdd9a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a7fdd9ab64

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/interpreter.md Resolved
Comment thread examples/65_asyncio_gather_orphans.py Resolved
@EMRahman
EMRahman merged commit 03a0fbf into main Nov 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant