From 10a4cfc75765d4f10010b105a190bc1ad30d4a79 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 9 Apr 2015 22:39:47 +0300 Subject: [PATCH] os: os.read() should return immutable value suitable e.g. for hashing. Converting bytearray to bytes is of course not memory-efficient, so os.read() is good candidate for native implementation. --- os/os/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/os/__init__.py b/os/os/__init__.py index 8e057d51..36210aba 100644 --- a/os/os/__init__.py +++ b/os/os/__init__.py @@ -158,7 +158,7 @@ def read(fd, n): buf = bytearray(n) r = read_(fd, buf, n) check_error(r) - return buf[:r] + return bytes(buf[:r]) def write(fd, buf): r = write_(fd, buf, len(buf))