Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError traceback when trying to open a particular recurring task: 'Date' object has no attribute 'strftime' #870

Closed
nekohayo opened this issue Mar 21, 2022 · 7 comments · Fixed by #943

Comments

@nekohayo
Copy link
Member

I don't know if this would happen with the git version and the new core, but in case this is useful, here's a traceback I encountered on 0.6 today when trying to open/edit my recurring "treat the leather clothes" task:

Traceback (most recent call last):
  File "/app/lib/python3.9/site-packages/GTG/gtk/browser/main_window.py", line 1060, in on_edit_active_task
    self.app.open_task(tid)
  File "/app/lib/python3.9/site-packages/GTG/gtk/application.py", line 553, in open_task
    editor = TaskEditor(requester=self.req, app=self, task=task,
  File "/app/lib/python3.9/site-packages/GTG/gtk/editor/editor.py", line 98, in __init__
    self.recurring_menu = RecurringMenu(self.req, task.tid, self.builder)
  File "/app/lib/python3.9/site-packages/GTG/gtk/editor/recurring_menu.py", line 45, in __init__
    self.update_header()
  File "/app/lib/python3.9/site-packages/GTG/gtk/editor/recurring_menu.py", line 121, in update_header
    month_day=self.task.get_recurring_updated_date().strftime('%d')))
AttributeError: 'Date' object has no attribute 'strftime'

The offending task looks like this in my gtg_data.xml file:

    <task id="ec4435e2-63de-4481-8d6a-bbea84e46562" status="Dismiss" uuid="ec4435e2-63de-4481-8d6a-bbea84e46562" recurring="True">
      <tags>
        <tag>a0261164-c489-4032-9942-7c5cecb6e3dd</tag>
      </tags>
      <title>conditionner les vêtements de cuir</title>
      <dates>
        <added>2022-01-15T14:24:39.347643</added>
        <modified>2022-03-03 09:41:19.407247</modified>
        <done>2022-03-03</done>
        <due>2022-02-21</due>
        <start>2022-03-03</start>
      </dates>
      <recurring enabled="true">
        <term>month</term>
        <updated_date>2022-01-15T14:24:39.359351</updated_date>
      </recurring>
      <subtasks/>
      <content><![CDATA[1x/quarter si inutilisés, monthly si légèrement utilisés; simply use cream sur toutes les paires de souliers! cf notes @apparte]]></content>
    </task>
@macrophone
Copy link

Same error trying to open a recurring task :

Context: Global generic exception

Traceback (most recent call last):
  File "/app/lib/python3.9/site-packages/GTG/gtk/browser/main_window.py", line 1060, in on_edit_active_task
    self.app.open_task(tid)
  File "/app/lib/python3.9/site-packages/GTG/gtk/application.py", line 553, in open_task
    editor = TaskEditor(requester=self.req, app=self, task=task,
  File "/app/lib/python3.9/site-packages/GTG/gtk/editor/editor.py", line 98, in __init__
    self.recurring_menu = RecurringMenu(self.req, task.tid, self.builder)
  File "/app/lib/python3.9/site-packages/GTG/gtk/editor/recurring_menu.py", line 45, in __init__
    self.update_header()
  File "/app/lib/python3.9/site-packages/GTG/gtk/editor/recurring_menu.py", line 121, in update_header
    month_day=self.task.get_recurring_updated_date().strftime('%d')))
AttributeError: 'Date' object has no attribute 'strftime'

Software versions:

  • Getting Things GNOME! v0.6
  • CPython 3.9.9 (main, Nov 10 2011, 15:00:00) [GCC 11.2.0]
  • GTK 3.24.33, GLib 2.70.5
  • PyGLib 3.42.0, PyGObject 3.42.0
  • Linux-5.10.0-13-rt-amd64-x86_64-with-glibc2.33

@ernestum
Copy link

I have the issue too:

Context: Global generic exception

Traceback (most recent call last):
  File "/app/lib/python3.9/site-packages/GTG/gtk/browser/main_window.py", line 1060, in on_edit_active_task
    self.app.open_task(tid)
  File "/app/lib/python3.9/site-packages/GTG/gtk/application.py", line 553, in open_task
    editor = TaskEditor(requester=self.req, app=self, task=task,
  File "/app/lib/python3.9/site-packages/GTG/gtk/editor/editor.py", line 98, in __init__
    self.recurring_menu = RecurringMenu(self.req, task.tid, self.builder)
  File "/app/lib/python3.9/site-packages/GTG/gtk/editor/recurring_menu.py", line 45, in __init__
    self.update_header()
  File "/app/lib/python3.9/site-packages/GTG/gtk/editor/recurring_menu.py", line 121, in update_header
    month_day=self.task.get_recurring_updated_date().strftime('%d')))
AttributeError: 'Date' object has no attribute 'strftime'

Software versions:

  • Getting Things GNOME! v0.6
  • CPython 3.9.9 (main, Nov 10 2011, 15:00:00) [GCC 11.3.0]
  • GTK 3.24.34, GLib 2.70.5
  • PyGLib 3.42.2, PyGObject 3.42.2
  • Linux-5.4.0-122-generic-x86_64-with-glibc2.33

@APCBoston
Copy link
Contributor

APCBoston commented Sep 19, 2022

Took a look at this today. It looks like the code is trying to call strftime() from datetime.date, which is not implemented in GTG.core.Date. One trivial fix that I'd be happy to submit if folks think it's worthwhile would be to simply implement strftime() in Date. That would have the beneficial side effect of improving future code's ability to interact with Date in ways that its authors expect to be able to interact with datetime.date.

@macrophone
Copy link

@APCBoston did you submitted a PR ?

@APCBoston
Copy link
Contributor

@APCBoston did you submitted a PR ?

I haven't done anything with this since my 9/19 message since it got no response, and I wasn't sure in light of the ongoing "megaport" whether it made sense to fix this in the current main branch. That said, on a quick glance it looks like the new code has the same issue, so if somebody wants to say "yes that would be a good idea / would make my life better," I'd be happy to do it.

@macrophone
Copy link

macrophone commented Nov 5, 2022 via email

@macrophone
Copy link

Thanks for this @APCBoston !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants