[BUG] DeprecationWarning in salt/modules/file.py: 'count' passed as positional argument to re.subn on Python 3.13+ / 3.14
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
When running salt-call or applying states on nodes running Python 3.13 or Python 3.14, a DeprecationWarning is emitted to stderr from salt/modules/file.py:
/opt/saltstack/salt/lib/python3.14/site-packages/salt/modules/file.py:2833: DeprecationWarning: 'count' is passed as positional argument
result, nrepl = re.subn(
Python 3.13+ / 3.14 deprecates passing count as the 4th positional argument to re.subn() (and re.sub()), requiring keyword arguments instead.
Steps to Reproduce
- Run
salt-call --local state.applyon an environment running Python 3.13+ / 3.14. - Observe
stderroutput during file state replacements.
Expected Behavior
file.replace and internal string replacements in salt/modules/file.py should execute cleanly without emitting Python DeprecationWarning messages.
Actual Behavior
The following deprecation warning is printed to stderr:
/opt/saltstack/salt/lib/python3.14/site-packages/salt/modules/file.py:2833: DeprecationWarning: 'count' is passed as positional argument
result, nrepl = re.subn(
Proposed Fix
In salt/modules/file.py (around line 2833), update the re.subn call to pass count as a keyword argument (count=count):
- result, nrepl = re.subn(
- cpattern,
- repl.replace(b"\\", b"\\\\") if backslash_literal else repl,
- r_data,
- count,
- )
+ result, nrepl = re.subn(
+ cpattern,
+ repl.replace(b"\\", b"\\\\") if backslash_literal else repl,
+ r_data,
+ count=count,
+ )
Environment
- Salt Version: 3008.2+
- Python Version: 3.13 / 3.14
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in salt/modules/file.py around line 2833 and reproduce file replacement on Python 3.13 or 3.14 to confirm the warning. Update the re.subn call so count is passed by keyword, then verify that file.replace and related internal replacements run without the DeprecationWarning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 86/100