diff options
author | Guido van Rossum <guido@python.org> | 2003-02-19 01:19:28 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2003-02-19 01:19:28 (GMT) |
commit | e690883ccf8081e5baab0e9d71f596f26245b569 (patch) | |
tree | 57c21839dbb39b03056f9d19c9c054fbb060900f /Lib/copy_reg.py | |
parent | a43fd0c8996eec2bdd0ec59edc252cb4f4ff4436 (diff) | |
download | cpython-e690883ccf8081e5baab0e9d71f596f26245b569.zip cpython-e690883ccf8081e5baab0e9d71f596f26245b569.tar.gz cpython-e690883ccf8081e5baab0e9d71f596f26245b569.tar.bz2 |
Use __reduce_ex__ in copy.py. The test_*copy_cant() tests are simpler again.
Diffstat (limited to 'Lib/copy_reg.py')
-rw-r--r-- | Lib/copy_reg.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/copy_reg.py b/Lib/copy_reg.py index fa4ce72..fcef409 100644 --- a/Lib/copy_reg.py +++ b/Lib/copy_reg.py @@ -113,9 +113,14 @@ def _better_reduce(obj): def _reduce_ex(obj, proto=0): obj_reduce = getattr(obj, "__reduce__", None) - if obj_reduce and obj.__class__.__reduce__ is not object.__reduce__: - return obj_reduce() - elif proto < 2: + # XXX This fails in test_copy.py line 61 + if obj_reduce: + try: + if obj.__class__.__reduce__ is not object.__reduce__: + return obj_reduce() + except AttributeError: + pass + if proto < 2: return _reduce(obj) else: return _better_reduce(obj) |