New submission from sajicek <saji...@gmail.com>:
Hello first of all, I couldn't find any issue related to this, so sorry if it has been solved before. There seems to be an issue with IMAPLIB in all versions I've checked, when using the Time2Internaldate function with time.struct_time created by datetime.timetuple() extracted from an EmailMessage object (using the email.utils.parsedate_to_datetime function), and even when created with datetime.now() the function crashes the app with "TypeError: unsupported type for timedelta seconds component: NoneType" on line 1530 in current master on GH. (delta = timedelta(seconds=gmtoff)) Crash happens because the "date_time.tm_gmtoff" from which the gmtoff variable is constructed, seems to default to None in all instances of time.struct_time object created by datetime.timetuple(), which still passes the try, except clausule on 1520, because it's not an AttributeError. The time.localtime() metioned in the docs asigns the correct value into tm_gmtoff, but the datetime.timetuple() does not. Possible solutions I've found: 1) inside Time2Internaldate: surround the delta with try and except - in except make the delta = 0 2) inside Time2Internaldate: check the gmtoff for None and if yes, then change it to 0 3) change the default of tm_gmtoff in timetuple from None to 0 (or to a current timezone offset) or just say in the docs, that time.struct_time created this way (using the datetime.timetuple()) is unsupported PS: when writing this issue, I've started thinking this might be a datetime lib issue too ---------- components: Library (Lib) messages: 378409 nosy: sajicek priority: normal severity: normal status: open title: imaplib Time2Internaldate crashing with time.struct_time supplied from datetime.timetuple() type: behavior versions: Python 3.10, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue41999> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com