cobs 1.2.1__tar.gz → 1.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cobs-1.2.1/cobs.egg-info → cobs-1.2.3}/PKG-INFO +5 -4
- {cobs-1.2.1 → cobs-1.2.3}/README.rst +2 -2
- {cobs-1.2.1 → cobs-1.2.3/cobs.egg-info}/PKG-INFO +5 -4
- {cobs-1.2.1 → cobs-1.2.3}/pyproject.toml +1 -1
- {cobs-1.2.1 → cobs-1.2.3}/setup.py +2 -0
- {cobs-1.2.1 → cobs-1.2.3}/src/cobs/_version/__init__.py +1 -1
- {cobs-1.2.1 → cobs-1.2.3}/src/cobs/cobs/_cobs_py.py +5 -4
- {cobs-1.2.1 → cobs-1.2.3}/src/cobs/cobs/test.py +8 -0
- {cobs-1.2.1 → cobs-1.2.3}/src/cobs/cobsr/_cobsr_py.py +6 -5
- {cobs-1.2.1 → cobs-1.2.3}/src/cobs/cobsr/test.py +8 -0
- {cobs-1.2.1 → cobs-1.2.3}/src/ext/_cobs_ext.c +1 -1
- {cobs-1.2.1 → cobs-1.2.3}/src/ext/_cobsr_ext.c +1 -1
- {cobs-1.2.1 → cobs-1.2.3}/LICENSE.txt +0 -0
- {cobs-1.2.1 → cobs-1.2.3}/MANIFEST.in +0 -0
- {cobs-1.2.1 → cobs-1.2.3}/cobs.egg-info/SOURCES.txt +0 -0
- {cobs-1.2.1 → cobs-1.2.3}/cobs.egg-info/dependency_links.txt +0 -0
- {cobs-1.2.1 → cobs-1.2.3}/cobs.egg-info/top_level.txt +0 -0
- {cobs-1.2.1 → cobs-1.2.3}/setup.cfg +0 -0
- {cobs-1.2.1 → cobs-1.2.3}/src/cobs/__init__.py +0 -0
- {cobs-1.2.1 → cobs-1.2.3}/src/cobs/cobs/__init__.py +0 -0
- {cobs-1.2.1 → cobs-1.2.3}/src/cobs/cobsr/__init__.py +0 -0
- {cobs-1.2.1 → cobs-1.2.3}/test/test_cobs.py +0 -0
- {cobs-1.2.1 → cobs-1.2.3}/test/test_cobsr.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: cobs
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.3
|
|
4
4
|
Summary: Consistent Overhead Byte Stuffing (COBS)
|
|
5
5
|
Author-email: Craig McQueen <python@craig.mcqueen.id.au>
|
|
6
6
|
License: ----------------------------------------------------------------------------
|
|
@@ -37,6 +37,7 @@ Classifier: Topic :: Communications
|
|
|
37
37
|
Requires-Python: >=3.6
|
|
38
38
|
Description-Content-Type: text/x-rst
|
|
39
39
|
License-File: LICENSE.txt
|
|
40
|
+
Dynamic: license-file
|
|
40
41
|
|
|
41
42
|
========================================
|
|
42
43
|
Consistent Overhead Byte Stuffing (COBS)
|
|
@@ -184,10 +185,10 @@ application.
|
|
|
184
185
|
Supported Python Versions
|
|
185
186
|
-------------------------
|
|
186
187
|
|
|
187
|
-
Python >= 3.
|
|
188
|
+
Python >= 3.10 are supported, and have both a C extension and a pure Python
|
|
188
189
|
implementation.
|
|
189
190
|
|
|
190
|
-
Python versions < 3.
|
|
191
|
+
Python versions < 3.10 might work, but have not been tested.
|
|
191
192
|
|
|
192
193
|
|
|
193
194
|
------------
|
|
@@ -144,10 +144,10 @@ application.
|
|
|
144
144
|
Supported Python Versions
|
|
145
145
|
-------------------------
|
|
146
146
|
|
|
147
|
-
Python >= 3.
|
|
147
|
+
Python >= 3.10 are supported, and have both a C extension and a pure Python
|
|
148
148
|
implementation.
|
|
149
149
|
|
|
150
|
-
Python versions < 3.
|
|
150
|
+
Python versions < 3.10 might work, but have not been tested.
|
|
151
151
|
|
|
152
152
|
|
|
153
153
|
------------
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: cobs
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.3
|
|
4
4
|
Summary: Consistent Overhead Byte Stuffing (COBS)
|
|
5
5
|
Author-email: Craig McQueen <python@craig.mcqueen.id.au>
|
|
6
6
|
License: ----------------------------------------------------------------------------
|
|
@@ -37,6 +37,7 @@ Classifier: Topic :: Communications
|
|
|
37
37
|
Requires-Python: >=3.6
|
|
38
38
|
Description-Content-Type: text/x-rst
|
|
39
39
|
License-File: LICENSE.txt
|
|
40
|
+
Dynamic: license-file
|
|
40
41
|
|
|
41
42
|
========================================
|
|
42
43
|
Consistent Overhead Byte Stuffing (COBS)
|
|
@@ -184,10 +185,10 @@ application.
|
|
|
184
185
|
Supported Python Versions
|
|
185
186
|
-------------------------
|
|
186
187
|
|
|
187
|
-
Python >= 3.
|
|
188
|
+
Python >= 3.10 are supported, and have both a C extension and a pure Python
|
|
188
189
|
implementation.
|
|
189
190
|
|
|
190
|
-
Python versions < 3.
|
|
191
|
+
Python versions < 3.10 might work, but have not been tested.
|
|
191
192
|
|
|
192
193
|
|
|
193
194
|
------------
|
|
@@ -14,7 +14,8 @@ def _get_buffer_view(in_bytes):
|
|
|
14
14
|
if mv.ndim > 1 or mv.itemsize > 1:
|
|
15
15
|
raise BufferError('object must be a single-dimension buffer of bytes.')
|
|
16
16
|
try:
|
|
17
|
-
mv
|
|
17
|
+
if mv.format != 'B':
|
|
18
|
+
mv = mv.cast('B')
|
|
18
19
|
except AttributeError:
|
|
19
20
|
pass
|
|
20
21
|
return mv
|
|
@@ -36,7 +37,7 @@ def encode(in_bytes):
|
|
|
36
37
|
idx = 0
|
|
37
38
|
search_start_idx = 0
|
|
38
39
|
for in_char in in_bytes_mv:
|
|
39
|
-
if in_char ==
|
|
40
|
+
if in_char == 0:
|
|
40
41
|
final_zero = True
|
|
41
42
|
out_bytes.append(idx - search_start_idx + 1)
|
|
42
43
|
out_bytes += in_bytes_mv[search_start_idx:idx]
|
|
@@ -70,13 +71,13 @@ def decode(in_bytes):
|
|
|
70
71
|
|
|
71
72
|
if len(in_bytes_mv) > 0:
|
|
72
73
|
while True:
|
|
73
|
-
length =
|
|
74
|
+
length = in_bytes_mv[idx]
|
|
74
75
|
if length == 0:
|
|
75
76
|
raise DecodeError("zero byte found in input")
|
|
76
77
|
idx += 1
|
|
77
78
|
end = idx + length - 1
|
|
78
79
|
copy_mv = in_bytes_mv[idx:end]
|
|
79
|
-
if
|
|
80
|
+
if 0 in copy_mv:
|
|
80
81
|
raise DecodeError("zero byte found in input")
|
|
81
82
|
out_bytes += copy_mv
|
|
82
83
|
idx = end
|
|
@@ -175,6 +175,14 @@ class InputTypesTest(unittest.TestCase):
|
|
|
175
175
|
decoded = cobs.decode(array_encoded_string)
|
|
176
176
|
self.assertEqual(decoded, test_string)
|
|
177
177
|
|
|
178
|
+
def test_memoryview(self):
|
|
179
|
+
"""Test that memoryview objects can be encoded or decoded."""
|
|
180
|
+
for (test_string, expected_encoded_string) in self.predefined_encodings:
|
|
181
|
+
encoded = cobs.encode(memoryview(test_string))
|
|
182
|
+
self.assertEqual(encoded, expected_encoded_string)
|
|
183
|
+
decoded = cobs.decode(memoryview(expected_encoded_string))
|
|
184
|
+
self.assertEqual(decoded, test_string)
|
|
185
|
+
|
|
178
186
|
def test_array_of_half_words(self):
|
|
179
187
|
"""Test that array of half-word objects (array('H', ...)) are not encoded or decoded.
|
|
180
188
|
They should raise a BufferError."""
|
|
@@ -14,7 +14,8 @@ def _get_buffer_view(in_bytes):
|
|
|
14
14
|
if mv.ndim > 1 or mv.itemsize > 1:
|
|
15
15
|
raise BufferError('object must be a single-dimension buffer of bytes.')
|
|
16
16
|
try:
|
|
17
|
-
mv
|
|
17
|
+
if mv.format != 'B':
|
|
18
|
+
mv = mv.cast('B')
|
|
18
19
|
except AttributeError:
|
|
19
20
|
pass
|
|
20
21
|
return mv
|
|
@@ -39,13 +40,13 @@ def encode(in_bytes):
|
|
|
39
40
|
out_bytes.append(0xFF)
|
|
40
41
|
out_bytes += in_bytes_mv[search_start_idx:idx]
|
|
41
42
|
search_start_idx = idx
|
|
42
|
-
if in_char ==
|
|
43
|
+
if in_char == 0:
|
|
43
44
|
out_bytes.append(idx - search_start_idx + 1)
|
|
44
45
|
out_bytes += in_bytes_mv[search_start_idx:idx]
|
|
45
46
|
search_start_idx = idx + 1
|
|
46
47
|
idx += 1
|
|
47
48
|
try:
|
|
48
|
-
final_byte_value =
|
|
49
|
+
final_byte_value = in_bytes_mv[-1]
|
|
49
50
|
except IndexError:
|
|
50
51
|
final_byte_value = 0
|
|
51
52
|
length_value = idx - search_start_idx + 1
|
|
@@ -77,13 +78,13 @@ def decode(in_bytes):
|
|
|
77
78
|
|
|
78
79
|
if len(in_bytes_mv) > 0:
|
|
79
80
|
while True:
|
|
80
|
-
length =
|
|
81
|
+
length = in_bytes_mv[idx]
|
|
81
82
|
if length == 0:
|
|
82
83
|
raise DecodeError("zero byte found in input")
|
|
83
84
|
idx += 1
|
|
84
85
|
end = idx + length - 1
|
|
85
86
|
copy_mv = in_bytes_mv[idx:end]
|
|
86
|
-
if
|
|
87
|
+
if 0 in copy_mv:
|
|
87
88
|
raise DecodeError("zero byte found in input")
|
|
88
89
|
out_bytes += copy_mv
|
|
89
90
|
idx = end
|
|
@@ -208,6 +208,14 @@ class InputTypesTest(unittest.TestCase):
|
|
|
208
208
|
decoded = cobsr.decode(array_encoded_string)
|
|
209
209
|
self.assertEqual(decoded, test_string)
|
|
210
210
|
|
|
211
|
+
def test_memoryview(self):
|
|
212
|
+
"""Test that memoryview objects can be encoded or decoded."""
|
|
213
|
+
for (test_string, expected_encoded_string) in self.predefined_encodings:
|
|
214
|
+
encoded = cobsr.encode(memoryview(test_string))
|
|
215
|
+
self.assertEqual(encoded, expected_encoded_string)
|
|
216
|
+
decoded = cobsr.decode(memoryview(expected_encoded_string))
|
|
217
|
+
self.assertEqual(decoded, test_string)
|
|
218
|
+
|
|
211
219
|
def test_array_of_half_words(self):
|
|
212
220
|
"""Test that array of half-word objects (array('H', ...)) are not encoded or decoded.
|
|
213
221
|
They should raise a BufferError."""
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"object supporting the buffer API is required"); \
|
|
62
62
|
return NULL; \
|
|
63
63
|
} \
|
|
64
|
-
if (PyObject_GetBuffer((obj), (viewp),
|
|
64
|
+
if (PyObject_GetBuffer((obj), (viewp), PyBUF_ND) == -1) { \
|
|
65
65
|
return NULL; \
|
|
66
66
|
} \
|
|
67
67
|
if (((viewp)->ndim > 1) || ((viewp)->itemsize > 1)) { \
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"object supporting the buffer API is required"); \
|
|
62
62
|
return NULL; \
|
|
63
63
|
} \
|
|
64
|
-
if (PyObject_GetBuffer((obj), (viewp),
|
|
64
|
+
if (PyObject_GetBuffer((obj), (viewp), PyBUF_ND) == -1) { \
|
|
65
65
|
return NULL; \
|
|
66
66
|
} \
|
|
67
67
|
if (((viewp)->ndim > 1) || ((viewp)->itemsize > 1)) { \
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|