[Zope3-dev] zope3 doesn't like the python datetime module?

Tim Peters tim at zope.com
Sun Sep 21 18:13:17 EDT 2003


[Anthony Baxter]
> When trying to use zope.interface outside Zope, without the
> src/datetime package, tests fail with:
>
>   File "test.py", line 487, in get_suite
>     mod = package_import(modname)
>   File "test.py", line 479, in package_import
>     mod = __import__(modname)
>   File "zope/interface/common/tests/test_idatetime.py", line 22, in ?
>     from zope.interface.common.idatetime import ITimeDelta,
>   ITimeDeltaClass File "zope/interface/common/idatetime.py", line
>     574, in ? directlyProvides(timedelta, ITimeDeltaClass)
>   File "zope/interface/declarations.py", line 969, in directlyProvides
>     object.__provides__ = ProvidesSpecification(*interfaces)
> TypeError: can't set attributes of built-in/extension type
> 'datetime.timedelta'
>
> This makes me sad.  Can anyone suggest a fix?  It looks like the
> implemented-in-C datetime code breaks when fed into the interface
> code.

Actually, it looks more like this part of the Zope interface code breaks
when it's fed the C datetime types, yes?

> Assuming that a) Zope3 doesn't want to maintain it's own datetime
> package for ever,

It does not.

> and/or b) Zope3 wants to use the C code version at some point for
> speed,

More so for memory frugality, I think.  The C datetime types have small
memory requirements compared to the Python implementation.

> this is a problem.

Yup.  Offhand I don't know what causes the problem.  I would *like* to see
Zope Corp require Python 2.3 for Zope3.  That would force the issue in such
a way that it must be solved.  So long as we dilute our efforts wrestling
with artificial Python 2.2 compatibility requirements too, I doubt that this
one is going to make it to the top of my todo list (it can rise to crisis
status so long as "use the Python implementation" remains a blessed
alternative).

BTW, it's generally true that you can't set attributes on an object of a
builtin type (the datetime types aren't unique that way), so if you want to
pursue this now I'd look for code that manages to use, e.g., dicts with
interfaces now.




More information about the Zope3-dev mailing list