[Python] `tzinfo_to_string` should accept None
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 91
Description
Currently `tzinfo_to_string` errors with `Not an instance of datetime.tzinfo` when timezone is None.
```python
>>> tz = None
>>> import pyarrow
>>> pyarrow.lib.tzinfo_to_string(None)
Traceback (most recent call last):
File "", line 1, in
File "pyarrow/types.pxi", line 2080, in pyarrow.lib.tzinfo_to_string
return frombytes(GetResultValue(TzinfoToString(tz)))
File "pyarrow/error.pxi", line 143, in pyarrow.lib.pyarrow_internal_check_status
return check_status(status)
File "pyarrow/error.pxi", line 122, in pyarrow.lib.check_status
raise ArrowTypeError(message)
pyarrow.lib.ArrowTypeError: Not an instance of datetime.tzinfo
```
`tzinfo_to_string` should accept None also. With this `arrays()` in python/pyarrow/tests/strategies.py in case of timestamp dtype should also accept None.
See
- [https://github.com/apache/arrow/pull/12522#discussion_r822637011](https://github.com/apache/arrow/pull/12522#discussion_r837216640)
-
**Reporter**: [Alenka Frim](https://issues.apache.org/jira/browse/ARROW-16056) / @AlenkaF
**Note**: *This issue was originally created as [ARROW-16056](https://issues.apache.org/jira/browse/ARROW-16056). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*
Contributor guide
Research direction
Start with the tzinfo_to_string entry point in pyarrow/types.pxi and inspect the timestamp handling in python/pyarrow/tests/strategies.py. Reproduce the None case, then run the relevant Python tests and confirm that tzinfo_to_string(None) succeeds and timestamp arrays() strategies accept None.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100