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
560 scanned, 41 skipped (binary, oversized, or unrecognised)
Signals
0 critical · 0 warn · 77 info
Scan time
47.1 s
LLM review
Reviewed by claude-haiku-5-5 (Anthropic): 63 of 63 warn and critical signals; 63 demoted to info.
Disclude version
4.1.0
Scanned (UTC)
2026-10-21 21:11

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 Documentation example calling os.system with a fixed echo command to demonstrate output capture.
    Reasoning

    Literal os.system call with a fixed echo command inside an rst doc example for capfd. No untrusted input and no obfuscation.

  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 Documentation example of os.system with a fixed echo command for binary capture.
    Reasoning

    Same literal echo example in a doc page, illustrating capfdbinary. Nothing malicious.

  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 Demo code compiling a module's source inside a pytest assertion example.
    Reasoning

    Pytest's assertion failure demo builds a module from source text to show import-time rewriting behaviour. The compile is a local demo artifact, not an attack.

  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 Demo exec of a dynamically built module in a pytest assertion example.
    Reasoning

    exec of compiled demo source in a pytest example file. The surrounding code is a legitimate import helper for demonstrating failures.

  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 Test example that uses eval on the method name to set an id.
    Reasoning

    Test example evaluates a slice of the test method name to derive an id. Input comes from the test's own name, so the risk is nil.

  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 Doc snippet using eval on a test parameter in a parametrize example.
    Reasoning

    Documentation example of eval in a parametrize test, illustrating expression evaluation. Standard tutorial code.

  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 Doc snippet using eval inside a parametrized test example.
    Reasoning

    Doc snippet of an eval-based parametrized test, repeated tutorial material from the historical notes.

  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
    likely benign LLM, confidence 0.90 Prose mention of an eval expression in historical notes.
    Reasoning

    Prose inline literal of eval on a constant string describing old pytest behaviour. It is not executed 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 Install instruction evaluating register-python-argcomplete output for bash completion.
    Reasoning

    This is the documented way to enable pytest's bash completion, eval of a command substitution from the vendor's own helper. It is dynamic but is the standard, expected setup instruction.

  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 Doc snippet using eval on a parameter in a parametrize tutorial.
    Reasoning

    Documentation example of eval in a parametrized test. Tutorial code with no malicious indicators.

  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
    likely benign LLM, confidence 0.90 Doc failure-output excerpt containing an eval line.
    Reasoning

    Prose or error-output snippet showing the eval line from a test failure. Not executed 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 Doc snippet using eval in a parametrize example.
    Reasoning

    Same eval-based parametrize example in tutorial docs. Benign.

  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.75 Non-breaking space characters in an indented doc code block.
    Reasoning

    A non-breaking space in rst indentation is a common editor artifact in docs. It causes at most a rendering quirk and shows no obfuscation.

  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)
    likely benign LLM, confidence 0.90 Cyrillic prose in a plugin description flagged as a homoglyph.
    Reasoning

    The flagged character is part of ordinary Russian prose in a plugin description, not an identifier. The homoglyph detector misfires on natural-language text.

  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`
    likely benign LLM, confidence 0.90 Russian plugin description text falsely flagged as a homoglyph.
    Reasoning

    Same Russian description text for the pytest_notify plugin. Legitimate localized prose, not an 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:
    likely benign LLM, confidence 0.90 Pytest traceback helper that evaluates code in a frame's namespace.
    Reasoning

    pytest's frame-evaluation helper evaluates expressions in captured frame globals and locals for repr and debugging. This is core, expected functionality of the library.

  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):
    likely benign LLM, confidence 0.93 Dynamic __import__ of a hash module name inside pytest's vendored py.path checksum code.
    Reasoning

    The hashtype value is chosen from a fixed set of hash names (e.g. 'sha', 'md5') before __import__ runs, so this is a standard hashlib fallback with no attacker-controlled input.

  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":
    likely benign LLM, confidence 0.92 Dynamic __import__ of a module name in pytest's vendored py.path pyimport implementation.
    Reasoning

    This is the import machinery of py.path.pyimport, which imports a module by its computed package name and then reads it from sys.modules. That is the documented purpose of the function, not a hidden payload.

  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.90 exec of a module's own source file during pytest's vendored py.path pyimport.
    Reasoning

    pyimport executes the source of the file the caller explicitly asked to import, into the module's own namespace, and removes the module from sys.modules on failure. The pickle import is incidental to the module-loading logic.

  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.90 exec of a file's contents into a module namespace in pytest's vendored py.path.
    Reasoning

    This is the same legitimate module-source exec in pyimport, run into mod.__dict__ on a file the user specified. The finding is a duplicate of the decoder-import-with-exec signal on the same line.

  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:
    likely benign LLM, confidence 0.90 exec of cached rewritten bytecode in pytest's assertion rewrite import hook.
    Reasoning

    This executes a cached rewritten bytecode object into the module's dict, which is how pytest's assertion rewriting hook loads its modules. Marshal and exec in this position are expected for a bytecode import hook.

  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:
    likely benign LLM, confidence 0.90 exec of a code object from pytest's assertion rewrite cache.
    Reasoning

    This is the same exec of cached rewritten bytecode in the assertion rewrite hook, a duplicate signal on one line of standard import machinery.

  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
    likely benign LLM, confidence 0.90 compile of a rewritten AST for an assertion-rewritten test module.
    Reasoning

    This compiles an AST produced by pytest's own assertion rewriter from the test module's source. The compile call is the normal final step of that rewriting.

  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 pytest's cached .pyc bytecode in _read_pyc.
    Reasoning

    marshal.load reads pytest's own .pyc cache files, which are written locally by the same tool. Marshal deserialization is a general concern, but this is the standard bytecode cache read path.

  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.92 Dynamic __import__ of a configured plugin module in pytest's config plugin loader.
    Reasoning

    This imports a plugin module named by the user's configured plugin spec, then reads it from sys.modules. Plugin loading by name is the design of pytest's plugin manager.

  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 sys._getframe used to locate the caller for pytest warning records.
    Reasoning

    sys._getframe with a stacklevel offset is how pytest attributes a warning to the caller's file and line. It is ordinary diagnostic use of frame introspection.

  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 sys._getframe().f_back used to start pdb at the caller's frame in pytest's debugging module.
    Reasoning

    This takes the calling frame so that pdb.set_trace starts at the user's breakpoint location, which is the expected behaviour of pytest's pdb integration.

  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 inspect.stack used to get the defining file of a fixture for pytest's fixture registry.
    Reasoning

    inspect.stack is used to find the file and location where a fixture is defined, for error reporting and path resolution. It is a common and benign introspection pattern.

  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.93 compile of a parsed pytest -k/-m match expression.
    Reasoning

    This compiles the AST produced by pytest's own -k/-m expression parser, with a fixed filename. It is the intended compile step of a small expression language.

  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.90 Restricted eval of a compiled pytest mark expression with builtins disabled.
    Reasoning

    eval runs with an empty __builtins__ dict and only a matcher adapter in scope. This sandboxes the expression to name lookups for keyword matching, so it is restricted evaluation rather than arbitrary code execution.

  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.
    dismissed LLM, confidence 0.92 pytest's outcomes module compiles a module-name string to catch syntax errors.
    Reasoning

    The compile call validates the syntax of a module-name string in pytest's skip/importorskip helper, with a comment saying so. It is a standard syntax-check pattern in a test framework, not obfuscation or a dropper.

  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)
    dismissed LLM, confidence 0.93 Pytester helper takes the caller's frame locals to evaluate user-supplied match expressions.
    Reasoning

    pytester's matchreport helper reads the caller's locals via sys._getframe(1) so that assertion expressions can be evaluated against them. The 'critical' severity comes from the anti-analysis heuristic firing on any file that mentions eval, which is a false positive here.

  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:
    dismissed LLM, confidence 0.90 Pytester evaluates test-supplied check expressions against recorded hook call attributes.
    Reasoning

    eval runs test-author-written check expressions against a call's attributes inside a testing utility. This is intended assertion-matching behaviour for a test framework, not attacker-controlled execution.

  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:
    dismissed LLM, confidence 0.92 pytest's skipif evaluator compiles mark condition strings as expressions.
    Reasoning

    pytest compiles skipif/xfail condition strings from marks, which is the documented feature of evaluating condition expressions. The code is in the framework's marker evaluation path and handles SyntaxError explicitly.

  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 = [
    dismissed LLM, confidence 0.92 pytest evaluates compiled skipif/xfail condition expressions from markers.
    Reasoning

    This eval runs the compiled skip/xfail condition from the test author's marks, which is the documented behaviour of pytest's condition-based markers. It is the expected use of eval in this context.

  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())
    dismissed LLM, confidence 0.95 Test helper returns its own frame to exercise pytest's Frame wrapper.
    Reasoning

    This is a unit test that uses sys._getframe(0) to construct a Frame object for testing pytest's code-introspection wrapper. The anti-analysis label is a false positive from the file also containing exec/eval.

  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())
    dismissed LLM, confidence 0.95 Test helper returns its own frame to exercise pytest's Frame wrapper.
    Reasoning

    Same pattern as the other frame tests: a test function returns its own frame to check pytest's Frame class. 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"))
    dismissed LLM, confidence 0.95 Test function returns its own frame to test argument extraction from frames.
    Reasoning

    A parametrised-signature test helper returns its own frame for Frame introspection tests. This is ordinary test scaffolding.

  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"))
    dismissed LLM, confidence 0.95 Test function returns its own frame to test *args handling in Frame.
    Reasoning

    A test helper with *args returns its own frame to test argument extraction. Benign test code.

  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"))
    dismissed LLM, confidence 0.95 Test function returns its own frame to test **kwargs handling in Frame.
    Reasoning

    A test helper with **kwargs returns its own frame to test keyword-argument extraction. Benign test code.

  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"))
    dismissed LLM, confidence 0.95 Test function returns its own frame to test combined varargs handling in Frame.
    Reasoning

    A test helper with *args and **kwargs returns its own frame to test argument extraction. Benign test code.

  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()
    dismissed LLM, confidence 0.92 Test executes a compiled code object to produce a traceback for ExceptionInfo.
    Reasoning

    The exec of a compiled code object sits inside a test that checks how pytest's ExceptionInfo handles tracebacks from exec'd code. It is an intentional test fixture, not a dropper.

  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()
    dismissed LLM, confidence 0.92 Test executes a compiled code object to produce a traceback for ExceptionInfo.
    Reasoning

    Same as the other exec in this file: a test builds a traceback from compiled code to verify ExceptionInfo behaviour. Benign.

  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":
    dismissed LLM, confidence 0.95 Test inspects the upper frame's function name to verify traceback behaviour.
    Reasoning

    The test reads its caller's frame to check the co_name of the function that raised an error. This is a normal test assertion about traceback paths.

  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.95 Test helper using sys._getframe to capture the calling frame's statement.
    Reasoning

    This is pytest's own test suite for source-code inspection helpers. sys._getframe is used to capture the caller's statement, which is a normal pattern for a Source/getstatement helper. The anti-analysis label is a heuristic match on the file's test fixtures.

  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 fixture source string to exercise source lookup.
    Reasoning

    Compiling a test string constructed with known contents inside pytest's source-inspection tests is expected; the code is test fixture data, not attacker-controlled.

  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 evaluates a locally compiled fixture code object.
    Reasoning

    eval of a code object compiled from a local test fixture, in pytest's test suite. Benign test scaffolding.

  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.95 Test helper capturing caller frame via sys._getframe.
    Reasoning

    Same pytest source-inspection helper pattern as the earlier frame introspection finding; a legitimate test utility.

  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 wrapper compiling a constant-built source string to check line numbers.
    Reasoning

    Test helper that pads source lines with a fixed number of newlines to test line-number handling; the string is built from constants, not external input.

  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.95 Conftest restores the previous sys trace function after a test.
    Reasoning

    Restoring the original trace function in a pytest conftest fixture is a standard way to avoid leaking debugger/coverage tracing between tests.

  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.90 Build helper invoking pyinstaller through a shell with locally assembled arguments.
    Reasoning

    Build script for freezing test executables with pyinstaller; the command is assembled from fixed local arguments and shell=True is used only to run the local build tool. Not attacker-driven, though shell=True is worth noting.

  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.95 Runs the frozen test executable via os.system during tox tests.
    Reasoning

    Test-freezing helper running the built executable with a fixed f-string command; a normal test runner invocation.

  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.90 Test evaluates a repr string to verify round-trip formatting.
    Reasoning

    Test for ExceptionGroup repr/str checks that evals a repr-like string in a parametrized test; it's test scaffolding over fixed inputs.

  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.90 Test helper compiling and executing rewritten assertion source.
    Reasoning

    The assertion-rewrite test helper compiles and execs rewritten test source, which is how pytest tests its own rewriting. The marshal import is a normal part of pytest's pyc caching machinery, not a payload loader.

  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.90 Compiles the rewritten test module source.
    Reasoning

    Compile of rewritten test module source inside pytest's assertion-rewrite tests; expected behaviour.

  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.90 Execs the compiled test code in a test namespace.
    Reasoning

    Executes the compiled rewritten test source in a namespace to run the test function; standard for testing the rewriter.

  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.93 Test helper walks to the caller frame to check reported locations.
    Reasoning

    inspect.currentframe used to report the caller's line in an assertion-rewrite test helper; ordinary introspection in test code.

  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.90 Test compiles rewritten source to verify assertion locations.
    Reasoning

    Rewrites and compiles test source strings in pytest's assertion-rewrite tests; expected for this test module.

  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.90 Test execs the rewritten source in globals.
    Reasoning

    Executes compiled rewritten test source in the test's globals; standard test scaffolding.

  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.90 Test compiles source to compare original assertion locations.
    Reasoning

    Compiles a test source string to compare original locations in the rewriter test; expected.

  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.90 Test helper that execs a compiled module during assertion-rewrite testing.
    Reasoning

    The file is pytest's own test suite for assertion rewriting. The exec call runs a module compiled from a test-generated source string with explicit globals, which is the expected way to test an import hook. The snippet shows no encoded payload, network access, or obfuscation.

  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.90 Test code compiles source bytes and marshals them to exercise pyc generation.
    Reasoning

    This is a test that marshals a compiled code object to check the pyc writer. Compiling a test-supplied source is a normal pattern in this test suite, and the snippet has no suspicious indicators.

  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,
        ]
    dismissed LLM, confidence 0.93 Test fixture using a deliberately mixed-script identifier to exercise unicode mark names.
    Reasoning

    The identifier mixes Latin and Hebrew deliberately, and the line carries a pylint disable for non-ascii-name. This is a test fixture checking that the mark-expression parser handles unicode identifiers. It is not a homoglyph attack on real code, and the raw-pass finding has a high false-positive rate.

  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.1.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 .