File: python3.4_compat.patch

package info (click to toggle)
python-mock 1.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,032 kB
  • ctags: 1,296
  • sloc: python: 5,283; makefile: 49
file content (35 lines) | stat: -rw-r--r-- 1,106 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Description: With Python 3.4, some builtins are now introspectable but
  don't have the full compliment of attributes.  Ignore
  AttributeErrors when accessing such attributes.
Author: Barry Warsaw <barry@debian.org>
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=739890
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/python-mock/+bug/1283742
Forwarded: no

--- a/mock.py
+++ b/mock.py
@@ -218,12 +218,21 @@
     funcopy.__name__ = func.__name__
     funcopy.__doc__ = func.__doc__
     #funcopy.__dict__.update(func.__dict__)
-    funcopy.__module__ = func.__module__
+    try:
+        funcopy.__module__ = func.__module__
+    except AttributeError:
+        pass
     if not inPy3k:
         funcopy.func_defaults = func.func_defaults
         return
-    funcopy.__defaults__ = func.__defaults__
-    funcopy.__kwdefaults__ = func.__kwdefaults__
+    try:
+        funcopy.__defaults__ = func.__defaults__
+    except AttributeError:
+        pass
+    try:
+        funcopy.__kwdefaults__ = func.__kwdefaults__
+    except AttributeError:
+        pass
 
 
 def _callable(obj):