From knowledge-patch
Provides up-to-date knowledge on Python 3.13, 3.14, and 3.15 preview for compatibility and migration.
How this skill is triggered — by the user, by Claude, or both
Slash command
/knowledge-patch:python-knowledge-patchThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Baseline: Python through 3.12. Covered range: Python 3.13 and 3.14, plus the Python 3.15.0b3 preview.
agents/openai.yamlcoverage.jsonreferences/build-and-distribution.mdreferences/c-api-and-extensions.mdreferences/concurrency-and-asyncio.mdreferences/data-io-and-serialization.mdreferences/filesystem-os-and-platforms.mdreferences/language-and-runtime.mdreferences/networking-and-security.mdreferences/tooling-debugging-and-testing.mdreferences/typing-and-introspection.mdBaseline: Python through 3.12. Covered range: Python 3.13 and 3.14, plus the Python 3.15.0b3 preview.
Included batches: whatsnew-3.13, 3.13.0, whatsnew-3.14, 3.14.0, whatsnew-3.15, and 3.15.0b3.
Use the quick reference for migration-sensitive decisions, then open the topic reference that matches the code being changed. Treat every Python 3.15 item as preview behavior and gate it by the actual runtime version.
| Reference | Topics |
|---|---|
| Language and runtime | Syntax and execution, built-ins, object model, text and numeric behavior, garbage collection, removals |
| Typing and introspection | Deferred annotations, typing, ASTs, frames and locals, signatures, symbols, runtime metadata |
| Concurrency and asyncio | Asyncio, threads and queues, multiprocessing, executors, subinterpreters, free-threading |
| Data, I/O, and serialization | Configuration, SQLite and dbm, serialization, compression, archives, streams, codecs, TOML and JSON |
| Networking and security | TLS, HTTP, URLs, email, sockets, protocol validation, parser hardening |
| Filesystems, OS, and platforms | pathlib, OS APIs, mmap, resources, virtual environments, locale, platform behavior |
| Tooling, debugging, and testing | REPL, pdb, profiling, monitoring, CLI parsing, logging, tests, imports and packaging |
| C API and extensions | Compatibility, references and errors, types and modules, free-threading, Stable/Limited APIs, embedding |
| Build and distribution | Build prerequisites, configure controls, JIT, cross-builds, platform targets, artifacts |
locals() call returns an independent snapshot. frame.f_locals is instead a write-through proxy; copy it when a stable dictionary is needed.exec() or eval() namespace no longer makes newly assigned optimized locals observable afterward. Pass explicit globals and locals when retrieving results.ast.Constant.value and visit_Constant().annotationlib instead of assuming values are eagerly present in __annotations__ or a class namespace.int() no longer falls back to __trunc__(), and Boolean evaluation of NotImplemented raises TypeError in 3.14.return, break, or continue that exits a finally block emits a compile-time SyntaxWarning in 3.14.functools.partial used directly as a class attribute warns in 3.13; wrap it in staticmethod() to retain non-binding behavior.maxsplit, count, and flags parameters are becoming keyword-only. Name them now.namespace = {}
exec("answer = 42", globals(), namespace)
answer = namespace["answer"]
parts = re.split(pattern, text, maxsplit=1, flags=re.ASCII)
asyncio.get_event_loop() raises RuntimeError when no current loop exists in 3.14. Use asyncio.run(), get_running_loop(), or asyncio.Runner as appropriate.loop_factory on asyncio.run() or Runner.name, context, and future keywords.ProcessPoolExecutor default to forkserver in 3.14, not fork. Explicitly request a context if inherited globals are required.queue.Queue and asyncio.Queue have explicit shutdown() methods and raise ShutDown or QueueShutDown at termination.Server.wait_closed() now waits for closure and all active connections. A Unix server removes its socket when it closes.Task.set_name(); _set_task_name() is removed.tasks = [asyncio.create_task(fetch(url)) for url in urls]
async for task in asyncio.as_completed(tasks):
# Async iteration preserves supplied task/future identity.
result = await task
dbm now selects the SQLite backend by default. Select a backend explicitly when file format or implementation stability matters.ssl.create_default_context() enables VERIFY_X509_PARTIAL_CHAIN and VERIFY_X509_STRICT; previously accepted malformed certificates can fail verification.Path.glob() and rglob() patterns ending in ** return files and directories. Add a trailing slash for directories only, and use recurse_symlinks deliberately.0o700 now applies access control in mkdir() and makedirs().Path.exists() and the Path.is_*() predicates suppress every OSError in 3.14. Use stat() when the failure must be visible.mimetypes.guess_type() is soft-deprecated; use guess_file_type().ValueError.sqlite3.Connection, NamedTemporaryFile, and GzipFile objects can emit ResourceWarning. Use explicit closure, not only transaction context management.gzip.compress() defaults to mtime=0 in 3.14 for reproducibility. Pass mtime=None to record the current time.ZipFile.writestr() respects SOURCE_DATE_EPOCH; Python 3.15 preview lowers gzip and gzip-tar default compression from 9 to 6.ProgrammingError. Several connect parameters become keyword-only in 3.15.urllib.parse.parse_qs() and parse_qsl() deprecate unsupported false values such as 0 and []; bytes handling and lossless component options also changed.argparse.ArgumentParser.suggest_on_error defaults to true in the 3.15 preview, and inferred destinations for overlapping short/long forms can change.http.server, legacy sre_* modules, PurePath.is_reserved(), code.co_lnotab, zipimporter.load_module(), and several other deprecated APIs. Review both removal sections before targeting it.python3.13t or --disable-gil. Extensions declare support with Py_mod_gil or PyUnstable_Module_SetGIL(); undeclared extensions normally re-enable the GIL.Py_GIL_DISABLED themselves.abi3t Stable ABI. Use opaque per-type storage and the new module export/slot machinery; publish a separate cp315t build for APIs outside abi3t.PyDict_Next() does not lock in free-threaded builds. Hold one critical section around the whole iteration.PyModule_Add() always steals the supplied reference, including on failure.Python.h no longer supplies several system headers transitively. Include every declaration's owning header directly.PY_SSIZE_T_CLEAN is obsolete, and removed trashcan macros must become Py_TRASHCAN_BEGIN(object, deallocator) / Py_TRASHCAN_END.PyObject_GetBuffer() plus PyBuffer_Release(), PyObject_Call*(), and PyConfig initialization.PyUnstable_Object_Is*Referenced() API.Py_Finalize() deletes interned strings in 3.14. Embedders that reinitialize must release extension-held interned references during shutdown.PyGILState family is soft-deprecated.Python 3.14 evaluates function, class, and module annotations lazily. Choose the representation required by the consumer:
from annotationlib import Format, get_annotations
def parse(value: Missing): ...
hints = get_annotations(parse, format=Format.FORWARDREF)
Format.VALUE evaluates values and can raise for missing names.Format.FORWARDREF preserves unresolved names as ForwardRef objects.Format.STRING returns source-like strings.inspect.signature() accepts annotation_format.types.UnionType and typing.Union are aliases in 3.14; compare unions by equality or use get_origin() / get_args(), not identity.TypeForm, closed or extensible TypedDict, richer TypeVarTuple, and more metadata on type aliases.A t-prefixed literal creates string.templatelib.Template, retaining static strings and interpolation objects for safe DSL-specific rendering:
name = "Ada"
template = t"Hello {name}"
for part in template:
process(part)
Templates do not concatenate with str, and t-string literals do not implicitly concatenate with string or f-string literals in 3.15.0b3.
sys._is_gil_enabled() and control it with PYTHON_GIL or -X gil where supported.concurrent.interpreters exposes isolated interpreters in 3.14, while InterpreterPoolExecutor provides a true-multicore executor inside one process.sys.implementation.supports_isolated_interpreters in 3.15.0b3.-X context_aware_warnings and sys.flags.thread_inherit_context default on for free-threaded builds and off for GIL-enabled builds.PyMutex, and the documented iterator synchronization APIs rather than assuming the GIL serializes access.asyncio.as_completed() can yield the original task or future objects.Executor.map(buffersize=n) applies submission backpressure; process pools can terminate or kill all workers explicitly.multiprocessing.Process.interrupt() sends SIGINT, allowing normal KeyboardInterrupt and finally cleanup.python -m asyncio ps PID and pstree PID inspect remote task graphs; in-process code can use capture_call_graph() and print_call_graph().await pdb.set_trace_async() supports await while debugging a coroutine.TaskGroup.cancel() for direct group cancellation.compression.zstd and the preferred compression.{gzip,bz2,lzma,zlib} namespace arrive in 3.14; tar, ZIP, and shutil understand Zstandard archives.marshal format 5 serializes slices; allow_code=False blocks code-object serialization and deserialization.mmap(..., trackfd=False) avoids retaining a duplicate descriptor on Unix and, in the 3.15 preview, on Windows.Path.info caches type/stat information, including details obtained during iterdir().tomllib.TOMLDecodeError exposes structured location fields in 3.14; the 3.15 preview accepts TOML 1.1.json's array_hook, shelf serializer hooks, bytearray.take_bytes(), and stricter/canonical base-encoding controls.breakpoint() and pdb.set_trace() stop at the call site in 3.13. Pdb can execute statements against current-frame locals and attach remotely in 3.14.PYTHON_DISABLE_REMOTE_DEBUG, -X disable-remote-debug, or --without-remote-debug.profiling.tracing and profiling.sampling; cProfile remains an alias, while pure-Python profile is deprecated.sys.monitoring gains directional branch events in 3.14 and per-code exception-event control in 3.15.Explicit lazy imports defer loading until first use and report failures at that point:
lazy import json
lazy from pathlib import Path
data = json.loads('{"answer": 42}')
try, star imports, and future imports.-X lazy_imports=all or PYTHON_LAZY_IMPORTS=all changes the default; inspect and control it through sys.get_lazy_imports(), set_lazy_imports(), and filters.frozendict is immutable, insertion-ordered, and conditionally hashable; test generic mappings with collections.abc.Mapping.sentinel() creates identity-stable marker values that survive copying and can be pickleable when importable by name.* and ** unpacking.map(..., strict=True) is a 3.14 feature; the preview additionally supplies synchronized/concurrent iterator utilities and expands free-threaded iterator guarantees.abi3t behind 3.15 checks.ResourceWarning visible; exercise filesystem errors, malformed protocol fields, nonblocking streams, serialization compatibility, interpreter shutdown, and extension imports.npx claudepluginhub nevaberry/nevaberry-plugins --plugin knowledge-patchCovers Python 3.13+ fundamentals: free-threading (no-GIL), JIT compiler, pattern matching, walrus operator, type parameters, exception groups, dataclasses, enums for modern syntax, performance, best practices.
Python language conventions, modern idioms, and toolchain. Invoke whenever task involves any interaction with Python code — writing, reviewing, refactoring, debugging, or understanding Python projects.
Provides expert guidance on Python 3.12+ development, async programming, performance optimization, and modern tooling (uv, ruff, pydantic, FastAPI).