The current usage can be replaced by built-in datatime module.
pytz is not currently in test requirements and it is no longer required
by oslo.utils in Python 3.11.
Change-Id: Ib490f5aebc5c84daf28edc3698694d70a74a4715
inspect.getargspec was deprecated since Python 3.0 and
inspect.getfullargspec is its replacement with correct handling of
function annotations and keyword-only parameters[1].
[1] https://docs.python.org/3/library/inspect.html#inspect.getargspec
Change-Id: I29478df88665ee5311e3ba308ab645c47e5b0fc8
This fixes the leftover of c1933306dd
and makes the get_method_spec method patched instead of inspect.argspec
because now the method wraps call to inspect.argspec.
Change-Id: Id3c18d151a6f239f7ceff4e0b24f4006963827ea
md5 is not an approved algorithm in FIPS mode, and trying to
instantiate a hashlib.md5() will fail when the system is running in
FIPS mode.
md5 is allowed when in a non-security context. There is a plan to
add a keyword parameter (usedforsecurity) to hashlib.md5() to annotate
whether or not the instance is being used in a security context.
In the case where it is not, the instantiation of md5 will be allowed.
See https://bugs.python.org/issue9216 for more details.
Some downstream python versions already support this parameter. To
support these versions, a new encapsulation of md5() has been added to
oslo_utils. See https://review.opendev.org/#/c/750031/
This patch is to replace the instances of hashlib.md5() with this new
encapsulation, adding an annotation indicating whether the usage is
a security context or not.
In this case, md5 is computed as one of the object hashes for the
purposes of object versioning.
Change-Id: Idf36897d690a20d23123950618643d0b9e085f6c
Depends-On: https://review.opendev.org/#/c/760160
This patch bumps bandit allowed version to >=1.6.0,<1.7.0 in order to
avoid the errors detailed here https://github.com/PyCQA/bandit/pull/393
Change-Id: I005962a63341bb8585141dfe5dcff3ea79560b87
Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
The repo is Python 3 now, so update hacking to version 3.1.0 which
supports Python 3.
Fix problems found.
Remove hacking and friends from lower-constraints, they are not needed
for installation.
Change-Id: I810e4c30513746bc46a3e65b398539929a7ac6b0
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.
Change-Id: I26f2df6d4657133a5c7e6ed85298aa843c1bdd73
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
Python3 has deprecated inspect.getargspec(), which our fixture uses
to provide fingerprinting for remotable methods. Since the hashesh for
those methods are stored in the wild and are used to detect when objects
change in incompatible ways, it is desirable to avoid having to change
all stored hashes when a library adopts the newer method.
This change attempts to use the older spec format when possible to
avoid needless hash changes, and opts for the newer one when necessary
to represent some newer feature. Changing hashes when adding such a feature
to a remotable method is implied anyway, so getting the newer one based
on the newer method is expected.
Change-Id: I84b4ce9c95d6ab86c58f8d797dba28201c1f1668
This allows us to use a new version of flake8 that supports Python
3-only syntax. Existing issues are resolved.
Change-Id: I5de7e5cde6a5260f4e7e57586952256b59d3756d
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
We no longer need much of the functionality this was providing.
Change-Id: I0f625b714950a712249757906974715358f9e6c6
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
The 'obj_tree_get_versions' function is used by e.g. the
'test_compatibility_routines' fixture to sanity check object versioning
and we don't do things like remove objects that are referenced
elsewhere. Unfortunately if we do this exact thing, an unhelpful
'IndexError' is raised. Handle things better and raise a specific
exception with hints towards what may be the root cause.
Change-Id: I7c05c648a9efb018ef9718fa31a9cc075482db59
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Closes-bug: #1860652
From the deprecation warning message:
"Using or importing the ABCs from 'collections' instead of from
'collections.abc' is deprecated since Python 3.3, and in 3.9 it
will stop working"
Change-Id: I53b11ebe81977d13a460cdf167ba37c5d3e1bdcd
Closes-Bug: #1856882
This addresses a couple sources of deprecation warnings in the code.
The collections package has moved abstract base classes from
collections.* to collections.abc.*. Use of the old path causes
DeprecationWarning messages now, but will eventually be removed. Six
does not support this yet, so for now just try the newer preferred path
and fall back to the old path if the import fails.
This also addresses unit test deprecation methods with self.skip()
changing to self.skipTest().
Change-Id: I0463ab2109adeee6468261f9e96225766a55998e
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
The type check on the list field requires a list, though many
objects can be trivially iterated as lists, like sqlalchemy
lazy query objects. Relax the check slightly to fit a broader
range of "lists".
Change-Id: I514a0e6d445e9a14e3c0279b4e9bebfa0940337d
The ObjectVersionChecker fixture is logging object
comparison at INFO which in some tests can blow up
the subunit output stream capture parser (see nova
bug 1813147). This change drops the logging level
to DEBUG which can be enabled using the OS_DEBUG
environment variable found in oslotest.
Change-Id: If20663ecad19f18f22172ae489206b42489fd9f6
Closes-Bug: #1815223
This adds a simple ListOfUUIDField which is copied from
kuryr-kubernetes and is also needed in nova.
Change-Id: Ife866af6e07c887774689fd98ac6fde6fa55d6de
The string representation of an empty set is different between py27 and
py35. The ObjectVersionChecker uses the string represenation of the
default value of the fields as input for the hash of the object. This
makes hash of an object with a set field defaulted to an empty set
unstable.
This patch enhances the repr generation of the Field object to avoid the
unstable hash situation.
Change-Id: Ie9519c1893175614d60af97b635e6ff57f2b0d7d
Closes-Bug: #1771804
The latest version of Incompatible check exception Shows
in the exception output but the supported version is not listed.
Change-Id: Ia9f433342b1b233e119613470a829608085de10c
Related-Bug: 1773393
In newer versions of oslotest, moxstubout will be deprecated.
So we can get out in front of the curve now and remove it.
Change-Id: I7b39aa52d3051e81a908277a6fc956d680d653e7
Signed-off-by: Charles Short <zulcss@gmail.com>
Set the default python to python3 except for the py27 environment. We
have to set that explicitly to override the new default.
Because flake8 runs under python 3, where the type "long" has been
merged into int(), we have to ignore the error from the undefined name
in one of the tests.
Change-Id: I86ae7f83d17724d74bae7102dd1775eceb82599d
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Change Ic6b6308fb1960ec40407e6efde30137b64543e72 attempts to
fix difference between Python 2 and Python 3 values by switching
from using str() to formatting into a unicode string (u"%s").
This is equivalent to changing str() to unicode(), but that is
not correct for expected default string types for Python 2.
This requires either using six.text_type(), or just formatting
into a string, without forcing unicode ("%s"), to be correct on
either runtime.
Change-Id: I178f14cdc670d7a696778891e587ef75de208fc2
Closes-bug: #1763179
If we use non uuid unicode user id in py27 env,
unicode error pop up when function is called.
Closes-bug: #1760918
Change-Id: Ic6b6308fb1960ec40407e6efde30137b64543e72
Today UUIDField emits a warning if the provided value is not a valid
UUID. However this warning cannot be escalated to an exception through
the standard warnings module because the validation code also adds a
warning filter to the warning filter list that overrides the existing
filters.
This patch ensures that the 'once' warning filter only added to the
end of the filter list. This way if the client has already specified
another filter for this warning (e.g. and error filter) then that
filter will not be overriden.
Change-Id: I17cb96d16fcd91195478b738fbdda01b47cfd69d
Closes-Bug: #1746966
The iso8601 lib introduced a change such that if running on python
3.2 or later it internally uses the python timezone information
instead of its own implementation. This does not change direct
date handling, but when converting this value there is a slight
difference where now python 2.x will show UTC times as "UTC", but
on python 3 they will end up with "UTC+00:00".
The to_primitive call for DateTime fields was doing an exact match
on "UTC" to determine whether to include "Z" in the resulting string.
This updates that handling to recognize either of the new values.
Change-Id: I71b58e8fd8fee8a57ee275ff3e0b77f165eca836
Closes-bug: #1744160
iso8601.UTC is correct datetime UTC field object.
iso8601 >= 0.1.12 includes only iso8601.UTC for python3
while both UTC and Utc() for python2. Less then 0.1.12
included both UTC and Utc() for both python2/3.
Some of the occurrences were missed in the previous commit:
934fb45a2d
This patch fixes those missing occurrences.
Change-Id: Ib6ba40a31bbc0e4a279568bd70fb210ad142d77b
iso8601.UTC is correct datetime UTC field object.
iso8601.UTC is correct datetime UTC field object.
iso8601 >= 0.1.12 includes only iso8601.UTC for python3
while both UTC and Utc() for python2. Less then 0.1.12
included both UTC and Utc() for both python2/3.
Change-Id: Ie7957959e836d2f78409d4197c6a2d7ad9e8457b
Closes-Bug: #1713354