Skip to content

Commit

Permalink
Update Python version support.
Browse files Browse the repository at this point in the history
  • Loading branch information
icemac committed Jan 16, 2025
1 parent 4bae1fb commit a47be47
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 25 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#
#
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/buildout-recipe

Expand All @@ -11,7 +11,7 @@ branch = true
source = ["zdaemon"]
parallel = true
data_file = "$COVERAGE_HOME.coverage"
omit = "*/__main__.py"
omit = ["*/__main__.py"]

[tool.coverage.report]
fail_under = 79
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@ def read(*rnames):
'License :: OSI Approved :: Zope Public License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Operating System :: POSIX',
Expand All @@ -74,7 +73,7 @@ def read(*rnames):
zip_safe=False,
entry_points=entry_points,
include_package_data=True,
python_requires='>=3.7',
python_requires='>=3.9',
install_requires=[
"ZConfig",
"setuptools"
Expand Down
4 changes: 2 additions & 2 deletions src/zdaemon/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
pkg_resources.Requirement.parse('zdaemon')).location
zconfig_loc = pkg_resources.working_set.find(
pkg_resources.Requirement.parse('ZConfig')).location
except (ImportError, AttributeError):
except (ModuleNotFoundError, AttributeError):
zdaemon_loc = os.path.dirname(os.path.dirname(zdaemon.__file__))
zconfig_loc = os.path.dirname(os.path.dirname(ZConfig.__file__))

Expand Down Expand Up @@ -535,7 +535,7 @@ def checkenv(match):
try:
import coverage
except ImportError:
except ModuleNotFoundError:
pass
else:
coverage.process_startup()
Expand Down
2 changes: 1 addition & 1 deletion src/zdaemon/tests/testzdoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def test_handler_side_effect(self):
L = []
options.add("setting", None, "a:", "append=", handler=L.append)
options.realize(["-a2", "--append", "3"])
self.assertTrue(options.setting is None)
self.assertIsNone(options.setting)
self.assertEqual(L, ["2", "3"])

def test_handler_with_bad_value(self):
Expand Down
11 changes: 7 additions & 4 deletions src/zdaemon/tests/testzdrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def tearDown(self):
signal.signal(sig, signal.SIG_DFL)
try:
os.unlink(self.zdsock)
except os.error:
except OSError:
pass
output = self.new_stdout.getvalue()
self.assertEqual(self.expect, output)
Expand Down Expand Up @@ -234,8 +234,11 @@ def testRunIgnoresParentSignals(self):
# Make sure the child is still responsive.
response = send_action('status\n', zdrun_socket,
raise_on_error=True)
self.assertTrue(b'\n' in response,
'no newline in response: ' + repr(response))
self.assertIn(
b'\n',
response,
'no newline in response: ' + repr(response)
)
# Kill the process.
send_action('stop\n', zdrun_socket)
finally:
Expand All @@ -252,7 +255,7 @@ def testRunIgnoresParentSignals(self):
for fname in os.listdir(tmp):
try:
os.unlink(os.path.join(tmp, fname))
except os.error:
except OSError:
pass
os.rmdir(tmp)

Expand Down
2 changes: 1 addition & 1 deletion src/zdaemon/zdctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def do_kill(self, arg):
print("kill(%d, %d)" % (self.zd_pid, sig))
try:
os.kill(self.zd_pid, sig)
except os.error as msg:
except OSError as msg:
print("Error:", msg)
else:
print("signal %s sent to process %d" % (signame, self.zd_pid))
Expand Down
23 changes: 12 additions & 11 deletions src/zdaemon/zdrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ def _set_filename(self, program):
filename = program
try:
st = os.stat(filename)
except os.error:
except OSError:
self.options.usage("can't stat program %r" % program)
else:
path = get_path()
for dir in path:
filename = os.path.join(dir, program)
try:
st = os.stat(filename)
except os.error:
except OSError:
continue
mode = st[ST_MODE]
if mode & 0o111:
Expand Down Expand Up @@ -189,7 +189,7 @@ def spawn(self):
self.lasttime = time.time()
try:
pid = os.fork()
except os.error:
except OSError:
return 0
if pid != 0:
# Parent
Expand All @@ -210,11 +210,11 @@ def spawn(self):
for i in range(3, 100):
try:
os.close(i)
except os.error:
except OSError:
pass
try:
os.execv(self.filename, self.args)
except os.error as err:
except OSError as err:
sys.stderr.write("can't exec %r: %s\n" %
(self.filename, err))
sys.stderr.flush() # just in case
Expand All @@ -232,7 +232,7 @@ def kill(self, sig):
return "no subprocess running"
try:
os.kill(self.pid, sig)
except os.error as msg:
except OSError as msg:
return str(msg)
return None

Expand Down Expand Up @@ -268,7 +268,7 @@ def run(self):
finally:
try:
os.unlink(self.options.sockname)
except os.error:
except OSError:
pass

mastersocket = None
Expand All @@ -286,7 +286,7 @@ def opensocket(self):
try:
os.link(tempname, sockname)
break
except os.error:
except OSError:
# Lock contention, or stale socket.
self.checkopen()
# Stale socket -- delete, sleep, and try again.
Expand All @@ -311,7 +311,7 @@ def opensocket(self):
def unlink_quietly(self, filename):
try:
os.unlink(filename)
except os.error:
except OSError:
pass

def checkopen(self):
Expand Down Expand Up @@ -347,7 +347,7 @@ def sigexit(self, sig, frame):
def sigchild(self, sig, frame):
try:
pid, sts = os.waitpid(-1, os.WNOHANG)
except os.error:
except OSError:
return
if pid:
if pid == self.proc.pid:
Expand Down Expand Up @@ -396,7 +396,7 @@ def daemonize(self):
if self.options.directory:
try:
os.chdir(self.options.directory)
except os.error as err:
except OSError as err:
self.logger.warn("can't chdir into %r: %s"
% (self.options.directory, err))
else:
Expand Down Expand Up @@ -767,6 +767,7 @@ def get_path():

class _ChildExits(dict):
"""map ``pid`` to exit status or ``None``."""

def fetch(self, pid):
"""fetch and reset status for *pid*."""
st = self.get(pid)
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ basepython = python3
allowlist_externals =
mkdir
setenv =
COVERAGE_PROCESS_START={toxinidir}/.coveragerc
COVERAGE_PROCESS_START={toxinidir}/pyproject.toml
COVERAGE_HOME={toxinidir}/
deps =
coverage[toml]
Expand Down

0 comments on commit a47be47

Please sign in to comment.