Skip to content

Commit ce757cd

Browse files
authored
fix(protocols): revert #2432's RegistryError message to name Protocol (#2434)
#2432 (round 10 of #1103) changed register's RegistryError message from "...must be a Protocol subclass" to "...must be a ProtocolBase subclass" in pcapkit/protocols/protocol.py and foundation/registry/protocols.py, and updated the locked assertions in tests/protocols/test_register_class_guard_unit.py and tests/foundation/registry/test_protocols.py to match. This was a mistake. * The wording naming Protocol (not ProtocolBase) is a deliberate, ratified decision: #1016 ruled the message's reader is third-party code, who should be told to subclass Protocol -- ProtocolBase's own docstring says it is "for internal use only". The owner approved that reasoning, #2316 re-confirmed it as out of scope to change, and #2420's commit explicitly records "the error message names Protocol" as the kept half of the split between the Raises: clause (ProtocolBase) and the raised message (Protocol). #2420 also notes it already caught and corrected one prior accidental flip of this exact wording. * Reverted both raise sites and the four locked test assertions back to "Protocol subclass". * Also fixed a citation left by #2432: tests/foundation/reassembly/ test_deferred_pickle_2423_unit.py cited :issue:`2424` (the merged PR, not an issue) where it meant the underlying fix, tracked as #2423 -- matches the file's existing :issue:`2423` citation style and the changelog's own "(:issue:`2423`, :issue:`2425`, :pr:`2424`)" citation. #2432's other two fixes (a stale docstring, a cross-reference to a moved EnumField) are correct and untouched. Refs #1016, #2316, #2420 Refs #1103 Build: tests/protocols/test_register_class_guard_unit.py, tests/foundation/registry/test_protocols.py, tests/foundation/reassembly/test_deferred_pickle_2423_unit.py pass; full tests/project/ run shows no new failures (13 pre-existing failures, all in unrelated subprocess/network-dependent tests, none touching these files).
1 parent c2f1089 commit ce757cd

5 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎pcapkit/foundation/registry/protocols.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class rather than supplied by a caller, and this function is the funnel
221221
if not isinstance(protocol, type):
222222
raise RegistryError(f'protocol must be a class, not {protocol!r}')
223223
if not issubclass(protocol, ProtocolBase):
224-
raise RegistryError(f'protocol must be a ProtocolBase subclass, not {protocol!r}')
224+
raise RegistryError(f'protocol must be a Protocol subclass, not {protocol!r}')
225225

226226
name = protocol.__name__.upper()
227227
incumbent = protocol_registry.get(name)

‎pcapkit/protocols/protocol.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ def _next_layer_entry(cls, code: 'Any', protocol: 'ModuleDescriptor[ProtocolBase
11391139
if not isinstance(protocol, type):
11401140
raise RegistryError(f'protocol must be a class, not {protocol!r}')
11411141
if not issubclass(protocol, ProtocolBase):
1142-
raise RegistryError(f'protocol must be a ProtocolBase subclass, not {protocol!r}')
1142+
raise RegistryError(f'protocol must be a Protocol subclass, not {protocol!r}')
11431143
return protocol
11441144

11451145
@classmethod

‎tests/foundation/reassembly/test_deferred_pickle_2423_unit.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def test_setstate_still_accepts_the_first_revisions_flat_shape(self) -> None:
245245
"""The flat ``{slot: value}`` shape the very first fix returned.
246246
247247
Never released, but already pushed in an earlier revision of
248-
:issue:`2424`'s fix -- accepting it costs nothing and protects anyone
248+
:issue:`2423`'s fix -- accepting it costs nothing and protects anyone
249249
who pickled against that revision.
250250
251251
"""

‎tests/foundation/registry/test_protocols.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ def test_register_protocol_rejects_a_non_class_with_registry_error(self) -> None
438438
('none', None, 'must be a class'),
439439
('descriptor argument (not unwrapped here)',
440440
ModuleDescriptor('pcapkit.protocols.misc.raw', 'Raw'), 'must be a class'),
441-
('wrong class', object, 'ProtocolBase subclass'),
441+
('wrong class', object, 'Protocol subclass'),
442442
):
443443
with self.subTest(value=label):
444444
with self.assertRaises(RegistryError) as caught:

‎tests/protocols/test_register_class_guard_unit.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def test_wrong_class_still_raises_registry_error(self) -> None:
8282
with mock.patch.dict(klass.__proto__):
8383
with self.assertRaises(RegistryError) as caught:
8484
klass.register(code, dict) # type: ignore[arg-type]
85-
self.assertIn('ProtocolBase subclass', str(caught.exception))
85+
self.assertIn('Protocol subclass', str(caught.exception))
8686

8787
def test_descriptor_naming_a_non_class_raises_registry_error(self) -> None:
8888
from pcapkit.corekit.module import ModuleDescriptor
@@ -107,7 +107,7 @@ def test_descriptor_naming_a_wrong_class_still_raises_registry_error(self) -> No
107107
with mock.patch.dict(klass.__proto__):
108108
with self.assertRaises(RegistryError) as caught:
109109
klass.register(code, descriptor) # type: ignore[arg-type]
110-
self.assertIn('ProtocolBase subclass', str(caught.exception))
110+
self.assertIn('Protocol subclass', str(caught.exception))
111111

112112
def test_valid_class_and_descriptor_still_register(self) -> None:
113113
from pcapkit.corekit.module import ModuleDescriptor

0 commit comments

Comments
 (0)