Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix import error on Python 3.13 #684

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions plugins/module_utils/mongodb_shell.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type

# DeprecationWarning: 'pipes' is deprecated and slated for removal in Python 3.13
# Ignore for now
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)

import shlex
import pipes
import re
import json
import os

try:
from shlex import quote
except ImportError:
from pipes import quote

Check warning on line 11 in plugins/module_utils/mongodb_shell.py

View check run for this annotation

Codecov / codecov/patch

plugins/module_utils/mongodb_shell.py#L10-L11

Added lines #L10 - L11 were not covered by tests


def escape_param(param):
'''
Escapes the given parameter
@param - The parameter to escape
'''
escaped = None
if hasattr(shlex, 'quote'):
escaped = shlex.quote(param)
elif hasattr(pipes, 'quote'):
escaped = pipes.quote(param)
else:
escaped = "'" + param.replace("'", "'\\''") + "'"
return escaped
return quote(param)


def add_arg_to_cmd(cmd_list, param_name, param_value, is_bool=False, omit=None):
Expand Down
Loading