how about just before this putting

```
try:
    n = as_int(n)
except ValueError:
    pass
if visual and isinstance(n, Integer):
    ...
elif...
elif...
else:
    raise ValueError('unexpected input: %s' % n)
```

Also, watch out for the difference between 'is_integer' which applies to 42 and Symbol('x', integer=True) and 'is_Integer' which only applies to Integer(42)-like things.