code: def test_set_object(self):
      # new exception as obj is not an exception
      with self.assertRaises(ValueError) as e:
          _testcapi.exc_set_object(ValueError, 42)
      self.assertEqual(e.exception.args, (42,))
  
      # wraps the exception because unrelated types
      with self.assertRaises(ValueError) as e:
          _testcapi.exc_set_object(ValueError, TypeError(1, 2, 3))
      wrapped = e.exception.args[0]
      self.assertIsInstance(wrapped, TypeError)
      self.assertEqual(wrapped.args, (1, 2, 3))
  
      # is superclass, so does not wrap
      with self.assertRaises(PermissionError) as e:
          _testcapi.exc_set_object(OSError, PermissionError(24))
      self.assertEqual(e.exception.args, (24,))
  
      class Meta(type):
          def __subclasscheck__(cls, sub):
              1 / 0
  
      class Broken(Exception, metaclass=Meta):
          pass
  
      with self.assertRaises(ZeroDivisionError) as e:
          _testcapi.exc_set_object(Broken, Broken())
  
imports: import errno
  import os
  import re
  import sys
  import unittest
  from test import support
  from test.support import import_helper
  from test.support.os_helper import TESTFN, TESTFN_UNDECODABLE
  from test.support.script_helper import assert_python_failure
  from test.support.testcase import ExceptionIsLikeMixin
  from .test_misc import decode_stderr
label_desc: Use image node_id 3 for calling the Test_ErrSetAndRestore obj's underlying member method code with example usage: obj.test_set_object() without return types