launchd: remove conditional code for Python < 3.4 (#10909)

* launchd: remove conditional code for Python < 3.4

* add changelog frag
This commit is contained in:
Alexei Znamensky 2025-10-12 19:56:05 +13:00 committed by GitHub
commit 056633efaa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 11 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- launchd - remove conditional code supporting Python versions prior to 3.4 (https://github.com/ansible-collections/community.general/pull/10909).

View file

@ -160,9 +160,6 @@ class Plist:
state, pid, dummy, dummy = LaunchCtlList(module, self.__service).run()
# Check if readPlist is available or not
self.old_plistlib = hasattr(plistlib, 'readPlist')
self.__file = self.__find_service_plist(self.__filename)
if self.__file is None:
msg = 'Unable to find the plist file %s for service %s' % (
@ -201,10 +198,6 @@ class Plist:
def __read_plist_file(self, module):
service_plist = {}
if self.old_plistlib:
return plistlib.readPlist(self.__file)
# readPlist is deprecated in Python 3 and onwards
try:
with open(self.__file, 'rb') as plist_fp:
service_plist = plistlib.load(plist_fp)
@ -217,10 +210,6 @@ class Plist:
if not service_plist:
service_plist = {}
if self.old_plistlib:
plistlib.writePlist(service_plist, self.__file)
return
# writePlist is deprecated in Python 3 and onwards
try:
with open(self.__file, 'wb') as plist_fp:
plistlib.dump(service_plist, plist_fp)