It was the first move made by Montreal, which gave up a second-round pick and a conditional fifth-round pick in the deal. According to ESPN.com's Pierre LeBrun, the condition on the pick is that it becomes a fourth if the Habs win a playoff round, or a third if the Habs win two rounds.
Petry, 27, has four goals and 11 points in 59 games for the Oilers this season.
Flynn, 26, has five goals and 17 points in 54 games this season for the Sabres.
Forward Max Pacioretty was pleased Canadiens GM Marc Bergevin added three players without altering the Atlantic Division-leading team's chemistry. Montreal gave up a combined four draft picks and minor league prospect Jack Nevins.
"We're getting rewarded for our good play right now," Pacioretty said. "I think (Bergevin) saw a couple of areas he can improve on but not change things too much."
The Associated Press contributed to this report.