He asked the Prophet ﷺ about the dwellings of the polytheists which are raided at night, where their children and women may be struck down. The Prophet ﷺ said, "They are of them."Amr, meaning Ibn Dinar, used to say, "They belong to their fathers."Zuhri said, "Then the Messenger of Allah ﷺ later forbade the killing of women and children."
حدثنا أحمد بن عمرو بن السرح حدثنا سفيان عن الزهري عن عبيد الله يعني ابن عبد الله عن ابن عباس
أنه سأل النبي ﷺ عن الدار من المشركين يبيتون فيصاب من ذراريهم ونسائهم فقال النبي ﷺ هم منهم وكان عمرو يعني ابن دينار يقول هم من آبائهم قال الزهري ثم نهى رسول الله ﷺ بعد ذلك عن قتل النساء والولدان
Reported by Bukhari, jihad and expeditions, chapter on people of a house being raided at night when children and dependents are struck, hadith no. 3012, and Muslim, jihad, chapter on the permissibility of killing women and children in a night raid without deliberate intent, hadith no. 1745, from the hadith of Sufyan bin Uyayna, with this same wording.