"""Minimal repro: PyQt6 signal emit with None changes the refcount of None on Python 3.14.

None is immortal on 3.12+, so its refcount should never change. On 3.14 it grows on
pyqtSignal(..., object, ...).emit(..., None, ...). Same PyQt6 / Qt / sip on 3.13: no change.
"""
import ctypes
import os
import sys

os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
from PyQt6 import QtCore, QtWidgets
from PyQt6.sip import SIP_VERSION_STR


def none_refcount():
    return ctypes.c_uint64.from_address(id(None)).value


class W(QtCore.QObject):
    sig = QtCore.pyqtSignal(str, object, object)

    @QtCore.pyqtSlot(str, object, object)
    def slot(self, a, b, c):
        pass


app = QtWidgets.QApplication([])
w = W()
w.sig.connect(w.slot)

N = 100000
before = none_refcount()
for _ in range(N):
    w.sig.emit("k", None, None)
after = none_refcount()

print("python", sys.version.split()[0], "| PyQt6", QtCore.PYQT_VERSION_STR, "| Qt", QtCore.QT_VERSION_STR,
      "| sip", SIP_VERSION_STR)
print("None refcount before: %#x  after: %#x  delta: %d (2 None args x %d emits)" % (before, after, after - before, N))
print("RESULT:", "OK (unchanged)" if after == before else "BUG (None refcount changed)")
