كتاب الجنائز
11  
The Book of Prayer - Funerals
(10)
Chapter: Stern warning against wailing
(10)
باب التَّشْدِيدِ فِي النِّيَاحَةِ
Sahih Muslim 937

Hafsa narrated on the authority of Umm 'Atiyya that she said:

When this verse was revealed:" When believing women came to thee giving thee a pledge that they will not associate aught with Allah, and will not disobey thee in good" (lx. 12), she (Umm Atiyya) said: In (this pledge) was also included wailing. I said: Messenger of Allah, except members of such a tribe who helped me (in lamentation) during pre-Islamic days, there is left no alternative for me, but that I should also help them. Upon this the Messenger of Allah (ﷺ) said: (Yes) but only in case of the members of such a tribe.
وَحَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، وَزُهَيْرُ بْنُ حَرْبٍ، وَإِسْحَاقُ بْنُ إِبْرَاهِيمَ، جَمِيعًا عَنْ أَبِي مُعَاوِيَةَ، - قَالَ زُهَيْرٌ حَدَّثَنَا مُحَمَّدُ بْنُ خَازِمٍ، - حَدَّثَنَا عَاصِمٌ، عَنْ حَفْصَةَ، عَنْ أُمِّ، عَطِيَّةَ قَالَتْ لَمَّا نَزَلَتْ هَذِهِ الآيَةُ ‏{‏ يُبَايِعْنَكَ عَلَى أَنْ لاَ يُشْرِكْنَ بِاللَّهِ شَيْئًا‏}‏ ‏{‏ وَلاَ يَعْصِينَكَ فِي مَعْرُوفٍ‏}‏ قَالَتْ كَانَ مِنْهُ النِّيَاحَةُ ‏.‏ قَالَتْ فَقُلْتُ يَا رَسُولَ اللَّهِ إِلاَّ آلَ فُلاَنٍ فَإِنَّهُمْ كَانُوا أَسْعَدُونِي فِي الْجَاهِلِيَّةِ فَلاَ بُدَّ لِي مِنْ أَنْ أُسْعِدَهُمْ ‏.‏ فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ إِلاَّ آلَ فُلاَنٍ ‏"‏ ‏.‏
Reference : Sahih Muslim 937
In-book reference : Book 11, Hadith 43
USC-MSA web (English) reference : Book 4, Hadith 2038
  (deprecated numbering scheme)