complain about "global __class__" in a class body (closes #17983)
diff --git a/Lib/test/test_scope.py b/Lib/test/test_scope.py
index 41678b5..26ce042 100644
--- a/Lib/test/test_scope.py
+++ b/Lib/test/test_scope.py
@@ -743,6 +743,10 @@
         del tester
         self.assertIsNone(ref())
 
+    def test__Class__Global(self):
+        s = "class X:\n    global __class__\n    def f(self): super()"
+        self.assertRaises(SyntaxError, exec, s)
+
 
 def test_main():
     run_unittest(ScopeTests)
diff --git a/Misc/NEWS b/Misc/NEWS
index c45a87b..d6c151f 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@
 Core and Builtins
 -----------------
 
+- Issue #17983: Raise a SyntaxError for a ``global __class__`` statement in a
+  class body.
+
 - Issue #17927: Frame objects kept arguments alive if they had been copied into
   a cell, even if the cell was cleared.
 
diff --git a/Python/symtable.c b/Python/symtable.c
index 55898f9..e686d9e 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -1236,6 +1236,12 @@
         asdl_seq *seq = s->v.Global.names;
         for (i = 0; i < asdl_seq_LEN(seq); i++) {
             identifier name = (identifier)asdl_seq_GET(seq, i);
+            if (st->st_cur->ste_type == ClassBlock &&
+                !PyUnicode_CompareWithASCIIString(name, "__class__")) {
+                PyErr_SetString(PyExc_SyntaxError, "cannot make __class__ global");
+                PyErr_SyntaxLocationEx(st->st_filename, s->lineno, s->col_offset);
+                return 0;
+            }
             long cur = symtable_lookup(st, name);
             if (cur < 0)
                 VISIT_QUIT(st, 0);