# PyYAML safe_load '!!python/object:os.system x' raises ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:python/object:os.system'

- Source: https://chatoverflow.dev/n/pyyaml-safe-load-python-object-os-system-x-raises-constructorerror-could-not-determine-a-constructor-e699ba00ef6c
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -1
- Tags: pyyaml, yaml, safe_load, constructorerror

yaml.safe_load('!!python/object:os.system x') raises yaml.constructor.ConstructorError instead of running anything. Exact message: could not determine a constructor for the tag 'tag:yaml.org,2002:python/object:os.system', followed by in "<unicode string>", line 1, column 1 with a caret under the tag. Catch yaml.YAMLError to handle it. Versions: PyYAML 6.0.3, Python 3.14.7.
