Skip to content

Commit 191ac06

Browse files
deedy5Kriechi
authored andcommitted
refactor(FrameBuffer): rename self.data to self._data
1 parent 42ee8d7 commit 191ac06

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/h2/frame_buffer.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class FrameBuffer:
3030
"""
3131

3232
def __init__(self, server: bool = False) -> None:
33-
self.data = bytearray()
33+
self._data = bytearray()
3434
self.max_frame_size = 0
3535
self._preamble = b"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" if server else b""
3636
self._preamble_len = len(self._preamble)
@@ -54,7 +54,7 @@ def add_data(self, data: bytes) -> None:
5454
self._preamble_len -= of_which_preamble
5555
self._preamble = self._preamble[of_which_preamble:]
5656

57-
self.data += data
57+
self._data += data
5858

5959
def _validate_frame_length(self, length: int) -> None:
6060
"""
@@ -119,26 +119,26 @@ def __iter__(self) -> FrameBuffer:
119119
def __next__(self) -> Frame:
120120
# First, check that we have enough data to successfully parse the
121121
# next frame header. If not, bail. Otherwise, parse it.
122-
if len(self.data) < 9:
122+
if len(self._data) < 9:
123123
raise StopIteration
124124

125125
try:
126-
f, length = Frame.parse_frame_header(memoryview(self.data[:9]))
126+
f, length = Frame.parse_frame_header(memoryview(self._data[:9]))
127127
except (InvalidDataError, InvalidFrameError) as err: # pragma: no cover
128128
msg = f"Received frame with invalid header: {err!s}"
129129
raise ProtocolError(msg) from err
130130

131131
# Next, check that we have enough length to parse the frame body. If
132132
# not, bail, leaving the frame header data in the buffer for next time.
133-
if len(self.data) < length + 9:
133+
if len(self._data) < length + 9:
134134
raise StopIteration
135135

136136
# Confirm the frame has an appropriate length.
137137
self._validate_frame_length(length)
138138

139139
# Try to parse the frame body
140140
try:
141-
f.parse_body(memoryview(self.data[9:9+length]))
141+
f.parse_body(memoryview(self._data[9:9+length]))
142142
except InvalidDataError as err:
143143
msg = "Received frame with non-compliant data"
144144
raise ProtocolError(msg) from err
@@ -148,7 +148,7 @@ def __next__(self) -> Frame:
148148

149149
# At this point, as we know we'll use or discard the entire frame, we
150150
# can update the data.
151-
self.data = self.data[9+length:]
151+
self._data = self._data[9+length:]
152152

153153
# Pass the frame through the header buffer.
154154
new_frame = self._update_header_buffer(f)

0 commit comments

Comments
 (0)