PyPI / pytest / 9.1.1

pytest 9.1.1

Source
https://github.com/pytest-dev/pytest
Tag scanned
9.1.1
Compared with
9.1.0 (0 signals introduced since)
Files
559 scanned, 42 skipped (binary, oversized, or unrecognised)
Signals
0 critical · 0 warn · 77 info
Scan time
48.4 s
LLM review
Reviewed by claude-haiku-5-5 (Anthropic): 63 of 63 warn and critical signals; 63 demoted to info.
Disclude version
4.0.0
Scanned (UTC)
2026-10-14 18:13

Signals

Ordered by severity, then signals introduced in this release. Hidden characters are shown as ⟨U+…⟩.

  1. info warn → info by review dynamic-execution doc/en/builtin.rst:109:17

    [embedded python] `os.system` called with a literal shell command (ast pass, confidence 0.70)

                def test_system_echo(capfd):
                    os.system('echo "hello"')
                    captured = capfd.readouterr()
                    assert captured.out == "hello\n"
    likely benign LLM, confidence 0.90 A documented pytest example calling os.system('echo "hello"') to demonstrate output capture.
    Reasoning

    This is a documentation example of a pytest test using os.system with a fixed echo command to show capfd capturing. The literal command is harmless and the context is clearly illustrative.

  2. info warn → info by review dynamic-execution doc/en/builtin.rst:127:17

    [embedded python] `os.system` called with a literal shell command (ast pass, confidence 0.70)

                def test_system_echo(capfdbinary):
                    os.system('echo "hello"')
                    captured = capfdbinary.readouterr()
                    assert captured.out == b"hello\n"
    likely benign LLM, confidence 0.90 A second documented pytest example running a fixed os.system echo to demonstrate binary capture.
    Reasoning

    Same pattern as the sibling finding: a fixed echo command in a capfdbinary doc example, with no external input and no malicious behavior.

  3. info warn → info by review dynamic-execution doc/en/example/assertion/failure_demo.py:201:12

    `compile` called on a non-literal expression (ast pass, confidence 0.70)

        module = importlib.util.module_from_spec(spec)
        code = compile(src, name, "exec")
        exec(code, module.__dict__)
        sys.modules[name] = module
    likely benign LLM, confidence 0.85 A demo helper that compiles a source string into a module for assertion-failure illustration.
    Reasoning

    This is pytest's assertion failure demo, which intentionally loads a generated module from a source string to show rewriting behavior. The compile is part of a demo, not a hidden payload.

  4. info warn → info by review dynamic-execution doc/en/example/assertion/failure_demo.py:202:5

    `exec` called on a non-literal expression (ast pass, confidence 0.70)

        code = compile(src, name, "exec")
        exec(code, module.__dict__)
        sys.modules[name] = module
        module.foo()
    likely benign LLM, confidence 0.85 Executes the demo module code it just compiled, as part of the assertion failure example.
    Reasoning

    The exec runs the code produced by the demo's own compile step inside a module namespace it created, as part of the demonstration. Nothing here fetches or hides code from outside the example.

  5. info warn → info by review dynamic-execution doc/en/example/assertion/test_setup_flow_example.py:16:19

    `eval` called on a non-literal expression (ast pass, confidence 0.70)

        def setup_method(self, method):
            self.id = eval(method.__name__[5:])
    
        def test_42(self):
    likely benign LLM, confidence 0.85 An example test class using eval on the test method name to set an id.
    Reasoning

    This is a test example that derives an id by evaluating a slice of the method name. It is a contrived but harmless illustration in a documentation test file.

  6. info warn → info by review dynamic-execution doc/en/example/parametrize.rst:627:16

    [embedded python] `eval` called on a non-literal expression (ast pass, confidence 0.70)

        def test_eval(test_input, expected):
            assert eval(test_input) == expected
    likely benign LLM, confidence 0.90 A doc snippet using eval on parametrized test input.
    Reasoning

    Documentation of pytest parametrization showing eval of test input strings as a teaching example. It is not run against untrusted input.

  7. info warn → info by review dynamic-execution doc/en/historical-notes.rst:183:16

    [embedded python] `eval` called on a non-literal expression (ast pass, confidence 0.70)

        def test_eval(test_input, expected):
            assert eval(test_input) == expected
    likely benign LLM, confidence 0.90 A historical docs example using eval on test input.
    Reasoning

    Historical doc example of parametrized eval-based tests. The code is illustrative and inert.

  8. info warn → info by review dynamic-execution doc/en/historical-notes.rst:233:3

    [markup prose] `eval` called on a string literal (ast pass, confidence 0.85)

    ``eval('sys.version_info >= (3,0)', namespace)``.  The namespace contains
    dismissed LLM, confidence 0.90 Inline prose mentioning eval of a version check string.
    Reasoning

    The match is inside prose describing an eval expression in inline markup, not executable code.

  9. info critical → info by review dynamic-execution doc/en/how-to/bash-completion.rst:33:5

    [embedded bash] `eval` called on a dynamic (variable/substitution) expression (ast pass, confidence 0.90)

        eval "$(register-python-argcomplete pytest)"
    likely benign LLM, confidence 0.80 Documented instruction to eval the output of register-python-argcomplete for bash completion.
    Reasoning

    This is the documented install step for pytest's shell completion, eval of a command substitution from the official register-python-argcomplete tool. It is a common pattern and is the expected usage, though it does execute generated shell code.

  10. info warn → info by review dynamic-execution doc/en/how-to/parametrize.rst:50:16

    [embedded python] `eval` called on a non-literal expression (ast pass, confidence 0.70)

        def test_eval(test_input, expected):
            assert eval(test_input) == expected
    likely benign LLM, confidence 0.90 A how-to docs example using eval on test input.
    Reasoning

    Standard pytest doc example of eval on parametrized input in a code block. Illustrative only.

  11. info warn → info by review dynamic-execution doc/en/how-to/parametrize.rst:73:5

    [markup prose] `eval` called on a string literal (ast pass, confidence 0.85)

        >       assert eval(test_input) == expected
    dismissed LLM, confidence 0.90 Doc output fragment that includes eval in an assertion line.
    Reasoning

    The match is a doc output/traceback fragment showing an assertion failure, not executable code.

  12. info warn → info by review dynamic-execution doc/en/how-to/parametrize.rst:172:16

    [embedded python] `eval` called on a non-literal expression (ast pass, confidence 0.70)

        def test_eval(test_input, expected):
            assert eval(test_input) == expected
    likely benign LLM, confidence 0.90 A repeated docs example using eval on test input.
    Reasoning

    Another instance of the same illustrative eval-based parametrize example in pytest documentation.

  13. info warn → info by review whitespace-anomaly doc/en/how-to/writing_plugins.rst:92:2

    invisible whitespace U+00A0 in indentation (raw pass, confidence 0.80)

    
     ⟨U+00A0⟩ ⟨U+00A0⟩ pytest test_flat.py --capture=no  # will not show "setting up"
         pytest a/test_sub.py --capture=no  # will show "setting up"
    likely benign LLM, confidence 0.70 A non-breaking space appears in the indentation of a shell example in the plugin docs.
    Reasoning

    A non-breaking space in indentation of an RST example block is a common copy-paste or editor artifact in docs. It is a formatting issue, not an attack, though it is a minor anomaly worth cleaning up.

  14. info warn → info by review unicode-homoglyph doc/en/reference/plugin_list.rst:1250:168

    identifier `о` contains homoglyph candidates: о (043E)→o (raw pass, confidence 0.70)

    �зличные каналы связи о статуе прохождения тестов.                                                                                                                                                                                                                                  … (341 bytes total)
    dismissed LLM, confidence 0.90 Cyrillic letter in a Russian-language plugin description in the pytest plugin list docs.
    Reasoning

    The flagged character is a Cyrillic 'о' inside Russian prose in a plugin description, not inside an identifier or code. Homoglyph checks fire on natural-language text in a non-English docs file, so this is a false positive.

  15. info warn → info by review unicode-homoglyph doc/en/reference/plugin_list.rst:10554:113

    identifier `о` contains homoglyph candidates: о (043E)→o (raw pass, confidence 0.70)

    
         Pytest plugin для отправки нотификаций в различные каналы связи о статуе прохождения тестов.
    
      :pypi:`pytest_notify`
    dismissed LLM, confidence 0.90 Cyrillic letter in a Russian-language description of the pytest_notify plugin.
    Reasoning

    Same as the other finding: a Cyrillic 'о' in the Russian description text of the pytest_notify plugin entry. It is ordinary localized prose, not a spoofed identifier.

  16. info warn → info by review dynamic-execution src/_pytest/_code/code.py:173:16

    `eval` called on a non-literal expression (ast pass, confidence 0.70)

            f_locals.update(vars)
            return eval(code, self.f_globals, f_locals)
    
        def repr(self, object: object) -> str:
    dismissed LLM, confidence 0.90 eval on a code string inside pytest's frame-evaluation helper.
    Reasoning

    This is pytest's Traceback/Frame.eval, which evaluates a caller-supplied expression in a frame's globals and locals. That is its documented purpose for debugging and assertion introspection, not a hidden payload.

  17. info critical → info by review dynamic-import src/_pytest/_py/path.py:626:23

    `__import__` called on a non-literal expression (ast pass, confidence 0.70)

                        hashtype = "sha"
                    mod = __import__(hashtype)
                hash = getattr(mod, hashtype)()
            except (AttributeError, ImportError):
    dismissed LLM, confidence 0.90 Dynamic __import__ selecting a hashlib module for file hashing in the vendored py.path code.
    Reasoning

    __import__ is called with a hash-type name chosen from a fixed set (sha, md5 variants) to load the hashlib module for computing file checksums. The dynamic name is limited to known hashing modules, so this is a benign pattern.

  18. info critical → info by review dynamic-import src/_pytest/_py/path.py:1118:13

    `__import__` called on a non-literal expression (ast pass, confidence 0.70)

                self._ensuresyspath(ensuresyspath, pkgroot)
                __import__(modname)
                mod = sys.modules[modname]
                if self.basename == "__init__.py":
    dismissed LLM, confidence 0.88 Dynamic __import__ of a package module name inside the vendored py.path pyimport routine.
    Reasoning

    This is the pyimport implementation of py.path, which imports a module by name derived from the file's package path. Dynamic import is the mechanism of that API, and the module name comes from the local filesystem layout.

  19. info warn → info by review decoder-import-with-exec src/_pytest/_py/path.py:1153:25

    file imports decoder module(s) pickle and calls `exec`/`eval`/`compile` — multi-stage payload shape (ast pass, confidence 0.80)

                        with open(str(self), "rb") as f:
                            exec(f.read(), mod.__dict__)
                    except BaseException:
                        del sys.modules[modname]
    likely benign LLM, confidence 0.80 Manual module load that reads a source file and execs it into a module namespace in py.path.pyimport.
    Reasoning

    The file reads a .py source file and executes it in a module's __dict__, reimplementing import for pyimport. The 'pickle' decoder-import signal is spurious here, since the code path loads Python source rather than pickled payloads. Executing a module the user asked to import is the intended behavior, though this is a legitimate but sensitive import mechanism.

  20. info warn → info by review dynamic-execution src/_pytest/_py/path.py:1153:25

    `exec` called on a non-literal expression (ast pass, confidence 0.70)

                        with open(str(self), "rb") as f:
                            exec(f.read(), mod.__dict__)
                    except BaseException:
                        del sys.modules[modname]
    likely benign LLM, confidence 0.80 Exec of a module file's contents into its module namespace in py.path.pyimport.
    Reasoning

    Same exec of a module file's bytes into mod.__dict__ as the paired finding. It is the module-loading implementation of py.path, with the pickle decoder signal being a false match.

  21. info warn → info by review decoder-import-with-exec src/_pytest/assertion/rewrite.py:188:9

    file imports decoder module(s) marshal and calls `exec`/`eval`/`compile` — multi-stage payload shape (ast pass, confidence 0.80)

                state.trace(f"found cached rewritten pyc for {fn}")
            exec(co, module.__dict__)
    
        def _early_rewrite_bailout(self, name: str, state: AssertionState) -> bool:
    dismissed LLM, confidence 0.90 Execution of a cached rewritten code object into a module's namespace in pytest's assertion rewriter.
    Reasoning

    pytest's assertion rewriter loads a cached rewritten .pyc through marshal and execs the code object into the module dict. This is standard import-hook behavior; the marshal signal reflects the normal pyc mechanism, not a dropper.

  22. info warn → info by review dynamic-execution src/_pytest/assertion/rewrite.py:188:9

    `exec` called on a non-literal expression (ast pass, confidence 0.70)

                state.trace(f"found cached rewritten pyc for {fn}")
            exec(co, module.__dict__)
    
        def _early_rewrite_bailout(self, name: str, state: AssertionState) -> bool:
    dismissed LLM, confidence 0.90 Exec of a cached rewritten code object in pytest's assertion rewriter.
    Reasoning

    Duplicate of the exec of cached rewritten bytecode in the assertion rewriter. It is the expected loader step for pytest's pyc cache.

  23. info warn → info by review dynamic-execution src/_pytest/assertion/rewrite.py:350:10

    `compile` called on a non-literal expression (ast pass, confidence 0.70)

        rewrite_asserts(tree, source, strfn, config)
        co = compile(tree, strfn, "exec", dont_inherit=True)
        return stat, co
    dismissed LLM, confidence 0.90 compile of the rewritten AST for test modules in pytest's assertion rewriter.
    Reasoning

    compile is applied to an AST produced by pytest's own assertion-rewriting transform of the test module's source. Compiling the rewritten tree is the core function of the rewriter.

  24. info warn → info by review dynamic-execution src/_pytest/assertion/rewrite.py:393:18

    `marshal.load` deserializes Python bytecode from bytes — code-object sink (ast pass, confidence 0.75)

            try:
                co = marshal.load(fp)
            except Exception as e:
                trace(f"_read_pyc({source}): marshal.load error {e}")
    likely benign LLM, confidence 0.85 marshal.load of a cached pyc file in pytest's assertion rewriter's read path.
    Reasoning

    marshal.load reads pytest's own .pyc cache file for rewritten test modules. Deserializing marshal data from a local cache is a known trust-boundary concern, but this is the standard bytecode cache path, not an obfuscated payload.

  25. info critical → info by review dynamic-import src/_pytest/config/__init__.py:917:17

    `__import__` called on a non-literal expression (ast pass, confidence 0.70)

                    # testing/test_config.py::test_disable_plugin_autoload.
                    __import__(importspec)
                    mod = sys.modules[importspec]
            except ImportError as e:
    likely benign LLM, confidence 0.90 Imports a pytest plugin module by name during plugin loading.
    Reasoning

    This is the standard pytest plugin import path, where importspec is a module name from entry points or the -p option. It is a non-literal import by design, and the surrounding code handles ImportError and sys.modules lookup as expected.

  26. info warn → info by review frame-introspection src/_pytest/config/__init__.py:1657:21

    `sys._getframe` — call-stack frame introspection (ast pass, confidence 0.70)

            if records:
                frame = sys._getframe(stacklevel - 1)
                location = frame.f_code.co_filename, frame.f_lineno, frame.f_code.co_name
                self.hook.pytest_warning_recorded.call_historic(
    likely benign LLM, confidence 0.93 Reads the caller's frame to attach file and line location to a recorded warning.
    Reasoning

    sys._getframe(stacklevel - 1) is used to record the source location for a pytest warning, a common pattern for attributing warnings to the calling code. It only reads filename, line number and function name.

  27. info warn → info by review frame-introspection src/_pytest/debugging.py:281:17

    `sys._getframe` — call-stack frame introspection (ast pass, confidence 0.70)

            """Invoke debugging via ``Pdb.set_trace``, dropping any IO capturing."""
            frame = sys._getframe().f_back
            _pdb = cls._init_pdb("set_trace", *args, **kwargs)
            _pdb.set_trace(frame)
    likely benign LLM, confidence 0.93 Gets the caller's frame so pdb can start a trace there.
    Reasoning

    This is the implementation of pytest.set_trace, which deliberately grabs the caller's frame to start pdb at that point. That is the documented purpose of the function.

  28. info warn → info by review frame-introspection src/_pytest/fixtures.py:745:21

    `inspect.stack` — call-stack frame introspection (ast pass, confidence 0.70)

            if has_params:
                frame = inspect.stack()[3]
                frameinfo = inspect.getframeinfo(frame[0])
                source_path = absolutepath(frameinfo.filename)
    likely benign LLM, confidence 0.90 Inspects the call stack to find the source file of a fixture definition.
    Reasoning

    inspect.stack()[3] is used to locate the file where a fixture is defined, so pytest can report its source path. This is a normal introspection pattern for test frameworks.

  29. info warn → info by review dynamic-execution src/_pytest/mark/expression.py:333:16

    `compile` called on a non-literal expression (ast pass, confidence 0.70)

            astexpr = expression(Scanner(input))
            code = compile(
                astexpr,
                filename="<pytest match expression>",
    likely benign LLM, confidence 0.90 Compiles the parsed -k/-m match expression into a code object.
    Reasoning

    This compiles an AST built by pytest's own expression parser for -k and -m matching. The input is the parsed expression AST, not arbitrary attacker-controlled code, and the filename is a fixed label.

  30. info warn → info by review dynamic-execution src/_pytest/mark/expression.py:353:21

    `eval` called on a non-literal expression (ast pass, confidence 0.70)

            """
            return bool(eval(self._code, {"__builtins__": {}}, MatcherAdapter(matcher)))
    likely benign LLM, confidence 0.88 Evaluates the compiled -k/-m expression against test names and marks with no builtins.
    Reasoning

    eval runs the compiled match expression with __builtins__ emptied and only a matcher adapter as locals. This is a restricted evaluator for user-supplied -k/-m expressions, which is the intended design.

  31. info warn → info by review dynamic-execution src/_pytest/outcomes.py:249:5

    `compile` called on a non-literal expression (ast pass, confidence 0.70)

        __tracebackhide__ = True
        compile(modname, "", "eval")  # to catch syntaxerrors
    
        # Keep the public signature compatible while using the pytest 9.1 default behavior.
    likely benign LLM, confidence 0.90 Compiles a string solely to validate its syntax, discarding the result.
    Reasoning

    compile(modname, '', 'eval') is used only to raise SyntaxError for an invalid module name, and the result is discarded. The comment confirms that purpose.

  32. info critical → info by review frame-introspection src/_pytest/pytester.py:290:27

    `sys._getframe` — call-stack frame introspection — file also calls `sys.exit`/`exec`/`eval` (anti-analysis shape) (ast pass, confidence 0.85)

            # Since Python 3.13, f_locals is not a dict, but eval requires a dict.
            backlocals = dict(sys._getframe(1).f_locals)
            while entries:
                name, check = entries.pop(0)
    likely benign LLM, confidence 0.85 Copies the caller's frame locals so test check expressions can be evaluated against recorded calls.
    Reasoning

    pytester's LineMatcher-style helper copies the caller's locals to evaluate check expressions in test-assertion helpers. The critical severity comes from the anti-analysis heuristic matching on sys.exit/eval in the same file, not from any evasive behavior. The code is test-support tooling.

  33. info warn → info by review dynamic-execution src/_pytest/pytester.py:296:24

    `eval` called on a non-literal expression (ast pass, confidence 0.70)

                        print("NAMEMATCH", name, call)
                        if eval(check, backlocals, call.__dict__):
                            print("CHECKERMATCH", repr(check), "->", call)
                        else:
    likely benign LLM, confidence 0.85 Evaluates a check expression against recorded call attributes in pytester.
    Reasoning

    This evaluates test-author-supplied check expressions against recorded call objects inside a pytester helper. It is test tooling run on the developer's own test code, not a hidden payload.

  34. info warn → info by review dynamic-execution src/_pytest/skipping.py:118:30

    `compile` called on a non-literal expression (ast pass, confidence 0.70)

                filename = f"<{mark.name} condition>"
                condition_code = compile(condition, filename, "eval")
                result = eval(condition_code, globals_)
            except SyntaxError as exc:
    likely benign LLM, confidence 0.88 Compiles a skipif/xfail string condition from a test mark.
    Reasoning

    This compiles string skipif/xfail conditions, which pytest documents as a feature. The condition comes from the test author's marks and is evaluated in a controlled globals dict.

  35. info warn → info by review dynamic-execution src/_pytest/skipping.py:119:22

    `eval` called on a non-literal expression (ast pass, confidence 0.70)

                condition_code = compile(condition, filename, "eval")
                result = eval(condition_code, globals_)
            except SyntaxError as exc:
                msglines = [
    likely benign LLM, confidence 0.88 Evaluates a skipif/xfail string condition from a test mark.
    Reasoning

    This evaluates the compiled skipif/xfail condition, which is the documented string-condition feature of pytest. It is the same code path as the compile call above.

  36. info critical → info by review frame-introspection testing/code/test_code.py:62:16

    `sys._getframe` — call-stack frame introspection — file also calls `sys.exit`/`exec`/`eval` (anti-analysis shape) (ast pass, confidence 0.85)

        def func() -> FrameType:
            return sys._getframe(0)
    
        f = Frame(func())
    likely benign LLM, confidence 0.93 Test helper that returns the current frame to exercise the Frame wrapper class.
    Reasoning

    This is a unit test that calls sys._getframe(0) to verify that the Frame wrapper works. The critical severity comes from the anti-analysis heuristic, and the snippet shows no evasive behavior.

  37. info critical → info by review frame-introspection testing/code/test_code.py:72:16

    `sys._getframe` — call-stack frame introspection — file also calls `sys.exit`/`exec`/`eval` (anti-analysis shape) (ast pass, confidence 0.85)

        def func() -> FrameType:
            return sys._getframe(0)
    
        f = Frame(func())
    likely benign LLM, confidence 0.95 Test helper calling sys._getframe(0) to exercise pytest's Frame wrapper.
    Reasoning

    This is pytest's own test suite for its code-introspection helpers; sys._getframe is used deliberately to test Frame objects. Benign test code.

  38. info critical → info by review frame-introspection testing/code/test_code.py:135:16

    `sys._getframe` — call-stack frame introspection — file also calls `sys.exit`/`exec`/`eval` (anti-analysis shape) (ast pass, confidence 0.85)

        def f1(x) -> FrameType:
            return sys._getframe(0)
    
        fr1 = Frame(f1("a"))
    likely benign LLM, confidence 0.95 Test function returning sys._getframe(0) to build a Frame for testing.
    Reasoning

    Same pattern in pytest's test suite testing frame introspection with varied signatures; no malicious behavior.

  39. info critical → info by review frame-introspection testing/code/test_code.py:141:16

    `sys._getframe` — call-stack frame introspection — file also calls `sys.exit`/`exec`/`eval` (anti-analysis shape) (ast pass, confidence 0.85)

        def f2(x, *y) -> FrameType:
            return sys._getframe(0)
    
        fr2 = Frame(f2("a", "b", "c"))
    likely benign LLM, confidence 0.95 Test function returning its own frame for Frame API tests.
    Reasoning

    Pytest test fixture exercising frame capture with *args; benign test scaffolding.

  40. info critical → info by review frame-introspection testing/code/test_code.py:147:16

    `sys._getframe` — call-stack frame introspection — file also calls `sys.exit`/`exec`/`eval` (anti-analysis shape) (ast pass, confidence 0.85)

        def f3(x, **z) -> FrameType:
            return sys._getframe(0)
    
        fr3 = Frame(f3("a", b="c"))
    likely benign LLM, confidence 0.95 Test function returning its own frame, variant with keyword args.
    Reasoning

    Pytest test code checking frame introspection with **kwargs; expected behavior for the library under test.

  41. info critical → info by review frame-introspection testing/code/test_code.py:153:16

    `sys._getframe` — call-stack frame introspection — file also calls `sys.exit`/`exec`/`eval` (anti-analysis shape) (ast pass, confidence 0.85)

        def f4(x, *y, **z) -> FrameType:
            return sys._getframe(0)
    
        fr4 = Frame(f4("a", "b", c="d"))
    likely benign LLM, confidence 0.95 Test function returning its own frame, variant with *args and **kwargs.
    Reasoning

    Pytest test covering frame introspection with mixed arguments; benign.

  42. info warn → info by review dynamic-execution testing/code/test_excinfo.py:666:13

    `exec` called on a non-literal expression (ast pass, confidence 0.70)

            try:
                exec(co)
            except ValueError:
                excinfo = _pytest._code.ExceptionInfo.from_current()
    likely benign LLM, confidence 0.93 Test executes a compiled code object to produce an exception for ExceptionInfo testing.
    Reasoning

    Pytest's excinfo tests compile and exec a code object deliberately to generate a traceback for testing; not obfuscation.

  43. info warn → info by review dynamic-execution testing/code/test_excinfo.py:684:13

    `exec` called on a non-literal expression (ast pass, confidence 0.70)

            try:
                exec(co)
            except ValueError:
                excinfo = _pytest._code.ExceptionInfo.from_current()
    likely benign LLM, confidence 0.93 Test execs a compiled snippet to raise an error for traceback assertions.
    Reasoning

    Same deliberate exec of a test code object in pytest's excinfo test suite.

  44. info critical → info by review frame-introspection testing/code/test_excinfo.py:1056:23

    `sys._getframe` — call-stack frame introspection — file also calls `sys.exit`/`exec`/`eval` (anti-analysis shape) (ast pass, confidence 0.85)

                nonlocal raised
                upframe = sys._getframe().f_back
                assert upframe is not None
                if upframe.f_code.co_name == "_makepath":
    likely benign LLM, confidence 0.94 Test inspects the upper frame's code name to verify path creation.
    Reasoning

    Test checking the calling function name via frame back-reference, a normal pattern in pytest tests.

  45. info critical → info by review frame-introspection testing/code/test_source.py:221:21

    `sys._getframe` — call-stack frame introspection — file also calls `sys.exit`/`exec`/`eval` (anti-analysis shape) (ast pass, confidence 0.85)

            def __init__(self, *args) -> None:
                frame = sys._getframe(1)
                self.source = Frame(frame).statement
    likely benign LLM, confidence 0.94 Exception-like class capturing caller frame to extract its source statement.
    Reasoning

    Pytest source-inspection code capturing the caller frame to record a statement; legitimate library behavior.

  46. info warn → info by review dynamic-execution testing/code/test_source.py:331:10

    `compile` called on a non-literal expression (ast pass, confidence 0.70)

        lines = ["if 1:\n", "    def x():\n", "          pass\n"]
        co = compile("".join(lines), filename, "exec")
    
        monkeypatch.setitem(linecache.cache, filename, (1, None, lines, filename))
    likely benign LLM, confidence 0.93 Test compiles a small generated code snippet for source-lookup testing.
    Reasoning

    Test compiles a fixed source string to check linecache and findsource behavior; benign.

  47. info warn → info by review dynamic-execution testing/code/test_source.py:340:5

    `eval` called on a non-literal expression (ast pass, confidence 0.70)

        d: dict[str, Any] = {}
        eval(co, d)
        src, lineno = findsource(d["x"])
        assert src is not None
    likely benign LLM, confidence 0.93 Test evals a compiled code object to check source location lookup.
    Reasoning

    Test evaluates a compiled code object in a dict namespace to verify findsource; benign test logic.

  48. info critical → info by review frame-introspection testing/code/test_source.py:643:21

    `sys._getframe` — call-stack frame introspection — file also calls `sys.exit`/`exec`/`eval` (anti-analysis shape) (ast pass, confidence 0.85)

            def __init__(self, *args):
                frame = sys._getframe(1)
                self.source = Frame(frame).statement
    likely benign LLM, confidence 0.94 Exception-like class capturing caller frame to extract its source statement.
    Reasoning

    Duplicate of the pytest source-inspection frame capture pattern; legitimate.

  49. info critical → info by review dynamic-execution testing/code/test_source.py:673:16

    `compile` called on a constructed string (ast pass, confidence 0.80)

            LINES = 99
            return compile("\ndef a():\n" + "\n" * LINES + "    pass", *args, **kwargs)
        # fmt: on
    likely benign LLM, confidence 0.90 Test helper compiling generated Python source to check line numbering.
    Reasoning

    This is a pytest test helper that compiles a constructed source string with padding lines to test line-number handling. It is a test fixture for source-code utilities, not a payload.

  50. info warn → info by review frame-introspection testing/conftest.py:27:13

    `sys.settrace` — call-stack frame introspection (ast pass, confidence 0.70)

            if sys.gettrace() != orig_trace:
                sys.settrace(orig_trace)
    likely benign LLM, confidence 0.85 Test fixture restoring the original sys trace function after a check.
    Reasoning

    Restoring the original trace function in a test conftest is a standard pattern to ensure tests do not leak a settrace hook; no malicious use is visible.

  51. 25 of 58 non-conventional identifiers are single-character (43%) (token pass, confidence 0.50)

  52. info critical → info by review dynamic-execution testing/freeze/create_executable.py:16:5

    `subprocess.check_call` with `shell=True` and a non-literal command — runtime-determined shell invocation (ast pass, confidence 0.85)

        args = ["pyinstaller", "--noconfirm", *hidden, "runtests_script.py"]
        subprocess.check_call(" ".join(args), shell=True)
    likely benign LLM, confidence 0.80 Build script invoking PyInstaller via a shell command assembled from local arguments.
    Reasoning

    This is a freeze-test script building a PyInstaller command from a fixed list of arguments. shell=True with a joined list is poor practice but the inputs are local constants, not attacker-controlled. Still, the pattern is a shell call worth noting in a test tool.

  53. info warn → info by review dynamic-execution testing/freeze/tox_run.py:16:14

    `os.system` called with a literal shell command (ast pass, confidence 0.70)

            executable += ".exe"
        sys.exit(os.system(f"{executable} tests"))
    likely benign LLM, confidence 0.90 Test runner calling os.system on the frozen test executable.
    Reasoning

    Runs a locally built test executable with a literal suffix in a freeze test runner. The command is a fixed test invocation with no external input.

  54. info unicode-mixed-script testing/io/test_terminalwriter.py:251:19

    identifier `乇乂ㄒ尺卂` mixes scripts: Han + Other (in string/comment) (raw pass, confidence 0.40)

            tw = terminalwriter.TerminalWriter()
            tw.write("乇乂ㄒ尺卂 ㄒ卄丨匚匚")
            assert tw.width_of_current_line == 21  # 5*2 + 1 + 5*2
  55. info unicode-mixed-script testing/io/test_terminalwriter.py:251:35

    identifier `ㄒ卄丨匚匚` mixes scripts: Other + Han (in string/comment) (raw pass, confidence 0.40)

            tw = terminalwriter.TerminalWriter()
            tw.write("乇乂ㄒ尺卂 ㄒ卄丨匚匚")
            assert tw.width_of_current_line == 21  # 5*2 + 1 + 5*2
  56. info unicode-mixed-script testing/python/metafunc.py:362:26

    identifier `ιμή` mixes scripts: Greek + Latin (in string/comment) (raw pass, confidence 0.40)

                (
                    r"δοκ.ιμή@παράδειγμα.δοκιμή",
                    r"\u03b4\u03bf\u03ba.\u03b9\u03bc\u03ae@\u03c0\u03b1\u03c1\u03ac\u03b4\u03b5\u03b9\u03b3"
                    r"\u03bc\u03b1.\u03b4\u03bf\u03ba\u03b9\u03bc\u03ae",
  57. info unicode-homoglyph testing/python/metafunc.py:362:33

    identifier `παράδειγμα` contains homoglyph candidates: α (03B1)→a, ρ (03C1)→p, α (03B1)→a (in string/comment) (raw pass, confidence 0.35)

                (
                    r"δοκ.ιμή@παράδειγμα.δοκιμή",
                    r"\u03b4\u03bf\u03ba.\u03b9\u03bc\u03ae@\u03c0\u03b1\u03c1\u03ac\u03b4\u03b5\u03b9\u03b3"
                    r"\u03bc\u03b1.\u03b4\u03bf\u03ba\u03b9\u03bc\u03ae",
  58. info unicode-mixed-script testing/python/metafunc.py:362:33

    identifier `παράδειγμα` mixes scripts: Greek + Latin (in string/comment) (raw pass, confidence 0.40)

                (
                    r"δοκ.ιμή@παράδειγμα.δοκιμή",
                    r"\u03b4\u03bf\u03ba.\u03b9\u03bc\u03ae@\u03c0\u03b1\u03c1\u03ac\u03b4\u03b5\u03b9\u03b3"
                    r"\u03bc\u03b1.\u03b4\u03bf\u03ba\u03b9\u03bc\u03ae",
  59. info unicode-homoglyph testing/python/metafunc.py:362:54

    identifier `δοκιμή` contains homoglyph candidates: ο (03BF)→o, κ (03BA)→k (in string/comment) (raw pass, confidence 0.35)

                (
                    r"δοκ.ιμή@παράδειγμα.δοκιμή",
                    r"\u03b4\u03bf\u03ba.\u03b9\u03bc\u03ae@\u03c0\u03b1\u03c1\u03ac\u03b4\u03b5\u03b9\u03b3"
                    r"\u03bc\u03b1.\u03b4\u03bf\u03ba\u03b9\u03bc\u03ae",
  60. info unicode-mixed-script testing/python/metafunc.py:362:54

    identifier `δοκιμή` mixes scripts: Greek + Latin (in string/comment) (raw pass, confidence 0.40)

                (
                    r"δοκ.ιμή@παράδειγμα.δοκιμή",
                    r"\u03b4\u03bf\u03ba.\u03b9\u03bc\u03ae@\u03c0\u03b1\u03c1\u03ac\u03b4\u03b5\u03b9\u03b3"
                    r"\u03bc\u03b1.\u03b4\u03bf\u03ba\u03b9\u03bc\u03ae",
  61. info warn → info by review dynamic-execution testing/python/raises_group.py:1210:18

    `eval` called on a non-literal expression (ast pass, confidence 0.70)

        def check_str_and_repr(s: str) -> None:
            evaled = eval(s)
            assert s == str(evaled) == repr(evaled)
    likely benign LLM, confidence 0.85 Test helper evaluating test-supplied strings to verify repr behavior.
    Reasoning

    Inside a test checking string and repr round-tripping of exception group representations, eval is applied to test-provided strings. This is a test of evaluation behavior, not a hidden payload.

  62. info warn → info by review decoder-import-with-exec testing/test_assertrewrite.py:55:12

    file imports decoder module(s) marshal and calls `exec`/`eval`/`compile` — multi-stage payload shape (ast pass, confidence 0.80)

        mod = rewrite(src)
        code = compile(mod, "<test>", "exec")
        ns: dict[str, object] = {}
        if extra_ns is not None:
    likely benign LLM, confidence 0.85 Assertion-rewrite test helper compiling and executing rewritten test source.
    Reasoning

    This is pytest's assertion-rewrite test harness, which compiles rewritten AST modules and execs them. The marshal and compile pattern is an artifact of testing the rewriter, not a multi-stage dropper.

  63. info warn → info by review dynamic-execution testing/test_assertrewrite.py:55:12

    `compile` called on a non-literal expression (ast pass, confidence 0.70)

        mod = rewrite(src)
        code = compile(mod, "<test>", "exec")
        ns: dict[str, object] = {}
        if extra_ns is not None:
    likely benign LLM, confidence 0.85 Test harness compiling rewritten module source.
    Reasoning

    compile of a rewritten module in the assertion-rewrite test harness is the expected operation under test. Input is locally generated test source.

  64. info warn → info by review dynamic-execution testing/test_assertrewrite.py:59:5

    `exec` called on a non-literal expression (ast pass, confidence 0.70)

            ns.update(extra_ns)
        exec(code, ns)
        func = ns[f.__name__]
        try:
    likely benign LLM, confidence 0.85 Test harness executing compiled test function in a namespace.
    Reasoning

    exec of compiled test code in a fresh namespace is how the assertion-rewrite tests run their generated functions. No external or encoded input is involved.

  65. info critical → info by review frame-introspection testing/test_assertrewrite.py:150:25

    `inspect.currentframe` — call-stack frame introspection — file also calls `sys.exit`/`exec`/`eval` (anti-analysis shape) (ast pass, confidence 0.85)

                def loc(msg: str | None = None) -> None:
                    frame = inspect.currentframe()
                    assert frame
                    frame = frame.f_back
    likely benign LLM, confidence 0.85 Test helper reading caller frame to check reported line locations.
    Reasoning

    Using inspect.currentframe to compute the caller line for location assertions is a common test technique in pytest's rewrite tests. The sys.exit/exec co-occurrence reflects test scaffolding, not anti-analysis.

  66. info warn → info by review dynamic-execution testing/test_assertrewrite.py:176:19

    `compile` called on a non-literal expression (ast pass, confidence 0.70)

                m = rewrite(s)
                mod = compile(m, "<string>", "exec")
                exec(mod, globals, globals)
                transformed_locations = locations
    likely benign LLM, confidence 0.85 Test code compiling and executing rewritten source to check locations.
    Reasoning

    Compile and exec of rewritten source with locations tracking is part of the assertion-rewrite location tests, operating on local test strings.

  67. info warn → info by review dynamic-execution testing/test_assertrewrite.py:177:13

    `exec` called on a non-literal expression (ast pass, confidence 0.70)

                mod = compile(m, "<string>", "exec")
                exec(mod, globals, globals)
                transformed_locations = locations
                locations = []
    likely benign LLM, confidence 0.85 Test code executing rewritten module for location checks.
    Reasoning

    Executing the compiled rewritten module in the test's globals is expected for this test harness; the source is local test data.

  68. info warn → info by review dynamic-execution testing/test_assertrewrite.py:181:19

    `compile` called on a non-literal expression (ast pass, confidence 0.70)

    
                mod = compile(s, "<string>", "exec")
                exec(mod, globals, globals)
                original_locations = locations
    likely benign LLM, confidence 0.85 Test code compiling source to compare original locations.
    Reasoning

    Compile of a test-provided source string in the location-checking test, matching the surrounding pattern of the pytest rewrite test suite.

  69. info warn → info by review dynamic-execution testing/test_assertrewrite.py:182:13

    `exec` called on a non-literal expression (ast pass, confidence 0.70)

                mod = compile(s, "<string>", "exec")
                exec(mod, globals, globals)
                original_locations = locations
    likely benign LLM, confidence 0.85 Test code executing source to record original locations.
    Reasoning

    Executing compiled test source to capture original locations is standard in this pytest test module, with no external or encoded input.

  70. info warn → info by review dynamic-execution testing/test_assertrewrite.py:1407:30

    `compile` called on a non-literal expression (ast pass, confidence 0.70)

    
            code = marshal.dumps(compile(source_bytes, str(source), "exec"))
    
            # Good header.
    likely benign LLM, confidence 0.85 Test code that compiles source bytes and marshals them to build a .pyc file for assertion-rewrite testing.
    Reasoning

    This is a pytest test file exercising assertion rewriting. The compile call is on source_bytes produced from a test fixture, inside a test that builds a .pyc with a header via marshal. Compiling a non-literal is the expected behavior for testing pyc generation, not malicious execution.

  71. info unicode-homoglyph testing/test_doctest.py:764:29

    identifier `с` contains homoglyph candidates: с (0441)→c (in string/comment) (raw pass, confidence 0.35)

                    """
                    >>> name = 'с' # not letter 'c' but instead Cyrillic 's'.
                    'anything'
                    """
  72. info unicode-mixed-script testing/test_mark_expression.py:169:10

    identifier `aaאבגדcc` mixes scripts: Latin + Hebrew (in string/comment) (raw pass, confidence 0.40)

            "אבגד",
            "aaאבגדcc",
            "a[bcd]",
            "1234",
  73. info warn → info by review unicode-mixed-script testing/test_mark_expression.py:266:50

    identifier `aaאבגדcc` mixes scripts: Latin + Hebrew (raw pass, confidence 0.80)

            pytest.mark.str_mark(  # pylint: disable-next=non-ascii-name
                m="M", space="with space", empty="", aaאבגדcc="aaאבגדcc", אבגד="אבגד"
            ).mark,
        ]
    likely benign LLM, confidence 0.90 Test fixture using a mixed Latin/Hebrew keyword argument to exercise non-ASCII mark names in pytest.
    Reasoning

    The identifier mixes Latin and Hebrew letters, but this is a deliberate test of non-ASCII keyword handling in pytest mark expressions. The file is in the testing directory, the code carries a pylint disable comment for non-ascii-name, and the paired keyword uses the same Hebrew text. This is intentional test data, not obfuscation.

  74. info unicode-mixed-script testing/test_mark_expression.py:266:64

    identifier `aaאבגדcc` mixes scripts: Latin + Hebrew (in string/comment) (raw pass, confidence 0.40)

            pytest.mark.str_mark(  # pylint: disable-next=non-ascii-name
                m="M", space="with space", empty="", aaאבגדcc="aaאבגדcc", אבגד="אבגד"
            ).mark,
        ]
  75. info unicode-mixed-script testing/test_mark_expression.py:323:20

    identifier `aaאבגדcc` mixes scripts: Latin + Hebrew (in string/comment) (raw pass, confidence 0.40)

            ('str_mark(m="M")', True),
            ("str_mark(aaאבגדcc='aaאבגדcc')", True),
            ("str_mark(אבגד='אבגד')", True),
            ("str_mark(space='with space')", True),
  76. info unicode-mixed-script testing/test_mark_expression.py:323:34

    identifier `aaאבגדcc` mixes scripts: Latin + Hebrew (in string/comment) (raw pass, confidence 0.40)

            ('str_mark(m="M")', True),
            ("str_mark(aaאבגדcc='aaאבגדcc')", True),
            ("str_mark(אבגד='אבגד')", True),
            ("str_mark(space='with space')", True),
  77. info unicode-mixed-script testing/test_mark_expression.py:329:20

    identifier `aaאבגדcc` mixes scripts: Latin + Hebrew (in string/comment) (raw pass, confidence 0.40)

            ("str_mark(m='wrong')", False),
            ("str_mark(aaאבגדcc='wrong')", False),
            ("str_mark(אבגד='wrong')", False),
            ("str_mark(m='')", False),

Reproduce This Scan

Run disclude locally to verify. Add --format sarif for SARIF output. Add --llm (with an API key in the environment) to include the LLM review.

cargo install disclude --version 4.0.0
git clone https://github.com/pytest-dev/pytest pytest && cd pytest
git checkout 9.1.1
disclude scan --severity info --diff 9.1.0 .