force version on deprecation (#74338)

This commit is contained in:
Brian Coca 2021-04-26 13:02:00 -04:00 committed by GitHub
parent d8fa2b50d5
commit 85e7108d52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 7 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- constants, internal _deprecated function always requires version.

View file

@ -120,6 +120,7 @@ class ConnectionProcess(object):
def run(self): def run(self):
try: try:
log_messages = self.connection.get_option('persistent_log_messages')
while not self.connection._conn_closed: while not self.connection._conn_closed:
signal.signal(signal.SIGALRM, self.connect_timeout) signal.signal(signal.SIGALRM, self.connect_timeout)
signal.signal(signal.SIGTERM, self.handler) signal.signal(signal.SIGTERM, self.handler)
@ -133,7 +134,6 @@ class ConnectionProcess(object):
data = recv_data(s) data = recv_data(s)
if not data: if not data:
break break
log_messages = self.connection.get_option('persistent_log_messages')
if log_messages: if log_messages:
display.display("jsonrpc request: %s" % data, log_only=True) display.display("jsonrpc request: %s" % data, log_only=True)

View file

@ -19,9 +19,6 @@ from ansible.module_utils.six import string_types
from ansible.release import __version__ from ansible.release import __version__
from ansible.utils.fqcn import add_internal_fqcns from ansible.utils.fqcn import add_internal_fqcns
# 4 versions above current
default_deprecated = to_text(float('.'.join(__version__.split('.')[0:2])) + 0.04)
def _warning(msg): def _warning(msg):
''' display is not guaranteed here, nor it being the full class, but try anyways, fallback to sys.stderr.write ''' ''' display is not guaranteed here, nor it being the full class, but try anyways, fallback to sys.stderr.write '''
@ -33,7 +30,7 @@ def _warning(msg):
sys.stderr.write(' [WARNING] %s\n' % (msg)) sys.stderr.write(' [WARNING] %s\n' % (msg))
def _deprecated(msg, version=default_deprecated): def _deprecated(msg, version):
''' display is not guaranteed here, nor it being the full class, but try anyways, fallback to sys.stderr.write ''' ''' display is not guaranteed here, nor it being the full class, but try anyways, fallback to sys.stderr.write '''
try: try:
from ansible.utils.display import Display from ansible.utils.display import Display
@ -55,11 +52,11 @@ class _DeprecatedSequenceConstant(Sequence):
self._version = version self._version = version
def __len__(self): def __len__(self):
_deprecated(self._msg, version=self._version) _deprecated(self._msg, self._version)
return len(self._value) return len(self._value)
def __getitem__(self, y): def __getitem__(self, y):
_deprecated(self._msg, version=self._version) _deprecated(self._msg, self._version)
return self._value[y] return self._value[y]