"'NoneType' is not callable" error for datetime after closing Jep. [Jep 3.7, Python 3.6, Fedora 24]

232 views
Skip to first unread message

Daniel Barker

unread,
Oct 25, 2017, 5:09:51 AM10/25/17
to Jep Project
Hi, 

I'm having trouble closing and then opening new Jep interpreters. Please see the following code

        JepConfig jepConfig = new JepConfig();
        jepConfig.setInteractive(false);

        final boolean succeed = false;

        Jep jep1 = new Jep(jepConfig);
        jep1.eval("from datetime import datetime");
        if (succeed)
            jep1.eval("print(datetime.strftime(datetime.now(), '%Y-%m-%d'))");
        else
            jep1.eval("print(datetime.strptime('2017-10-01', '%Y-%m-%d').date())");
        jep1.close();

        Jep jep2 = new Jep(jepConfig);
        jep2.eval("from datetime import datetime");
        if (succeed)
            jep2.eval("print(datetime.strftime(datetime.now(), '%Y-%m-%d'))");
        else
            jep2.eval("print(datetime.strptime('2017-10-01', '%Y-%m-%d').date())");
        jep2.close();

It should be quite obvious what it does; the branch with `succeed=true` runs fine and outputs twice the current date, whereas the branch with `succeed=false` throws the following error

2017-10-01
Exception in thread "main" jep.JepException: <class 'TypeError'>: attribute of type 'NoneType' is not callable
at <string>.<module>(<string>:1)
at jep.Jep.eval(Native Method)
at jep.Jep.eval(Jep.java:609)
at jep.test.TestCloseJep.main(TestCloseJep.java:28)

This feels like a bug with Jep since I would expect the instances `jep1` and `jep2` to have no bearing on each other since I'm not using any shared modules. Is this correct or am I just doing something wrong? If it is a bug, how can I work around this until it's fixed?

Thanks,
Dan 

Ben Steffensmeier

unread,
Oct 25, 2017, 11:27:24 AM10/25/17
to Jep Project
Hi Dan,

This is actually a known bug in python when using embedded interpreters, see python issue 27400. I have been able to work around this bug by adding _strptime as a shared module in the jep configuration.

Ben

Daniel Barker

unread,
Oct 25, 2017, 1:32:21 PM10/25/17
to Jep Project
Great, that worked. Thanks very much.
Reply all
Reply to author
Forward
0 new messages