# HG changeset patch # User Raphaël Gomès # Date 1711468291 0 # Node ID f5c46c3518a50c57644ff8d4bc0d15b62026aa46 # Parent 4dc1fc2b2f3a3be83095ad72631ca81018883ae6 util: make buffer readonly There is no use of writable buffers anywhere in the code, and this helps us make sure we don't get into unsound territory when sharing memory with Rust. This `toreadonly` method was not available in Python 3.6, but we dropped the support for it earlier that week, so no need for any compatibility code. diff -r 4dc1fc2b2f3a -r f5c46c3518a5 mercurial/util.py --- a/mercurial/util.py Thu Sep 05 17:12:52 2024 -0400 +++ b/mercurial/util.py Tue Mar 26 15:51:31 2024 +0000 @@ -333,8 +333,10 @@ def buffer(sliceable, offset=0, length=None): if length is not None: - return memoryview(sliceable)[offset : offset + length] - return memoryview(sliceable)[offset:] + view = memoryview(sliceable)[offset : offset + length] + else: + view = memoryview(sliceable)[offset:] + return view.toreadonly() _chunksize = 4096