{"record":{"id":"c7e22347e26d7627","repo":"pypa/pip","slug":"unexpected-marker-marker-r","errorCode":null,"errorMessage":"Unexpected marker {marker!r}","messagePattern":"Unexpected marker (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/packaging/markers.py","lineNumber":325,"sourceCode":"                lhs_value = lhs.value\n                environment_key = rhs.value\n                rhs_value = _lookup_environment(environment, environment_key)\n\n            if not isinstance(lhs_value, str):\n                raise UndefinedComparison(\n                    f\"Set-valued marker {environment_key!r} can only be used \"\n                    f'with the membership form (e.g. \"<name>\" in '\n                    f\"{environment_key}); it cannot appear on the left-hand \"\n                    f\"side of {op.serialize()!r}.\"\n                )\n            lhs_value, rhs_value = _normalize(lhs_value, rhs_value, key=environment_key)\n            groups[-1].append(_eval_op(lhs_value, op, rhs_value, key=environment_key))\n        elif marker == \"or\":\n            groups.append([])\n        elif marker == \"and\":\n            pass\n        else:  # pragma: nocover\n            raise TypeError(f\"Unexpected marker {marker!r}\")\n\n    return any(all(item) for item in groups)\n\n\ndef _format_full_version(info: sys._version_info) -> str:\n    version = f\"{info.major}.{info.minor}.{info.micro}\"\n    kind = info.releaselevel\n    if kind != \"final\":\n        version += kind[0] + str(info.serial)\n    return version\n\n\n@functools.cache\ndef _cached_default_environment() -> Environment:\n    \"\"\"Build the default marker environment for the current Python process.\n\n    The values are derived from process-constant data (the running interpreter\n    and the host platform), so this is cached and built only once. The result is","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_vendor/packaging/markers.py#L307-L343","documentation":"Defensive TypeError in _evaluate_markers (markers.py:325, marked '# pragma: nocover') for a marker element that is neither a list, a tuple, the 'and' string, nor the 'or' string. The parser grammar (_parse_marker) cannot produce such an element, so this branch is effectively unreachable through the public Marker/Requirement APIs.","triggerScenarios":"Not reachable via normal parsing. Only by directly assigning a malformed structure to a Marker's private _markers attribute (e.g. in tests/mocking) or via an internal packaging bug.","commonSituations":"Monkeypatching or hand-building marker._markers in tests with an invalid node type.","solutions":["Do not mutate _markers directly; always construct via Marker(string) or the __and__/__or__ combinators.","If encountered without direct attribute tampering, file a packaging bug report with the marker string."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from packaging.markers import Marker\n\ntry:\n    Marker(expr).evaluate()\nexcept TypeError as e:\n    # defensive/unexpected internal state; report upstream\n    ...\n","preventionTips":["Never assign to a Marker's private _markers attribute; build markers from strings or __and__/__or__.","If this fires without attribute tampering, it is a packaging bug."],"tags":["markers","internal","defensive"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}