Praise be to Allah.
This view was narrated from Abu Haneefah (may Allah have mercy on him) by his student Muhammad ibn al-Hasan in his book al-Hujjah ‘ala Ahl al-Madinah (1/399).
Abu Haneefah (may Allah have mercy on him) said, concerning a woman who fears for her child, and it is too hard for her to fast in the month of Ramadan:
She may break the fast, but she must make it up later on, and she does not have to give charity [fidyah]. Rather this comes under the heading of sickness, so no charity is required for it. End quote.
This is not the view of Abu Haneefah only; rather his students Abu Yoosuf, Zufar, and Muhammad ibn al-Hasan followed him in that. Al-Jassaas said:
Abu Haneefah, Abu Yoosuf, Muhammad, Zufar, ath-Thawri and al-Hasan ibn Hayy said: If they [pregnant and breastfeeding women] fear for their children, or for themselves, then they may break the fast and make it up later on, and no expiation is required of them.
End quote from Ahkaam al-Qur’an (1/223).
With regard to the report from ‘Ali ibn Abi Taalib (may Allah be pleased with him), it was mentioned by a number of scholars, but we have not come across it in the books of reports that are available to us.
If a pregnant or breastfeeding woman fears for herself or her child, she may break the fast, because the Prophet (blessings and peace of Allah be upon him) said: Allah, may He be exalted, has exempted the traveller from half of the prayer and the fast, and has exempted the pregnant and breastfeeding women from fasting.” And because it causes hardship to her or her child, and hardship is an excuse that allows one to break the fast, as in the case of one who is sick and one who is travelling. She must make up the fast later on, but she does not have to offer expiation, because she is not committing an infraction by breaking the fast, and no fidyah is required of her in our view.
Our view is narrated from ‘Ali and Ibn ‘Abbaas (may Allah be pleased with them both).
End quote from al-Mabsoot (3/99). Something similar is to be found in Badaa’i‘ as-Sanaa’i‘ (2/97) and in Ahkaam al-Qur’an by al-Jassaas (1/224).
And Allah knows best.