diff --git a/Lib/test/test_docxmlrpc.py b/Lib/test/test_docxmlrpc.py
index 7086d9a6a12..cb6366c7d5c 100644
--- a/Lib/test/test_docxmlrpc.py
+++ b/Lib/test/test_docxmlrpc.py
@@ -202,10 +202,12 @@ def test_annotations(self):
""" Test that annotations works as expected """
self.client.request("GET", "/")
response = self.client.getresponse()
+ docstring = (b'' if sys.flags.optimize >= 2 else
+ b'
Use function annotations.')
self.assertIn(
(b'- annotation'
- b'(x: int)
- Use function annotations.'
- b'
\n- '
+ b'(x: int)
' + docstring + b'
\n'
+ b'- '
b'method_annotation(x: bytes)
'),
response.read())
diff --git a/Misc/NEWS b/Misc/NEWS
index 5a760ba625c..0eac7fb2ad7 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -97,6 +97,8 @@ Library
Tests
-----
+- Issue #19535: Fixed test_docxmlrpc when python is run with -OO.
+
- Issue #19926: Removed unneeded test_main from test_abstract_numbers.
Patch by Vajrasky Kok.