Make pd.Period immutable
State: closed

Follows @jreback 's suggestion in #17116 to define `_Period.ordinal` and `_Period.freq` as `def readonly` attributes.  This requires massaging `__new__/__init__` a bit.

Adds a quick test that these attributes can't be changed.

Note that this doesn't fully solve the issue of Periods being immutable because `per.freq` is a `DateOffset` object which itself can be messed with.

- [ ] closes #
- [ ] tests added / passed
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry


Labels:
name: Period
description: Period data type
name: Compat
description: pandas objects compatability with Numpy or Python functions

Comments:
Hello @jbrockmendel! Thanks for updating the PR.



Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on August 24, 2017 at 10:02 Hours UTC
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17239?src=pr&el=h1) Report
> Merging [#17239](https://codecov.io/gh/pandas-dev/pandas/pull/17239?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/2bec750b21b8715e3f55e71a6c69f2abef54d08b?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff             @@
##           master   #17239      +/-   ##
==========================================
- Coverage   91.01%   90.99%   -0.02%     
==========================================
  Files         162      162              
  Lines       49558    49558              
==========================================
- Hits        45105    45096       -9     
- Misses       4453     4462       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.77% <ø> (ø)` | :arrow_up: |
| #single | `40.25% <ø> (-0.07%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17239?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/17239?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17239?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.72% <0%> (-0.1%)` | :arrow_down: |
| [pandas/errors/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/17239?src=pr&el=tree#diff-cGFuZGFzL2Vycm9ycy9fX2luaXRfXy5weQ==) | `100% <0%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17239?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/17239?src=pr&el=footer). Last update [2bec750...f739f8f](https://codecov.io/gh/pandas-dev/pandas/pull/17239?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

thanks!