From 5a45846df7bc8cbc683b2b19ba11d20bb7f6fdf1 Mon Sep 17 00:00:00 2001 From: Adi Roiban Date: Tue, 16 Jan 2024 14:42:20 +0100 Subject: [PATCH] Update dis.findlinestarts for Python 3.13 --- src/twisted/python/deprecate.py | 6 +++++- src/twisted/trial/_synctest.py | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/twisted/python/deprecate.py b/src/twisted/python/deprecate.py index c85b98d..08d37eb 100644 --- a/src/twisted/python/deprecate.py +++ b/src/twisted/python/deprecate.py @@ -606,7 +606,11 @@ def warnAboutFunction(offender, warningString): warningString, category=DeprecationWarning, filename=inspect.getabsfile(offenderModule), - lineno=max(lineNumber for _, lineNumber in findlinestarts(offender.__code__)), + lineno=max( + lineNumber + for _, lineNumber in findlinestarts(offender.__code__) + if lineNumber is not None + ), module=offenderModule.__name__, registry=offender.__globals__.setdefault("__warningregistry__", {}), module_globals=None, diff --git a/src/twisted/trial/_synctest.py b/src/twisted/trial/_synctest.py index 2cffc2c..8d8e9b1 100644 --- a/src/twisted/trial/_synctest.py +++ b/src/twisted/trial/_synctest.py @@ -1192,6 +1192,7 @@ class SynchronousTestCase(_Assertions): lineNumbers = [ lineNumber for _, lineNumber in _findlinestarts(aFunction.__code__) + if lineNumber is not None ] if not (min(lineNumbers) <= aWarning.lineno <= max(lineNumbers)): continue -- 2.43.0