python-2.6.2 Exception: TypeError: "'NoneType' object is not callable"in ignored

P

Poor Yorick

The following code produces an error (python-2.6.2). Either of the following
eliminates the error:

. assign something besides mod1 (the newly-created module) to d1

. remove the call to shelve.open

Why is there an error produced in the first place? What is the interaction
between d1, mod1, and shelve about? This code runs without error in python-3.1

$ cat test1.py
import test2
newmodule = test2.load()

$ cat test2.py

import imp
import shelve

def load():
text='import test2\n'
text += '''print('hello from test3')\n'''
code = compile(text,'<fake>', 'exec')
mod1 = imp.new_module('newmodule')

newdict = mod1.__dict__
#newdict = {}

exec(code,newdict)
mod1
mode = mod1
d1['unique'] = mod1
#d1['unique'] = ''
return mod1

print('hello from test2')
d1 = {}
cache = shelve.open('persist')

$ python2.6 test1.py
hello from test2
hello from test3
Exception TypeError: "'NoneType' object is not callable" in ignored
Exception TypeError: "'NoneType' object is not callable" in ignored
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top