Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: GlasgowEmbedded/glasgow
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: dd6ee6423b11
Choose a base ref
...
head repository: GlasgowEmbedded/glasgow
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 94badd13f16b
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Aug 2, 2019

  1. Copy the full SHA
    94badd1 View commit details
Showing with 12 additions and 5 deletions.
  1. +12 −5 software/glasgow/support/chunked_fifo.py
17 changes: 12 additions & 5 deletions software/glasgow/support/chunked_fifo.py
Original file line number Diff line number Diff line change
@@ -23,14 +23,15 @@ def clear(self):

def write(self, data):
"""Enqueue ``data``."""
try:
data = memoryview(data)
except TypeError:
data = memoryview(bytes(data))

if not data:
return

self._length += len(data)
try:
self._queue.append(memoryview(data))
except TypeError:
self._queue.append(memoryview(bytes(data)))
self._queue.append(data)

def read(self, max_length=None):
"""
@@ -78,6 +79,7 @@ def __len__(self):
# -------------------------------------------------------------------------------------------------

import unittest
from .bits import bits


class ChunkedFIFOTestCase(unittest.TestCase):
@@ -145,3 +147,8 @@ def test_len(self):
self.assertEqual(len(self.fifo), 5)
self.fifo.read(3)
self.assertEqual(len(self.fifo), 2)

def test_write_bits(self):
self.fifo.write(bits("1010"))
self.assertEqual(len(self.fifo), 1)
self.assertEqual(self.fifo.read(1), b"\x0a")