class_docstr: Tests for one-off or random functionality. Try not to add to this!
class_docstr_tok: ["Tests","for","one-off","or","random","functionality",".","Try","not","to","add","to","this","!"]
docstr: The standard library performs sys.module assignment hackery which
  causes modules who do this hackery to fail on import. See
  https://github.com/pytorch/pytorch/issues/57490 for more information.
docstr_tok: ["The","standard","library","performs","sys.module","assignment","hackery","which","causes","modules","who","do","this","hackery","to","fail","on","import",".","See","https",":","\/\/github.com\/pytorch\/pytorch\/issues\/57490","for","more","information","."]
code: def test_std_lib_sys_hackery_checks(self):
      """
      The standard library performs sys.module assignment hackery which
      causes modules who do this hackery to fail on import. See
      https://github.com/pytorch/pytorch/issues/57490 for more information.
      """
      import package_a.std_sys_module_hacks
  
      buffer = BytesIO()
      mod = package_a.std_sys_module_hacks.Module()
  
      with PackageExporter(buffer) as pe:
          pe.intern("**")
          pe.save_pickle("obj", "obj.pkl", mod)
  
      buffer.seek(0)
      pi = PackageImporter(buffer)
      mod = pi.load_pickle("obj", "obj.pkl")
      mod()
  
imports: import inspect
  import os
  import platform
  import sys
  from io import BytesIO
  from pathlib import Path
  from textwrap import dedent
  from unittest import skipIf
  from torch.package import is_from_package, PackageExporter, PackageImporter
  from torch.package.package_exporter import PackagingError
  from torch.testing._internal.common_utils import IS_FBCODE, IS_SANDCASTLE, run_tests, skipIfTorchDynamo
label_desc: Use image node_id 11 for calling the TestMisc obj's underlying member method code with example usage: obj.test_std_lib_sys_hackery_checks() without return types