bpo-33817: Fix _PyBytes_Resize() for empty bytes object. (GH-11516)

Add also tests for PyUnicode_FromFormat() and PyBytes_FromFormat()
with empty result.
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index cc43321..f7454d9 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -1001,6 +1001,12 @@
         self.assertRaises(OverflowError,
                           PyBytes_FromFormat, b'%c', c_int(256))
 
+        # Issue #33817: empty strings
+        self.assertEqual(PyBytes_FromFormat(b''),
+                         b'')
+        self.assertEqual(PyBytes_FromFormat(b'%s', b''),
+                         b'')
+
     def test_bytes_blocking(self):
         class IterationBlocked(list):
             __bytes__ = None
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index fb7bb2d..c277e70 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -2680,6 +2680,12 @@
         check_format('%.%s',
                      b'%.%s', b'abc')
 
+        # Issue #33817: empty strings
+        check_format('',
+                     b'')
+        check_format('',
+                     b'%s', b'')
+
     # Test PyUnicode_AsWideChar()
     @support.cpython_only
     def test_aswidechar(self):