BUG: Fix Segfault with pd.tslib.get_period_field (GH4519, GH4520)
Fixes the following problem (issues #4519, #4520):

``` python
>>> import pandas as pd
>>> pd.tslib.get_period_field(11, 1, 1)
Exception ValueError: ValueError('Unrecognized code: 11',) in 'pandas.tslib._get_accessor_func' ignored
Segmentation fault
```

Indeed, that would work but it seems to be simpler and cheaper to check f against NULL rather than using Cython's exception specification machinery.
 its fine...just pointing out another way...pls rebase and squash commits into 1 and i'll merge you in
 Done! Thanks.
 @prossahl thank you!
