From 1482bcc395983351a96fcdfc049118fd7e917f7e Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 26 Jan 2025 18:03:15 +0100 Subject: [PATCH] basexmpp: make_iq no longer defaults to id="0" having a hardcoded default ID in make_iq is a bad idea, particularly since it will overwrite the (good) id produced byt Iq() when a stream is available. This is arguably a breaking change, but I certainly hope it is not breaking anything in the real world. --- slixmpp/basexmpp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/slixmpp/basexmpp.py b/slixmpp/basexmpp.py index db9630b0..59b0c849 100644 --- a/slixmpp/basexmpp.py +++ b/slixmpp/basexmpp.py @@ -315,13 +315,12 @@ class BaseXMPP(XMLStream): pres['lang'] = self.default_lang return pres - def make_iq(self, id: str = "0", ifrom: OptJidStr = None, + def make_iq(self, id: Optional[str] = None, ifrom: OptJidStr = None, ito: OptJidStr = None, itype: Optional[IqTypes] = None, iquery: Optional[str] = None) -> stanza.Iq: """Create a new :class:`~.Iq` stanza with a given Id and from JID. :param id: An ideally unique ID value for this stanza thread. - Defaults to 0. :param ifrom: The from :class:`~.JID` to use for this stanza. :param ito: The destination :class:`~.JID` @@ -332,7 +331,8 @@ class BaseXMPP(XMLStream): :param iquery: Optional namespace for adding a query element. """ iq = self.Iq() - iq['id'] = str(id) + if id is not None: + iq['id'] = str(id) iq['to'] = ito iq['from'] = ifrom iq['type'] = itype