MAINT: use PyOS_snprintf instead of snprintf

PyOS_snprintf is portable and more secure than snprintf.
Merge pull request #3716 from charris/backport-1.7-3418

Backport 1.7 3418