The notebook index
Post archive
7 posts in Python.
- Python’s tar filter shows what a security boundary must cover
Python 3.15.2 fixed a path escape in tarfile’s explicit tar filter. The flaw shows why extraction safety depends on the order of archive entries, while the release’s separate TLS fix illustrates a very different kind of trust decision.
- Context variables follow asyncio tasks, not just threads
ContextVar gives asynchronous code task-local state without threading.local() leaking values between coroutines. Task creation, token reset and thread handoffs define where that state begins and ends.
- Descriptors turn attribute access into an interface policy
A descriptor lets a class attribute mediate reads and writes. Understanding its precedence, owner binding and storage name helps decide when the protocol is clearer than a property or ordinary method.
- A process pool is an import and serialization boundary
Python process workers may start from a fresh interpreter, a fork server or a forked parent. Put work in importable functions, guard process creation, and choose a context deliberately.
- Python 3.15 makes deferred imports explicit—and changes when failure happens
Python 3.15 adds opt-in lazy imports that defer module loading until first use. The startup win comes with a changed point of execution: errors and import-time effects move to the path that touches the name.
- Validate CSV headers before building dictionaries
Check CSV header uniqueness, required names and row widths before mapping fields, preserving IDs such as 007 as strings.
- CSV round trips: commas, quotes and embedded newlines
Use Python’s CSV reader and writer to round-trip commas, quotes and newlines while accounting for type loss and spreadsheet formula risks.