packages/python/python-oslo-utils/oslo-utils-py38.patch

59 lines
2.1 KiB
Diff

Description: non-strict callback comparison is not possible in py3.8
Author: Dimitri John Ledkov <xnox@ubuntu.com>
Bug-Python: https://bugs.python.org/issue1617161
Bug-LP: https://bugs.launchpad.net/ubuntu/+source/python-oslo.utils/+bug/1841072
Index: python-oslo.utils-3.41.1/oslo_utils/reflection.py
===================================================================
--- python-oslo.utils-3.41.1.orig/oslo_utils/reflection.py
+++ python-oslo.utils-3.41.1/oslo_utils/reflection.py
@@ -22,6 +22,8 @@ Reflection module.
import inspect
import types
+import platform
+import warnings
import six
@@ -169,7 +171,10 @@ def is_same_callback(callback1, callback
# This happens when plain methods are given (or static/non-bound
# methods).
return True
+ if not strict and platform.python_version() > '3.8':
+ warnings.warn("non strict comparison impossible in py3.8+", DeprecationWarning)
if callback1 == callback2:
+ ## raise deprecated warning
if not strict:
return True
# Two bound methods are equal if functions themselves are equal and
Index: python-oslo.utils-3.41.1/oslo_utils/tests/test_reflection.py
===================================================================
--- python-oslo.utils-3.41.1.orig/oslo_utils/tests/test_reflection.py
+++ python-oslo.utils-3.41.1/oslo_utils/tests/test_reflection.py
@@ -17,6 +17,7 @@
from oslotest import base as test_base
import six
import testtools
+import warnings
from oslo_utils import reflection
@@ -153,7 +154,15 @@ class CallbackEqualityTest(test_base.Bas
c = A()
self.assertFalse(reflection.is_same_callback(b.b, c.b))
- self.assertTrue(reflection.is_same_callback(b.b, c.b, strict=False))
+
+ # Non-strict reflection comparison is not possible in py3.8+
+ with warnings.catch_warnings(record=True) as capture:
+ warnings.simplefilter("always")
+ res = reflection.is_same_callback(b.b, c.b, strict=False)
+ if len(capture):
+ self.assertFalse(res)
+ else:
+ self.assertTrue(res)
class BoundMethodTest(test_base.BaseTestCase):