pcapkit.const.http.method.Method is a StrEnum, but every registered member carries an empty str payload, so comparing one to its own value is False:
Method.GET value='GET' str(Method.GET)='' len=0 Method.GET == 'GET': False
Cause is pcapkit/const/http/method.py:48, inside the class's own __new__:
obj = str.__new__(cls) # no argument, so the str content is ''
str.__new__(cls) with no second argument builds an empty string, so the member's str content never carries the value even though _value_ does. Every one of the 40 registered members is affected. Reproduced on main at c411d072a and on the current head of #869 alike — it predates both.
Consequence: any caller treating a Method as the string it is (Method.GET == 'GET', '%s' % Method.GET, an f-string, a dict keyed by the verb, str.startswith) silently sees an empty string. The .name and .value attributes are correct, which is why this has gone unnoticed.
Note the interaction with #869: that PR gives unregistered members a real payload (str(Method('frob')) == 'frob'), which leaves registered and unregistered members inconsistent until __new__ is fixed here. Fixing it changes what 40 public members compare equal to, so it is a behaviour change in its own right and belongs in its own review rather than being folded into #869 — see #869 (comment).
Check whether pcapkit/const/ftp/command.py's Command.__new__ and the other hand-rolled __new__s under pcapkit/const/ have the same shape before fixing, and pin the result with a test asserting str(member) == member.value for every member of every str-valued registry.
pcapkit.const.http.method.Methodis aStrEnum, but every registered member carries an emptystrpayload, so comparing one to its own value isFalse:Cause is
pcapkit/const/http/method.py:48, inside the class's own__new__:str.__new__(cls)with no second argument builds an empty string, so the member'sstrcontent never carries the value even though_value_does. Every one of the 40 registered members is affected. Reproduced onmainatc411d072aand on the current head of #869 alike — it predates both.Consequence: any caller treating a
Methodas the string it is (Method.GET == 'GET','%s' % Method.GET, an f-string, a dict keyed by the verb,str.startswith) silently sees an empty string. The.nameand.valueattributes are correct, which is why this has gone unnoticed.Note the interaction with #869: that PR gives unregistered members a real payload (
str(Method('frob')) == 'frob'), which leaves registered and unregistered members inconsistent until__new__is fixed here. Fixing it changes what 40 public members compare equal to, so it is a behaviour change in its own right and belongs in its own review rather than being folded into #869 — see #869 (comment).Check whether
pcapkit/const/ftp/command.py'sCommand.__new__and the other hand-rolled__new__s underpcapkit/const/have the same shape before fixing, and pin the result with a test assertingstr(member) == member.valuefor every member of every str-valued registry.