[New-bugs-announce] [issue35741] unittest.skipUnless(time._STRUCT_TM_ITEMS == 11, "needs tm_zone support") doesn't work

jianxu3 report at bugs.python.org
Tue Jan 15 04:32:07 EST 2019


New submission from jianxu3 <sunshone0711 at 163.com>:

Whether or not the HAVE_STRUCT_TM_TM_ZONE is defined, _STRUCT_TM_ITEMS always equal to 11. It is initialized at PyInit_time(void).
PyModule_AddIntConstant(m, "_STRUCT_TM_ITEMS", 11);

If I modify it like this:
#ifdef HAVE_STRUCT_TM_TM_ZONE
PyModule_AddIntConstant(m, "_STRUCT_TM_ITEMS", 11)
#else
PyModule_AddIntConstant(m, "_STRUCT_TM_ITEMS", 9)
#endif

Then test_fields at test_structseq.py will fail.

def test_fields(self):
self.assertEqual(t.n_fields, time._STRUCT_TM_ITEMS)

What I hope is that if HAVE_STRUCT_TM_TM_ZONE is not defined, test_localtime_timezone will be skipped.

----------
components: Tests
messages: 333654
nosy: jianxu3
priority: normal
severity: normal
status: open
title: unittest.skipUnless(time._STRUCT_TM_ITEMS == 11, "needs tm_zone support") doesn't work
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35741>
_______________________________________


More information about the New-bugs-announce mailing list