* fix: return empty memoryview for uninitialized DATA fields
Use a module-level sentinel when Cap'n Proto reports a NULL pointer with
zero size so PyBuffer_FillInfo receives a valid address for unset fields.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix: release buffer info if memoryview construction fails
PyBuffer_FillInfo pins `self` via buf.obj; call PyBuffer_Release on failure
so that reference is not leaked. This is safe for sentinel-backed empty views:
PyBuffer_Release only decrements buf.obj and does not free buf.buf.
Co-authored-by: Cursor <cursoragent@cursor.com>
* docs: clarify lifetime rules for zero-copy buffer views
Document borrowing semantics, mutation hazards, and empty DATA field
behavior for get_data_as_view and to_segment_views.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix: pin DATA field views via shared buffer exporter
Replace PyMemoryView_FromBuffer with a _BorrowedBufferView holder and
PyMemoryView_FromObject so get_data_as_view() correctly pins the struct
reader/builder for the memoryview lifetime. Generalize the same exporter
for to_segment_views() and add regression tests for packed payload release.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: bigtailfox <leoherz.liu@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
- Remove .flake8; add [tool.ruff] and [tool.ruff.format] config in pyproject.toml
(line-length 120, excludes, ignore list, per-file-ignores, mccabe complexity)
- Update GitHub workflow lint job to run `ruff check .` and `ruff format --check .`
- Swap black and flake8 for ruff in requirements.txt and Pipfile
- Change capnp/__init__.py to ruff-style noqa comment
- Move max-complexity into [tool.ruff.lint.mccabe], lint options into [tool.ruff.lint]
- Add per-file-ignores for capnp/__init__.py (F401, F403, F405), remove inline noqa
- Run ruff format across codebase (24 files) for consistent style
* get data field with view
* refine tc
* refine based on flake check
* run black again
* rebase upstream master
* add comment to tc
* refine raise exception