[issue18195] error when deep copying module is confusing

2017-02-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This issue looks as enhancement rather than bug fix. Since it is fixed in 3.6 
I'm closing it.

--
resolution:  -> out of date
stage:  -> resolved
status: open -> closed
type:  -> enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18195] error when deep copying module is confusing

2016-02-29 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Python 3.6:

Traceback (most recent call last):
  File "", line 1, in 
  File "/home/serhiy/py/cpython/Lib/copy.py", line 97, in copy
rv = reductor(4)
TypeError: can't pickle module objects

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18195] error when deep copying module is confusing

2013-06-11 Thread mrjbq7

New submission from mrjbq7:

If you have a simple module (say foo.py):

$ cat foo.py
bar = 1

You get weird errors when trying to deep copy them (which I did by accident, 
not intentionally trying to deep copy modules):

Python 2.7.2:

 import foo
 import copy
 copy.deepcopy(foo)
Traceback (most recent call last):
  File stdin, line 1, in module
  File 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py,
 line 190, in deepcopy
y = _reconstruct(x, rv, 1, memo)
  File 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py,
 line 334, in _reconstruct
state = deepcopy(state, memo)
  File 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py,
 line 163, in deepcopy
y = copier(x, memo)
  File 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py,
 line 257, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
  File 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py,
 line 163, in deepcopy
y = copier(x, memo)
  File 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py,
 line 257, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
  File 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py,
 line 190, in deepcopy
y = _reconstruct(x, rv, 1, memo)
  File 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py,
 line 329, in _reconstruct
y = callable(*args)
  File 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy_reg.py,
 line 93, in __newobj__
return cls.__new__(cls, *args)
TypeError: object.__new__(NotImplementedType) is not safe, use 
NotImplementedType.__new__()

Python 3.3.2:

 import foo
 import copy
 copy.deepcopy(foo)
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib/python3.3/copy.py, line 174, in deepcopy
y = _reconstruct(x, rv, 1, memo)
  File /usr/lib/python3.3/copy.py, line 301, in _reconstruct
y.__dict__.update(state)
AttributeError: 'NoneType' object has no attribute 'update'

I'm not expecting to be able to deep copy a module, but it would be really 
great if it is not possible for the error message to say something like 
deepcopy doesn't work for modules rather than two different funky tracebacks 
that don't really explain the problem...

Thanks,

--
messages: 190996
nosy: mrjbq7
priority: normal
severity: normal
status: open
title: error when deep copying module is confusing

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18195
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18195] error when deep copying module is confusing

2013-06-11 Thread R. David Murray

R. David Murray added the comment:

Well, we don't generally complicate the code to handle edge cases.  That said, 
it might not be too complicated to add copy protocol methods to the module 
object which just raise a more useful error.

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18195
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com