Introduce chaos to prevent GC from being disabled
This commit is contained in:
19
heaven.py
19
heaven.py
@@ -1,5 +1,7 @@
|
|||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
import sys
|
||||||
|
from importlib.util import spec_from_loader
|
||||||
|
|
||||||
|
|
||||||
class a_place_on_earth(list):
|
class a_place_on_earth(list):
|
||||||
@@ -23,6 +25,23 @@ class Dog:
|
|||||||
global heaven
|
global heaven
|
||||||
heaven.append(self)
|
heaven.append(self)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def disable():
|
||||||
|
sys.stdout.write("Arf!\n")
|
||||||
|
|
||||||
|
|
||||||
|
class Chaos:
|
||||||
|
def find_spec(self, n, *_):
|
||||||
|
if len(n) == 2:
|
||||||
|
return spec_from_loader(n, self)
|
||||||
|
|
||||||
|
# breaks in 3.15
|
||||||
|
@staticmethod
|
||||||
|
def load_module(n):
|
||||||
|
sys.modules[n] = Dog
|
||||||
|
|
||||||
|
|
||||||
|
sys.meta_path.insert(0, Chaos())
|
||||||
|
|
||||||
import gc
|
import gc
|
||||||
gc.disable()
|
gc.disable()
|
||||||
|
Reference in New Issue
Block a user