bpo-29730: replace some calls to PyNumber_Check and improve some error messages (#650)

diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c
index 0a0e5e7..59b917d 100644
--- a/Modules/_io/bytesio.c
+++ b/Modules/_io/bytesio.c
@@ -578,12 +578,18 @@
         /* Truncate to current position if no argument is passed. */
         size = self->pos;
     }
-    else {
+    else if (PyIndex_Check(arg)) {
         size = PyNumber_AsSsize_t(arg, PyExc_OverflowError);
         if (size == -1 && PyErr_Occurred()) {
             return NULL;
         }
     }
+    else {
+        PyErr_Format(PyExc_TypeError,
+                     "argument should be integer or None, not '%.200s'",
+                     Py_TYPE(arg)->tp_name);
+        return NULL;
+    }
 
     if (size < 0) {
         PyErr_Format(PyExc_ValueError,