From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Juan Carlos Garcia <jgarcia@cloudlinux.com>
Date: Mon, 11 May 2026 10:00:00 +0200
Subject: [PATCH] test.support: add control_characters_c0() helper

Backport of the test fixture added by upstream commit:

	From f7fceed79ca1bceae8dbe5ba5bc8928564da7211 Mon Sep 17 00:00:00 2001
	From: Seth Michael Larson <seth@python.org>
	Date: Tue, 20 Jan 2026 (gh-143916)
	Subject: [PATCH] gh-143916: Reject control characters in
	         wsgiref.headers.Headers + Add 'test.support' fixture
	         for C0 control characters

Cherry-picked from python/cpython@2f840249550e082dc351743f474ba56da10478d2
([3.10] backport).

Adapted for Python 3.6: the upstream patch anchors on the
adjust_int_max_str_digits() context manager (PEP 686, introduced
in 3.11.4), which is absent on 3.6. The helper is appended right
after the FakePath class which ends Lib/test/support/__init__.py
on 3.6. The PEP 585 ``list[str]`` annotation in the upstream
signature is also dropped here because it is invalid syntax on
3.6 (TypeError 'type' object is not subscriptable). The helper
is a test-only fixture so the annotation has no API consumers.

This helper is referenced by the new tests added by the
CVE-2026-0672, CVE-2026-3644, and CVE-2025-15282 backports below.
Without the helper, those tests collection-fail with NameError.
The production-code fixes in those CVE patches are unaffected;
this patch only fixes test execution.

---
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -2893,3 +2893,10 @@
             raise self.path
         else:
             return self.path
+
+
+def control_characters_c0():
+    """Returns a list of C0 control characters as strings.
+    C0 control characters defined as the byte range 0x00-0x1F, and 0x7F.
+    """
+    return [chr(c) for c in range(0x00, 0x20)] + ["\x7F"]
