code: def test_sys_setobject(self):
      # Test PySys_SetObject()
      setobject = _testcapi.sys_setobject
  
      value = ["value"]
      value2 = ["value2"]
      try:
          self.assertEqual(setobject(b"newattr", value), 0)
          self.assertIs(sys.newattr, value)
          self.assertEqual(setobject(b"newattr", value2), 0)
          self.assertIs(sys.newattr, value2)
          self.assertEqual(setobject(b"newattr", NULL), 0)
          self.assertFalse(hasattr(sys, "newattr"))
          self.assertEqual(setobject(b"newattr", NULL), 0)
      finally:
          with contextlib.suppress(AttributeError):
              del sys.newattr
      try:
          self.assertEqual(setobject("\U0001f40d".encode(), value), 0)
          self.assertIs(getattr(sys, "\U0001f40d"), value)
          self.assertEqual(setobject("\U0001f40d".encode(), NULL), 0)
          self.assertFalse(hasattr(sys, "\U0001f40d"))
      finally:
          with contextlib.suppress(AttributeError):
              delattr(sys, "\U0001f40d")
  
      with self.assertRaises(UnicodeDecodeError):
          setobject(b"\xff", value)
  
file_path: cpython/Lib/test/test_capi/test_sys.py
imports: import unittest
  import contextlib
  import sys
  from test import support
  from test.support import import_helper
label_desc: Use image node_id 2 for calling the CAPITest obj's underlying member method code with example usage: obj.test_sys_setobject() without return types