{"id":6026,"library":"petname","title":"Petname","description":"Petname is a Python library that generates human-readable, random names for objects by combining adverbs, adjectives, and common nouns. It's often used for generating unique hostnames or container names, providing memorable and pronounceable identifiers. The current version is 2.9, with a release cadence driven by bug fixes, security patches, and wordlist updates.","status":"active","version":"2.9","language":"en","source_language":"en","source_url":"https://github.com/dustinkirkland/python-petname","tags":["name generation","random","human-readable","utility","hostnames","identifiers"],"install":[{"cmd":"pip install petname","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The primary function `generate` is typically accessed directly as a method of the imported `petname` module, not from an instantiated class. Older examples might show a class or direct functions like `adverb()` or `name()`, but `generate()` is the main entry point for a full name.","wrong":"from petname import PetName; PetName.generate()","symbol":"generate","correct":"import petname\npetname.generate()"},{"note":"While `generate` is preferred for full names, individual word types can still be accessed directly.","symbol":"Adjective","correct":"import petname\npetname.Adjective()"},{"note":"Individual word types can be accessed directly.","symbol":"Adverb","correct":"import petname\npetname.Adverb()"},{"note":"Individual word types can be accessed directly.","symbol":"Name","correct":"import petname\npetname.Name()"}],"quickstart":{"code":"import petname\n\n# Generate a two-word name (default)\nname1 = petname.generate()\nprint(f\"Generated name: {name1}\")\n\n# Generate a three-word name with a custom separator\nname2 = petname.generate(3, '_')\nprint(f\"Generated name: {name2}\")\n\n# Generate a single-word name with max letters\nname3 = petname.generate(1, max_letters=5)\nprint(f\"Generated name: {name3}\")\n\n# Generate words from specific categories\nadjective = petname.Adjective()\nprint(f\"Random adjective: {adjective}\")","lang":"python","description":"Generate human-readable names with varying word counts and separators. The `generate()` function is the primary API. You can also access specific word types like adjectives, adverbs, or names directly."},"warnings":[{"fix":"Upgrade immediately to version 2.9 or newer: `pip install --upgrade petname`.","message":"Critical DoS Vulnerability (CVE Candidate) in versions < 2.9: Word selection functions (`petname.adverb()`, `petname.adjective()`, `petname.name()`, and consequently `petname.generate()`) could hang indefinitely, consuming 100% CPU, if the `letters` (or `max_letters`) parameter was smaller than the shortest word in the internal word lists. For example, `petname.adverb(letters=3)` could cause an infinite loop in affected versions.","severity":"breaking","affected_versions":"< 2.9"},{"fix":"No direct fix needed unless specific word availability is critical; consider auditing generated names if this is a concern. If specific words are essential, external wordlists can be used via the `wordlist` parameter in `generate()`.","message":"Wordlist changes in version 2.8: Several words (e.g., `peacock`, `cockatoo`, `woodcock`) were removed from the internal names list to maintain consistency with upstream versions and avoid potentially awkward or unprofessional combinations. If your application relied on the exact composition of previous wordlists, this change might subtly alter generated names.","severity":"gotcha","affected_versions":"2.8, 2.9"},{"fix":"Ensure that `max_letters` (or `letters` in older direct calls) is set to a reasonable value that allows for word selection. Test your name generation with chosen constraints.","message":"The `letters` parameter (now `max_letters` in `generate()`) can still lead to no names being found if constrained too strictly (e.g., `max_letters=1` when no single-letter words exist), resulting in an empty string or IndexError. While the infinite loop is fixed in 2.9, extreme constraints can still yield unexpected or empty results.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[]}