Python copy.Error() Examples
The following are 30
code examples of copy.Error().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
copy
, or try the search function
.

Example #1
Source File: copy.py From jawfish with MIT License | 5 votes |
def copy(x): """Shallow copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ cls = type(x) copier = _copy_dispatch.get(cls) if copier: return copier(x) copier = getattr(cls, "__copy__", None) if copier: return copier(x) reductor = dispatch_table.get(cls) if reductor: rv = reductor(x) else: reductor = getattr(x, "__reduce_ex__", None) if reductor: rv = reductor(2) else: reductor = getattr(x, "__reduce__", None) if reductor: rv = reductor() else: raise Error("un(shallow)copyable object of type %s" % cls) return _reconstruct(x, rv, 0)
Example #2
Source File: copy.py From meddle with MIT License | 5 votes |
def copy(x): """Shallow copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ cls = type(x) copier = _copy_dispatch.get(cls) if copier: return copier(x) copier = getattr(cls, "__copy__", None) if copier: return copier(x) reductor = dispatch_table.get(cls) if reductor: rv = reductor(x) else: reductor = getattr(x, "__reduce_ex__", None) if reductor: rv = reductor(2) else: reductor = getattr(x, "__reduce__", None) if reductor: rv = reductor() else: raise Error("un(shallow)copyable object of type %s" % cls) return _reconstruct(x, rv, 0)
Example #3
Source File: copy.py From ironpython2 with Apache License 2.0 | 5 votes |
def copy(x): """Shallow copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ cls = type(x) copier = _copy_dispatch.get(cls) if copier: return copier(x) copier = getattr(cls, "__copy__", None) if copier: return copier(x) reductor = dispatch_table.get(cls) if reductor: rv = reductor(x) else: reductor = getattr(x, "__reduce_ex__", None) if reductor: rv = reductor(2) else: reductor = getattr(x, "__reduce__", None) if reductor: rv = reductor() else: raise Error("un(shallow)copyable object of type %s" % cls) return _reconstruct(x, rv, 0)
Example #4
Source File: test_coercion.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_infix_binops(self): for ia, a in enumerate(candidates): for ib, b in enumerate(candidates): results = infix_results[(ia, ib)] for op, res, ires in zip(infix_binops, results[0], results[1]): if res is TE: self.assertRaises(TypeError, eval, 'a %s b' % op, {'a': a, 'b': b}) else: self.assertEqual(format_result(res), format_result(eval('a %s b' % op)), '%s %s %s == %s failed' % (a, op, b, res)) try: z = copy.copy(a) except copy.Error: z = a # assume it has no inplace ops if ires is TE: try: exec 'z %s= b' % op except TypeError: pass else: self.fail("TypeError not raised") else: exec('z %s= b' % op) self.assertEqual(ires, z)
Example #5
Source File: test_copy.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_exceptions(self): self.assertTrue(copy.Error is copy.error) self.assertTrue(issubclass(copy.Error, Exception)) # The copy() method
Example #6
Source File: copy.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
def copy(x): """Shallow copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ cls = type(x) copier = _copy_dispatch.get(cls) if copier: return copier(x) try: issc = issubclass(cls, type) except TypeError: # cls is not a class issc = False if issc: # treat it as a regular class: return _copy_immutable(x) copier = getattr(cls, "__copy__", None) if copier: return copier(x) reductor = dispatch_table.get(cls) if reductor: rv = reductor(x) else: reductor = getattr(x, "__reduce_ex__", None) if reductor: rv = reductor(4) else: reductor = getattr(x, "__reduce__", None) if reductor: rv = reductor() else: raise Error("un(shallow)copyable object of type %s" % cls) return _reconstruct(x, rv, 0)
Example #7
Source File: copy.py From BinderFilter with MIT License | 5 votes |
def copy(x): """Shallow copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ cls = type(x) copier = _copy_dispatch.get(cls) if copier: return copier(x) copier = getattr(cls, "__copy__", None) if copier: return copier(x) reductor = dispatch_table.get(cls) if reductor: rv = reductor(x) else: reductor = getattr(x, "__reduce_ex__", None) if reductor: rv = reductor(2) else: reductor = getattr(x, "__reduce__", None) if reductor: rv = reductor() else: raise Error("un(shallow)copyable object of type %s" % cls) return _reconstruct(x, rv, 0)
Example #8
Source File: test_coercion.py From BinderFilter with MIT License | 5 votes |
def test_infix_binops(self): for ia, a in enumerate(candidates): for ib, b in enumerate(candidates): results = infix_results[(ia, ib)] for op, res, ires in zip(infix_binops, results[0], results[1]): if res is TE: self.assertRaises(TypeError, eval, 'a %s b' % op, {'a': a, 'b': b}) else: self.assertEqual(format_result(res), format_result(eval('a %s b' % op)), '%s %s %s == %s failed' % (a, op, b, res)) try: z = copy.copy(a) except copy.Error: z = a # assume it has no inplace ops if ires is TE: try: exec 'z %s= b' % op except TypeError: pass else: self.fail("TypeError not raised") else: exec('z %s= b' % op) self.assertEqual(ires, z)
Example #9
Source File: test_copy.py From BinderFilter with MIT License | 5 votes |
def test_exceptions(self): self.assertTrue(copy.Error is copy.error) self.assertTrue(issubclass(copy.Error, Exception)) # The copy() method
Example #10
Source File: test_copy.py From BinderFilter with MIT License | 5 votes |
def test_copy_cant(self): class C(object): def __getattribute__(self, name): if name.startswith("__reduce"): raise AttributeError, name return object.__getattribute__(self, name) x = C() self.assertRaises(copy.Error, copy.copy, x) # Type-specific _copy_xxx() methods
Example #11
Source File: copy.py From Computable with MIT License | 5 votes |
def copy(x): """Shallow copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ cls = type(x) copier = _copy_dispatch.get(cls) if copier: return copier(x) copier = getattr(cls, "__copy__", None) if copier: return copier(x) reductor = dispatch_table.get(cls) if reductor: rv = reductor(x) else: reductor = getattr(x, "__reduce_ex__", None) if reductor: rv = reductor(2) else: reductor = getattr(x, "__reduce__", None) if reductor: rv = reductor() else: raise Error("un(shallow)copyable object of type %s" % cls) return _reconstruct(x, rv, 0)
Example #12
Source File: copy.py From oss-ftp with MIT License | 5 votes |
def copy(x): """Shallow copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ cls = type(x) copier = _copy_dispatch.get(cls) if copier: return copier(x) copier = getattr(cls, "__copy__", None) if copier: return copier(x) reductor = dispatch_table.get(cls) if reductor: rv = reductor(x) else: reductor = getattr(x, "__reduce_ex__", None) if reductor: rv = reductor(2) else: reductor = getattr(x, "__reduce__", None) if reductor: rv = reductor() else: raise Error("un(shallow)copyable object of type %s" % cls) return _reconstruct(x, rv, 0)
Example #13
Source File: test_coercion.py From oss-ftp with MIT License | 5 votes |
def test_infix_binops(self): for ia, a in enumerate(candidates): for ib, b in enumerate(candidates): results = infix_results[(ia, ib)] for op, res, ires in zip(infix_binops, results[0], results[1]): if res is TE: self.assertRaises(TypeError, eval, 'a %s b' % op, {'a': a, 'b': b}) else: self.assertEqual(format_result(res), format_result(eval('a %s b' % op)), '%s %s %s == %s failed' % (a, op, b, res)) try: z = copy.copy(a) except copy.Error: z = a # assume it has no inplace ops if ires is TE: try: exec 'z %s= b' % op except TypeError: pass else: self.fail("TypeError not raised") else: exec('z %s= b' % op) self.assertEqual(ires, z)
Example #14
Source File: test_copy.py From oss-ftp with MIT License | 5 votes |
def test_exceptions(self): self.assertTrue(copy.Error is copy.error) self.assertTrue(issubclass(copy.Error, Exception)) # The copy() method
Example #15
Source File: test_copy.py From oss-ftp with MIT License | 5 votes |
def test_copy_cant(self): class C(object): def __getattribute__(self, name): if name.startswith("__reduce"): raise AttributeError, name return object.__getattribute__(self, name) x = C() self.assertRaises(copy.Error, copy.copy, x) # Type-specific _copy_xxx() methods
Example #16
Source File: copy.py From pmatic with GNU General Public License v2.0 | 5 votes |
def copy(x): """Shallow copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ cls = type(x) copier = _copy_dispatch.get(cls) if copier: return copier(x) copier = getattr(cls, "__copy__", None) if copier: return copier(x) reductor = dispatch_table.get(cls) if reductor: rv = reductor(x) else: reductor = getattr(x, "__reduce_ex__", None) if reductor: rv = reductor(2) else: reductor = getattr(x, "__reduce__", None) if reductor: rv = reductor() else: raise Error("un(shallow)copyable object of type %s" % cls) return _reconstruct(x, rv, 0)
Example #17
Source File: copy.py From Coursera-Stanford-Divide-and-Conquer-Sorting-and-Searching-and-Randomized-Algorithms with MIT License | 5 votes |
def copy(x): """Shallow copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ cls = type(x) copier = _copy_dispatch.get(cls) if copier: return copier(x) copier = getattr(cls, "__copy__", None) if copier: return copier(x) reductor = dispatch_table.get(cls) if reductor: rv = reductor(x) else: reductor = getattr(x, "__reduce_ex__", None) if reductor: rv = reductor(2) else: reductor = getattr(x, "__reduce__", None) if reductor: rv = reductor() else: raise Error("un(shallow)copyable object of type %s" % cls) return _reconstruct(x, rv, 0)
Example #18
Source File: copy.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def copy(x): """Shallow copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ cls = type(x) copier = _copy_dispatch.get(cls) if copier: return copier(x) try: issc = issubclass(cls, type) except TypeError: # cls is not a class issc = False if issc: # treat it as a regular class: return _copy_immutable(x) copier = getattr(cls, "__copy__", None) if copier: return copier(x) reductor = dispatch_table.get(cls) if reductor: rv = reductor(x) else: reductor = getattr(x, "__reduce_ex__", None) if reductor: rv = reductor(4) else: reductor = getattr(x, "__reduce__", None) if reductor: rv = reductor() else: raise Error("un(shallow)copyable object of type %s" % cls) if isinstance(rv, str): return x return _reconstruct(x, None, *rv)
Example #19
Source File: copy.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def copy(x): """Shallow copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ cls = type(x) copier = _copy_dispatch.get(cls) if copier: return copier(x) try: issc = issubclass(cls, type) except TypeError: # cls is not a class issc = False if issc: # treat it as a regular class: return _copy_immutable(x) copier = getattr(cls, "__copy__", None) if copier: return copier(x) reductor = dispatch_table.get(cls) if reductor: rv = reductor(x) else: reductor = getattr(x, "__reduce_ex__", None) if reductor: rv = reductor(4) else: reductor = getattr(x, "__reduce__", None) if reductor: rv = reductor() else: raise Error("un(shallow)copyable object of type %s" % cls) return _reconstruct(x, rv, 0)
Example #20
Source File: test_copy.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_exceptions(self): self.assertIs(copy.Error, copy.error) self.assertTrue(issubclass(copy.Error, Exception)) # The copy() method
Example #21
Source File: test_copy.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_copy_cant(self): class C(object): def __getattribute__(self, name): if name.startswith("__reduce"): raise AttributeError(name) return object.__getattribute__(self, name) x = C() self.assertRaises(copy.Error, copy.copy, x) # Type-specific _copy_xxx() methods
Example #22
Source File: test_copy.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_deepcopy_cant(self): class C(object): def __getattribute__(self, name): if name.startswith("__reduce"): raise AttributeError(name) return object.__getattribute__(self, name) x = C() self.assertRaises(copy.Error, copy.deepcopy, x) # Type-specific _deepcopy_xxx() methods
Example #23
Source File: copy.py From Imogen with MIT License | 5 votes |
def copy(x): """Shallow copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ cls = type(x) copier = _copy_dispatch.get(cls) if copier: return copier(x) try: issc = issubclass(cls, type) except TypeError: # cls is not a class issc = False if issc: # treat it as a regular class: return _copy_immutable(x) copier = getattr(cls, "__copy__", None) if copier: return copier(x) reductor = dispatch_table.get(cls) if reductor: rv = reductor(x) else: reductor = getattr(x, "__reduce_ex__", None) if reductor: rv = reductor(4) else: reductor = getattr(x, "__reduce__", None) if reductor: rv = reductor() else: raise Error("un(shallow)copyable object of type %s" % cls) if isinstance(rv, str): return x return _reconstruct(x, None, *rv)
Example #24
Source File: copy.py From scylla with Apache License 2.0 | 5 votes |
def copy(x): """Shallow copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ cls = type(x) copier = _copy_dispatch.get(cls) if copier: return copier(x) try: issc = issubclass(cls, type) except TypeError: # cls is not a class issc = False if issc: # treat it as a regular class: return _copy_immutable(x) copier = getattr(cls, "__copy__", None) if copier: return copier(x) reductor = dispatch_table.get(cls) if reductor: rv = reductor(x) else: reductor = getattr(x, "__reduce_ex__", None) if reductor: rv = reductor(4) else: reductor = getattr(x, "__reduce__", None) if reductor: rv = reductor() else: raise Error("un(shallow)copyable object of type %s" % cls) return _reconstruct(x, rv, 0)
Example #25
Source File: copy.py From ironpython3 with Apache License 2.0 | 5 votes |
def copy(x): """Shallow copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ cls = type(x) copier = _copy_dispatch.get(cls) if copier: return copier(x) try: issc = issubclass(cls, type) except TypeError: # cls is not a class issc = False if issc: # treat it as a regular class: return _copy_immutable(x) copier = getattr(cls, "__copy__", None) if copier: return copier(x) reductor = dispatch_table.get(cls) if reductor: rv = reductor(x) else: reductor = getattr(x, "__reduce_ex__", None) if reductor: rv = reductor(2) else: reductor = getattr(x, "__reduce__", None) if reductor: rv = reductor() else: raise Error("un(shallow)copyable object of type %s" % cls) return _reconstruct(x, rv, 0)
Example #26
Source File: test_copy.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_exceptions(self): self.assertIs(copy.Error, copy.error) self.assertTrue(issubclass(copy.Error, Exception)) # The copy() method
Example #27
Source File: test_copy.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_copy_cant(self): class C(object): def __getattribute__(self, name): if name.startswith("__reduce"): raise AttributeError(name) return object.__getattribute__(self, name) x = C() self.assertRaises(copy.Error, copy.copy, x) # Type-specific _copy_xxx() methods
Example #28
Source File: test_copy.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_deepcopy_cant(self): class C(object): def __getattribute__(self, name): if name.startswith("__reduce"): raise AttributeError(name) return object.__getattribute__(self, name) x = C() self.assertRaises(copy.Error, copy.deepcopy, x) # Type-specific _deepcopy_xxx() methods
Example #29
Source File: copy.py From python with Apache License 2.0 | 5 votes |
def copy(x): """Shallow copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ cls = type(x) copier = _copy_dispatch.get(cls) if copier: return copier(x) try: issc = issubclass(cls, type) except TypeError: # cls is not a class issc = False if issc: # treat it as a regular class: return _copy_immutable(x) copier = getattr(cls, "__copy__", None) if copier: return copier(x) reductor = dispatch_table.get(cls) if reductor: rv = reductor(x) else: reductor = getattr(x, "__reduce_ex__", None) if reductor: rv = reductor(4) else: reductor = getattr(x, "__reduce__", None) if reductor: rv = reductor() else: raise Error("un(shallow)copyable object of type %s" % cls) if isinstance(rv, str): return x return _reconstruct(x, None, *rv)
Example #30
Source File: copy.py From python2017 with MIT License | 5 votes |
def copy(x): """Shallow copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ cls = type(x) copier = _copy_dispatch.get(cls) if copier: return copier(x) try: issc = issubclass(cls, type) except TypeError: # cls is not a class issc = False if issc: # treat it as a regular class: return _copy_immutable(x) copier = getattr(cls, "__copy__", None) if copier: return copier(x) reductor = dispatch_table.get(cls) if reductor: rv = reductor(x) else: reductor = getattr(x, "__reduce_ex__", None) if reductor: rv = reductor(4) else: reductor = getattr(x, "__reduce__", None) if reductor: rv = reductor() else: raise Error("un(shallow)copyable object of type %s" % cls) if isinstance(rv, str): return x return _reconstruct(x, None, *rv)