{"id":8331,"library":"mozinfo","title":"mozinfo","description":"mozinfo is a Python library designed to retrieve system information, primarily for use within Mozilla's testing infrastructure. It acts as a bridge to normalize diverse operating system and architecture details into a consistent set of values, such as 'os', 'version', 'bits', and 'processor'. The current version is 1.2.3, and it is actively maintained as part of the broader Mozilla ecosystem.","status":"active","version":"1.2.3","language":"en","source_language":"en","source_url":"https://firefox-source-docs.mozilla.org/python/mozinfo.html","tags":["system information","mozilla","testing","platform detection","build tools"],"install":[{"cmd":"pip install mozinfo","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"The library is typically imported directly as a module to access its top-level attributes.","symbol":"mozinfo","correct":"import mozinfo"}],"quickstart":{"code":"import mozinfo\n\nprint(f\"Operating System: {mozinfo.os}\")\nprint(f\"OS Version: {mozinfo.version}\")\nprint(f\"Architecture Bits: {mozinfo.bits}\")\nprint(f\"Processor Type: {mozinfo.processor}\")\n\n# Access all info as a dictionary\nprint(\"\\nAll mozinfo attributes:\")\nfor key, value in mozinfo.info.items():\n    print(f\"  {key}: {value}\")","lang":"python","description":"The quickstart demonstrates how to import the `mozinfo` module and access its primary system information attributes directly. It also shows how to retrieve all available information as a dictionary via `mozinfo.info`."},"warnings":[{"fix":"Explicitly check `if mozinfo.os is mozinfo.unknown:` or `if mozinfo.os == 'UNKNOWN':` instead of `if not mozinfo.os:` if differentiating between `None` and `UNKNOWN` is important.","message":"The `mozinfo.unknown` singleton, used when a value cannot be determined, evaluates as `False` in boolean contexts. This can lead to unexpected behavior if not explicitly checked for `mozinfo.unknown`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure the test or script is run in a properly configured Mozilla build environment (`objdir`) if specific build-time information is expected. Alternatively, handle 'UNKNOWN' values gracefully in your code.","message":"When not executed within a Mozilla build environment (i.e., where a `mozinfo.json` file is present in the object directory), some `mozinfo` attributes might return `mozinfo.unknown` or 'UNKNOWN'. The library's full capability is realized when used in its intended context.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Refer to the documentation for available attributes (e.g., `os`, `version`, `bits`, `processor`). If you want to see all available keys, use `mozinfo.info.keys()`.","cause":"Attempting to access a system information attribute that `mozinfo` does not expose as a direct module-level variable.","error":"AttributeError: module 'mozinfo' has no attribute 'some_non_existent_attribute'"},{"fix":"Understand that `mozinfo` provides a 'Mozilla-centric' view of system info. If you require general system information outside of a Mozilla build context, consider using standard Python modules like `platform` or `os` directly.","cause":"The `mozinfo` library relies on detecting information from the environment, including potentially a `mozinfo.json` file generated during a Mozilla build. If this file isn't found or the environment isn't typical for Mozilla testing, certain attributes may default to `mozinfo.unknown` (string representation 'UNKNOWN').","error":"print(mozinfo.os) outputs 'UNKNOWN' even though my OS is clearly Windows/Linux/macOS."}]}