Title: AttributeError: 'NoneType' object has no attribute 'convert' with ZoneInfo · Issue #646 · python-pendulum/pendulum · GitHub
Open Graph Title: AttributeError: 'NoneType' object has no attribute 'convert' with ZoneInfo · Issue #646 · python-pendulum/pendulum
X Title: AttributeError: 'NoneType' object has no attribute 'convert' with ZoneInfo · Issue #646 · python-pendulum/pendulum
Description: I am on the latest Pendulum version. I have searched the issues of this repo and believe that this is not a duplicate. OS version and name: 4.19.128-microsoft-standard Linux Pendulum version: 2.1.2 Issue Reproducible example import pendu...
Open Graph Description: I am on the latest Pendulum version. I have searched the issues of this repo and believe that this is not a duplicate. OS version and name: 4.19.128-microsoft-standard Linux Pendulum version: 2.1.2...
X Description: I am on the latest Pendulum version. I have searched the issues of this repo and believe that this is not a duplicate. OS version and name: 4.19.128-microsoft-standard Linux Pendulum version: 2.1.2...
Opengraph URL: https://github.com/python-pendulum/pendulum/issues/646
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"AttributeError: 'NoneType' object has no attribute 'convert' with ZoneInfo","articleBody":"\u003c!--\r\n Hi there! Thank you for discovering and submitting an issue.\r\n\r\n Before you submit this; let's make sure of a few things.\r\n Please make sure the following boxes are ticked if they are correct.\r\n If not, please try and fulfill these first.\r\n-->\r\n\r\n\u003c!-- Checked checkbox should look like this: [x] -->\r\n- [x] I am on the [latest](https://github.com/sdispater/pendulum/releases/latest) Pendulum version.\r\n- [x] I have searched the [issues](https://github.com/sdispater/pendulum/issues) of this repo and believe that this is not a duplicate.\r\n\r\n\u003c!--\r\n Once those are done, if you're able to fill in the following list with your information,\r\n it'd be very helpful to whoever handles the issue.\r\n-->\r\n\r\n- **OS version and name**: 4.19.128-microsoft-standard Linux\r\n- **Pendulum version**: 2.1.2\r\n\r\n## Issue\r\n\u003c!-- Now feel free to write your issue, but please be descriptive! Thanks again 🙌 ❤️ -->\r\n\r\n### Reproducible example\r\n\r\n```\r\nimport pendulum\r\nfrom zoneinfo import ZoneInfo\r\n\r\ntz = ZoneInfo(\"Europe/London\")\r\nmy_datetime = pendulum.now()\r\n\r\nmy_datetime.astimezone(tz) # AttributeError: 'NoneType' object has no attribute 'convert'\r\n```\r\n\r\n### Description\r\n\r\nThe above error seems to be thrown when calling `pendulum.astimezone()` with a `ZoneInfo` timezone. We are in the process of migrating a project from `pytz` to `zoneinfo`. The above example works perfectly if `pendulum` is replaced with `datetime.datetime`.\r\n\r\nThanks for reading and looking into this!\r\n\r\n\r\n### Expected behaviour\r\n\r\nFor `pendulum.astimezone()` to successfully convert a datetime object with a `ZoneInfo` timezone. \r\n\r\n### Stack trace\r\n\r\n```python\r\n---------------------------------------------------------------------------\r\nAttributeError Traceback (most recent call last)\r\nInput In [6], in \u003ccell line: 1>()\r\n----> 1 my_datetime.astimezone(tz)\r\n\r\nFile ~/.cache/pypoetry/virtualenvs/vidacycle_webapps-foslGWoH-py3.9/lib/python3.9/site-packages/pendulum/datetime.py:1467, in DateTime.astimezone(self, tz)\r\n 1466 def astimezone(self, tz=None):\r\n-> 1467 return pendulum.instance(super(DateTime, self).astimezone(tz))\r\n\r\nFile ~/.cache/pypoetry/virtualenvs/vidacycle_webapps-foslGWoH-py3.9/lib/python3.9/site-packages/pendulum/datetime.py:1443, in DateTime.__add__(self, other)\r\n 1440 if not isinstance(other, datetime.timedelta):\r\n 1441 return NotImplemented\r\n-> 1443 return self._add_timedelta_(other)\r\n\r\nFile ~/.cache/pypoetry/virtualenvs/vidacycle_webapps-foslGWoH-py3.9/lib/python3.9/site-packages/pendulum/datetime.py:760, in DateTime._add_timedelta_(self, delta)\r\n 755 elif isinstance(delta, pendulum.Duration):\r\n 756 return self.add(\r\n 757 years=delta.years, months=delta.months, seconds=delta._total\r\n 758 )\r\n--> 760 return self.add(seconds=delta.total_seconds())\r\n\r\nFile ~/.cache/pypoetry/virtualenvs/vidacycle_webapps-foslGWoH-py3.9/lib/python3.9/site-packages/pendulum/datetime.py:667, in DateTime.add(self, years, months, weeks, days, hours, minutes, seconds, microseconds)\r\n 645 return pendulum.datetime(\r\n 646 dt.year,\r\n 647 dt.month,\r\n (...)\r\n 653 tz=self.tz,\r\n 654 )\r\n 656 dt = self.__class__(\r\n 657 dt.year,\r\n 658 dt.month,\r\n (...)\r\n 664 tzinfo=UTC,\r\n 665 )\r\n--> 667 dt = self.tz.convert(dt)\r\n 669 return self.__class__(\r\n 670 dt.year,\r\n 671 dt.month,\r\n (...)\r\n 678 fold=dt.fold,\r\n 679 )\r\n\r\nAttributeError: 'NoneType' object has no attribute 'convert'\r\n```\r\n","author":{"url":"https://github.com/taosharma","@type":"Person","name":"taosharma"},"datePublished":"2022-08-26T14:35:24Z","url":"https://github.com/python-pendulum/pendulum/issues/646"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3257f267-ced5-1ead-abee-98895316fff4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CB66:92683:113A2F:17E9A4:6B0464A4 |
| html-safe-nonce | e00619ccde17cad0fc1498ceb506afd67afb914ee9979f4ee9843d6d03fd478f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjY2OjkyNjgzOjExM0EyRjoxN0U5QTQ6NkIwNDY0QTQiLCJ2aXNpdG9yX2lkIjoiNTI5NzIyODQ3OTMwNDMyODM1NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 732c507520d76166926d5bfd74196356d5c2be7d893e004c81863122b4da0248 |
| hovercard-subject-tag | issue:1352355253 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-pendulum/pendulum/646/issue_layout |
| twitter:image | https://opengraph.githubassets.com/95f69e4a53dede2ed83d6d9a1ea5fa86d0f5efbdafceaea5419e4c5b8d15c26d/python-pendulum/pendulum/issues/646 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/95f69e4a53dede2ed83d6d9a1ea5fa86d0f5efbdafceaea5419e4c5b8d15c26d/python-pendulum/pendulum/issues/646 |
| og:image:alt | I am on the latest Pendulum version. I have searched the issues of this repo and believe that this is not a duplicate. OS version and name: 4.19.128-microsoft-standard Linux Pendulum version: 2.1.2... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | taosharma |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2d58451b4bcb73c33c67bfb6b28fb75fe6d5e279daf9b560fa4fd832f3d8c9a6 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-pendulum/pendulum git https://github.com/python-pendulum/pendulum.git |
| octolytics-dimension-user_id | 191041900 |
| octolytics-dimension-user_login | python-pendulum |
| octolytics-dimension-repository_id | 62095504 |
| octolytics-dimension-repository_nwo | python-pendulum/pendulum |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 62095504 |
| octolytics-dimension-repository_network_root_nwo | python-pendulum/pendulum |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 03e114520787ad27289207f153520ef97461127c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width