[issue14350] Strange Exception from copying an iterable

Jakob Bowyer report at bugs.python.org
Sat Mar 17 20:04:26 CET 2012


New submission from Jakob Bowyer <jkbbwr at gmail.com>:

Running:
Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)]
Code:
import copy
copy.copy(iter([1,2,3]))
Exception:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
T:\languages\Python27\Scripts\<ipython-input-2-4b0069a09ded> in <module>()
----> 1 copy.copy(iter([1,2,3]))

T:\languages\Python27\lib\copy.pyc in copy(x)
     94                 raise Error("un(shallow)copyable object of type %s" % cl
s)
     95
---> 96     return _reconstruct(x, rv, 0)
     97
     98

T:\languages\Python27\lib\copy.pyc in _reconstruct(x, info, deep, memo)
    327     if deep:
    328         args = deepcopy(args, memo)
--> 329     y = callable(*args)
    330     memo[id(x)] = y
    331

T:\languages\Python27\lib\copy_reg.pyc in __newobj__(cls, *args)
     91
     92 def __newobj__(cls, *args):
---> 93     return cls.__new__(cls, *args)
     94
     95 def _slotnames(cls):

TypeError: object.__new__(listiterator) is not safe, use listiterator.__new__()

Either this is a bug or not a clear error message in the exception

----------
components: None
messages: 156189
nosy: Jakob.Bowyer
priority: normal
severity: normal
status: open
title: Strange Exception from copying an iterable
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14350>
_______________________________________


More information about the Python-bugs-list mailing list