Pandas version checks

  • [X] I have checked that this issue has not already been reported.

  • [X] I have confirmed this bug exists on the latest version of pandas.

  • [X] I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

>>> # pandas 1.5.2
>>> index = pd.DatetimeIndex(['2000-01-01 12:00:00+00:00'])
>>> type(index.tz)
<class 'pytz.UTC'>
>>> index.tz.zone
'UTC'
>>> # pandas 2.0.1
>>> import pytz
>>> index = pd.DatetimeIndex(['2000-01-01 12:00:00+00:00'])
>>> type(index.tz)
<class 'datetime.timezone'>
>>> index.tz.zone
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'datetime.timezone' object has no attribute 'zone'

```

Issue Description

In pandas 1.5.2 I am able to check the timezone of a DatetimeIndex as shown in the example.

In pandas 2.0.1 I'm getting a ValueError, because the type of the tz attribute changed.

Expected Behavior

I don't know if this is a bug, I did not expect the type of tz to change when upgrading pandas.

If this is not a bug, how would I check the timezone of a DatetimeIndex correctly?

Installed Versions

For 1.5.2 INSTALLED VERSIONS ------------------ commit : 8dab54d6573f7186ff0c3b6364d5e4dd635ff3e7 python : 3.8.7.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.22621 machine : AMD64 processor : AMD64 Family 23 Model 96 Stepping 1, AuthenticAMD byteorder : little LC_ALL : None LANG : None LOCALE : de_DE.cp1252 pandas : 1.5.2 numpy : 1.24.3 pytz : 2023.3 dateutil : 2.8.2 setuptools : 49.2.1 pip : 20.2.3 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : None IPython : None pandas_datareader: None bs4 : None bottleneck : None brotli : None fastparquet : None fsspec : None gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyreadstat : None pyxlsb : None s3fs : None scipy : None snappy : None sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None xlwt : None zstandard : None tzdata : 2023.3 For 2.0.1 INSTALLED VERSIONS ------------------ commit : 37ea63d540fd27274cad6585082c91b1283f963d python : 3.8.7.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.22621 machine : AMD64 processor : AMD64 Family 23 Model 96 Stepping 1, AuthenticAMD byteorder : little LC_ALL : None LANG : None LOCALE : de_DE.cp1252 pandas : 2.0.1 numpy : 1.24.3 pytz : 2023.3 dateutil : 2.8.2 setuptools : 49.2.1 pip : 20.2.3 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : None IPython : None pandas_datareader: None bs4 : None bottleneck : None brotli : None fastparquet : None fsspec : None gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyreadstat : None pyxlsb : None s3fs : None scipy : None snappy : None sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None zstandard : None tzdata : 2023.3 qtpy : None pyqt5 : None

Comment From: mroeschke

Yes: https://pandas.pydata.org/docs/dev/whatsnew/v2.0.0.html#utc-and-fixed-offset-timezones-default-to-standard-library-tzinfo-objects

.tz will continue to return the timezone of a DatetimeIndex, so closing