BUG: type aliasing is not allowed to be compared using isinstance()
State: closed

- [X] closes #21078
- [ ] tests added / passed
- [X] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

As raised in #21078, Python 3.5.4 supports the using `isinstance()` with `typing.re.Pattern` But it does not support the same method in 3.5.2.

``` Python
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> import typing
>>> isinstance(re.compile(''), typing.re.Pattern)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.5/typing.py", line 260, in __instancecheck__
    raise TypeError("Type aliases cannot be used with isinstance().")
TypeError: Type aliases cannot be used with isinstance().
```

This Bugfix PR is to revert the `re_type` to be back to what it used to be before the update with the new release.


Labels:
name: Strings
description: String extension data type and string data
name: Compat
description: pandas objects compatability with Numpy or Python functions

Comments:
Thanks for the PR. Reading through the issue I think the suggestion was to only use the old way for 3.5.2 and older, but should keep it for newer versions. 

You'd be better off just changing the original condition to if `sys.version_info >= (3,5,3)` (or 3.5.4 - whichever is applicable)
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21098?src=pr&el=h1) Report
> Merging [#21098](https://codecov.io/gh/pandas-dev/pandas/pull/21098?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/d623ffd90f57abda2beb34d807da58ca95b3743d?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/21098/graphs/tree.svg?width=650&height=150&src=pr&token=eZ4WkYLtcO)](https://codecov.io/gh/pandas-dev/pandas/pull/21098?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master   #21098   +/-   ##
=======================================
  Coverage   91.83%   91.83%           
=======================================
  Files         153      153           
  Lines       49497    49497           
=======================================
  Hits        45456    45456           
  Misses       4041     4041
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.23% <100%> (ø)` | :arrow_up: |
| #single | `41.88% <100%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/21098?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/compat/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/21098/diff?src=pr&el=tree#diff-cGFuZGFzL2NvbXBhdC9fX2luaXRfXy5weQ==) | `58.43% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21098?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21098?src=pr&el=footer). Last update [d623ffd...278e67e](https://codecov.io/gh/pandas-dev/pandas/pull/21098?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

That makes a lot more sense.

I only changed the `PY35` so thatthe `re_type = typing.re.Pattern` is only applicable for 3.5.4 or above.
No I wouldn’t do that - that item is used many other places in the package so there are a lot of implications there. I meant just change the original conditional that you removed
Noob mistake! I just made sure that the conditional statement is only applicable when `sys.version_info` is 3.5.4 or above.
also pls add a note in the whatsnew (0.23.1) add a strings sub-section in bug fixes
Should do the trick. Thanks for the guidance!
Thanks for the quick fix!