{"record":{"id":"ba29bb313c5d2105","repo":"pypa/pip","slug":"invalid-sysconfig-get-config-var-ext-suffix","errorCode":null,"errorMessage":"invalid sysconfig.get_config_var('EXT_SUFFIX')","messagePattern":"invalid sysconfig\\.get_config_var\\('EXT_SUFFIX'\\)","errorType":"exception","errorClass":"SystemError","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/packaging/tags.py","lineNumber":496,"sourceCode":"\ndef _generic_abi() -> list[str]:\n    \"\"\"\n    Return the ABI tag based on EXT_SUFFIX.\n    \"\"\"\n    # The following are examples of `EXT_SUFFIX`.\n    # We want to keep the parts which are related to the ABI and remove the\n    # parts which are related to the platform:\n    # - linux:   '.cpython-310-x86_64-linux-gnu.so' => cp310\n    # - mac:     '.cpython-310-darwin.so'           => cp310\n    # - win:     '.cp310-win_amd64.pyd'             => cp310\n    # - win:     '.pyd'                             => cp37 (uses _cpython_abis())\n    # - pypy:    '.pypy38-pp73-x86_64-linux-gnu.so' => pypy38_pp73\n    # - graalpy: '.graalpy-38-native-x86_64-darwin.dylib'\n    #                                               => graalpy_38_native\n\n    ext_suffix = _get_config_var(\"EXT_SUFFIX\", warn=True)\n    if not isinstance(ext_suffix, str) or not ext_suffix.startswith(\".\"):\n        raise SystemError(\"invalid sysconfig.get_config_var('EXT_SUFFIX')\")\n    parts = ext_suffix.split(\".\")\n    if len(parts) < 3:\n        # CPython3.7 and earlier uses \".pyd\" on Windows.\n        return _cpython_abis(sys.version_info[:2])\n    soabi = parts[1]\n    if soabi.startswith(\"cpython\"):\n        # non-windows\n        cpython_parts = soabi.split(\"-\")\n        if len(cpython_parts) < 2 or not cpython_parts[1]:\n            raise SystemError(\"invalid sysconfig.get_config_var('EXT_SUFFIX')\")\n        abi = \"cp\" + cpython_parts[1]\n    elif soabi.startswith(\"cp\"):\n        # windows\n        abi = soabi.split(\"-\")[0]\n    elif soabi.startswith(\"pypy\"):\n        abi = \"-\".join(soabi.split(\"-\")[:2])\n    elif soabi.startswith(\"graalpy\"):\n        abi = \"-\".join(soabi.split(\"-\")[:3])","sourceCodeStart":478,"sourceCodeEnd":514,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_vendor/packaging/tags.py#L478-L514","documentation":"Raised as SystemError by _generic_abi (tags.py:495-496) when sysconfig.get_config_var('EXT_SUFFIX') is either not a string or does not start with a '.'. EXT_SUFFIX is the suffix used for CPython extension modules (e.g. '.cpython-310-x86_64-linux-gnu.so'); an unexpected shape means the running interpreter's build configuration is malformed, so the ABI tag cannot be derived.","triggerScenarios":"Running under a minimal/embedded Python build where EXT_SUFFIX is unset (None) or set to a non-dot-prefixed value; a misconfigured PyPy/other interpreter reporting an odd EXT_SUFFIX; a test harness monkeypatching sysconfig to return a non-string.","commonSituations":"Embedded Python distributions (some app bundles) with stripped sysconfig; broken/abnormal Python installs; running packaging's tag generation in an environment where the interpreter was built without normal config vars; CI on exotic interpreters.","solutions":["Verify sysconfig.get_config_var('EXT_SUFFIX') in the failing environment; reinstall or repair the Python build if it is missing/malformed.","If you control tag generation, pass explicit abis to generic_tags/sys_tags rather than relying on EXT_SUFFIX autodetection.","For embedded/minimal interpreters, ensure the config vars are populated (rebuild with the normal configuration).","Catch SystemError around tag generation and fall back to a known ABI list."],"exampleFix":"# before - relies on EXT_SUFFIX autodetection\ntags = list(generic_tags())  # SystemError: invalid EXT_SUFFIX\n\n# after - supply the ABI explicitly, or repair the interpreter\nimport sysconfig\nprint(sysconfig.get_config_var('EXT_SUFFIX'))  # inspect\ntags = list(generic_tags(abis=['cp310']))  # bypass EXT_SUFFIX path","handlingStrategy":"try-catch","validationCode":"import sysconfig\ndef ext_suffix_ok() -> bool:\n    s = sysconfig.get_config_var('EXT_SUFFIX')\n    return isinstance(s, str) and s.startswith('.')","typeGuard":null,"tryCatchPattern":"try:\n    tags = list(generic_tags())\nexcept SystemError:\n    tags = list(generic_tags(abis=[f'cp{sys.version_info.major}{sys.version_info.minor}']))","preventionTips":["Inspect EXT_SUFFIX on minimal/embedded interpreters before tag generation.","Pass explicit abis to bypass EXT_SUFFIX autodetection.","Repair/reinstall interpreters with malformed sysconfig."],"tags":["packaging","tags","sysconfig","interpreter","environment"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}