As I was debugging serial communication between an ST Nucleo F303 board and a Raspberry Pi I found that the RPi baud rates are a way off on a RPi3. Then googled and found this git post that discusses the issue:
Here are some measurements to prove it at 115200 and 230400 bit/s baud rates. The slower speeds are equally off. Read more for working around this problem.
ser = serial.Serial('/dev/ttyS0',15350)
where the 15350 is from the table above in the 9600 row.