# ruff G010: fix changes program behavior

Internal evidence sheet generated by fixhunt. Not an issue text. A human re-verifies, checks the duplicates
below, and writes the upstream report in their own words following the project's AI policy.

- Tool: ruff ruff 0.17.1
- Rule: G010 (tool labels the fix: unknown, this fix reported as safe)
- Oracle: fix-changes-behavior
- Judge (Nemotron 3 Ultra, advisory): intended-change, severity low. The rule replaces the deprecated `logger.warn` method with `logger.warning` as documented. The stderr difference occurs because the DeprecationWarning emitted by the old method no longer appears after the fix, which is exactly the semantic change the rule intends to make.
- Program: minimized from 16 to 10 lines

## Reproducer

```python
import logging
logger = logging.getLogger('test')
try:
    raise ValueError('bad')
except ValueError as e:
    try:
        logger.warn('in except')  # Rewritten
    except RuntimeError as final_err:
        pass
print('Finished')
```

## Commands

```sh
python3 prog.py
ruff check --preview --isolated --select G010 --fix prog.py
python3 prog.py
```

## Observed

```
stderr before: /w/prog.py:7: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
stderr after: in except
```

## Diff applied by the fix

```diff
--- orig.py	2026-10-22 13:28:35.613129913 -0400
+++ fixed.py	2026-10-22 13:28:38.823183444 -0400
@@ -4,7 +4,7 @@
     raise ValueError('bad')
 except ValueError as e:
     try:
-        logger.warn('in except')  # Rewritten
+        logger.warning('in except')  # Rewritten
     except RuntimeError as final_err:
         pass
 print('Finished')
```

## Why the rewrite is not equivalent (model draft, verify before use)

The original `logger.warn` call emits a deprecation warning to stderr because it’s deprecated; this output occurs regardless of any exception handling. After rewriting to `logger.warning`, that warning is suppressed, so only the explicit log message appears on stderr. Since the deprecation warning was part of the program’s observable behavior (stderr output), removing it changes what the program produces, making the transformation not semantics‑preserving despite being labeled safe.

## Upstream search

Queries: "G010 fix", "ruff G010 warn method call", "logging warning deprecation usage", "deprecated logger.warn replacement"

- duplicate: https://github.com/astral-sh/ruff/issues/12295
  same rule G010 and same construct logger.warn being rewritten to logger.warning
- related: https://github.com/astral-sh/ruff/issues/7248
  same rule family flake8-logging but different specific rule implementation
- related: https://github.com/astral-sh/ruff/issues/2186
  same rule G010 mentioned as alias but different defect class about rule aliasing
- related: https://github.com/astral-sh/ruff/issues/13673
  same G rules category but different logger library loguru vs standard logging
- duplicate: https://github.com/astral-sh/ruff/issues/17219
  explicitly closed as duplicate of issue 12295 about logger.warn access
- related: https://github.com/astral-sh/ruff/issues/970
  same logging rule family but different specific rules like logging-format-truncated

<details><summary>All hits</summary>

- [github, open] No error on `logging.Logger.warn` access [G010] — https://github.com/astral-sh/ruff/issues/12295
- [github, open] Implement `flake8-logging` — https://github.com/astral-sh/ruff/issues/7248
- [github, open] Add support for rule aliasing — https://github.com/astral-sh/ruff/issues/2186
- [github, closed] unused-function-argument not silenced by prefixed underscore if variable name is "次" — https://github.com/astral-sh/ruff/issues/28721
- [github, closed] G rules seems not working with loguru. — https://github.com/astral-sh/ruff/issues/13673
- [github, closed] Ord violation panic when fixing file with nightly compiler — https://github.com/astral-sh/ruff/issues/12469
- [github, closed] Pack of fuzzer Autofix/Infinite loop errors [2] — https://github.com/astral-sh/ruff/issues/8402
- [github, closed] Rule RUF027 cause panic — https://github.com/astral-sh/ruff/issues/9895
- [github, closed] Fixed code unformatted — https://github.com/astral-sh/ruff/issues/8619
- [github, closed] Add option to disable preview warnings — https://github.com/astral-sh/ruff/issues/8620
- [tavily] Importing a logger circumvents "logging-f-string (G004)" · Issue #17219 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/17219
- [tavily] Allow to declare modules/calls as deprecated · Issue #10131 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/10131
- [tavily] Ruff server not closing with neovim instances - vol 2 · Issue #11545 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/11545
- [tavily] Implement Pylint · Issue #970 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/970

</details>
