He said, "If a man declares his wife forbidden to himself, it counts as an oath that requires expiation," and he recited, "Indeed, you have in the Messenger of Allah an excellent example to follow" [Ahzab 33:21].
إذا حرم الرجل عليه امرأته، فهي يمين يكفرها، وقال: {لقد كان لكم في رسول الله أسوة حسنة} [الأحزاب: ٢١].
Bukhari narrated it in the Book of Divorce (5266) and Muslim in the Book of Divorce (1473:19), both through Muawiya, meaning Ibn Salam, from Yahya bin Abu Kathir, that Yaala bin Hakeem informed him, that Saeed bin Jubayr informed him, that he heard Ibn Abbas say, and he mentioned it. The wording is Muslim's, and Bukhari's wording is similar. So whoever declares something lawful forbidden to himself must make atonement and return from what he has forbidden to himself.