Deecopy auf globales dict

24/11/2008 - 14:34 von Thomas Bach | Report spam
Guten Tag,

bin hier ueber etwas gestolpert, bei dem ich mir nicht ganz sicher
bin, ob es ein Bug, gewollt, oder, oder, oder
Bin in python doch noch etwas unbeholfen...

bachth@host:~/tests/tests/mvapich> cat test.py

ineed = ['cpi.c', 'fpi.f', 'pi3f90.f90', 'hello++.cc']
compiler = ['pgi', 'gcc', 'sun', 'pathscale']
mvapich = ['mvapich', 'mvapich-0.9.9']
exports = { 'mvapich': mvapich,
'comp': compiler,
'file': ineed,
'blah': 'blablah' }

bachth@host:~/tests/tests/mvapich> python2.6
Python 2.6 (r26:66714, Oct 15 2008, 13:50:01)
[GCC 4.1.2 20070115 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.



import copy
a = {}
b = {}
execfile('./test.py', a, b)
copy.deepcopy(a)






Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/cluster//lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)
File "/usr/local/cluster//lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/local/cluster//lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)
File "/usr/local/cluster//lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/local/cluster//lib/python2.6/copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/usr/local/cluster//lib/python2.6/copy.py", line 323, in _reconstruct
y = callable(*args)
File "/usr/local/cluster//lib/python2.6/copy_reg.py", line 93, in __newobj__
return cls.__new__(cls, *args)
TypeError: object.__new__(NotImplementedType) is not safe, use NotImplementedType.__new__()











Was meint ihr dazu?

Nach review meines Codes bin ich zu dem entschluss gekommen, dass ich
das dict wahrscheinlich gar nicht kopieren muesste.

Gruss,
Thomas Bach
 

Lesen sie die antworten

#1 Diez B. Roggisch
24/11/2008 - 15:07 | Warnen spam
Thomas Bach wrote:

Guten Tag,

bin hier ueber etwas gestolpert, bei dem ich mir nicht ganz sicher
bin, ob es ein Bug, gewollt, oder, oder, oder
Bin in python doch noch etwas unbeholfen...

:~/tests/tests/mvapich> cat test.py

ineed = ['cpi.c', 'fpi.f', 'pi3f90.f90', 'hello++.cc']
compiler = ['pgi', 'gcc', 'sun', 'pathscale']
mvapich = ['mvapich', 'mvapich-0.9.9']
exports = { 'mvapich': mvapich,
'comp': compiler,
'file': ineed,
'blah': 'blablah' }

:~/tests/tests/mvapich> python2.6
Python 2.6 (r26:66714, Oct 15 2008, 13:50:01)
[GCC 4.1.2 20070115 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import copy
a = {}
b = {}
execfile('./test.py', a, b)
copy.deepcopy(a)






Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/cluster//lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)
File "/usr/local/cluster//lib/python2.6/copy.py", line 255, in
_deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/local/cluster//lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)
File "/usr/local/cluster//lib/python2.6/copy.py", line 255, in
_deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/local/cluster//lib/python2.6/copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/usr/local/cluster//lib/python2.6/copy.py", line 323, in
_reconstruct
y = callable(*args)
File "/usr/local/cluster//lib/python2.6/copy_reg.py", line 93, in
__newobj__
return cls.__new__(cls, *args)
TypeError: object.__new__(NotImplementedType) is not safe, use
NotImplementedType.__new__()








Was meint ihr dazu?



Da du das entscheidende verheimlichst - naemlich was in "a" drin ist - nicht
so allzuviel...

Diez

Ähnliche fragen