Sony Pictures has been forced to apologise for a scene in its new Peter Rabbit movie, starring James Corden as Beatrix Potter's mischievous bunny, after widespread complaints from viewers and parents.

The scene in question sees Peter and his rabbit friends pelt Domhnall Gleeson's antagonistic character Thomas McGregor with blackberries, despite knowing he's allergic to them. When he swallows one he has to stab himself with a hypodermic shot to fend off a potentially deadly reaction.

An online petition has been signed by nearly 9,500 people, prompting a response from Sony.

"Food allergies are a serious issue," Sony said in a statement. "Our film should not have made light of Peter Rabbit's arch nemesis, Mr. McGregor, being allergic to blackberries, even in a cartoonish, slapstick way.

"We sincerely regret not being more aware and sensitive to this issue, and we truly apologise."

Peter Rabbit was released this past weekend in the US, taking just $25m (£18m) on its opening weekend, losing out to Universal's Fifty Shades Freed. The film arrives in UK cinemas on 16 March.

The online petition was started by Globalaai, an organisation that describes itself as "a worldwide allergy and anaphylaxis movement for positive change of social awareness and safety".

Globalaai says it was "appalled" by the scene, adding: "This mocks the seriousness of allergic disease and is heartbreakingly disrespectful to the families of those that have lost loved ones to anaphylaxis."

"Furthermore this is a socially irresponsible depiction in a movie aimed at children and based on an iconic and classic children's story. To spread a message that condones such victimising and dangerous behaviour amongst children is grossly offensive to worldwide viewers especially those who live with severe allergic disease."

The Kids With Food Allergies Foundation (KFA) said in a statement: "The new movie, Peter Rabbit, has a scene that may be disturbing to young viewers who have a food allergy.

"KFA believes that food allergy 'jokes' are harmful to our community. During a reaction, patients require the life-saving drug epinephrine and must go to the nearest hospital for follow-up treatment.

"The very real fear and anxiety that people experience during an allergic reaction (often referred to as an impending sense of doom) is a serious matter. Making light of this condition hurts our members because it encourages the public not to take the risk of allergic reactions seriously, and this cavalier attitude may make them act in ways that could put an allergic person in danger."