[Reproducible-commits] [debbindiff] 01/02: Better stacktraces with functools.wraps

Jérémy Bobbio lunar at moszumanska.debian.org
Thu Jul 30 09:12:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch master
in repository debbindiff.

commit edf6f8b98169bccec8f6d4a743127998fbb88ab0
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Wed Jul 29 13:12:41 2015 +0000

    Better stacktraces with functools.wraps
---
 debbindiff/__init__.py           | 3 +++
 debbindiff/comparators/binary.py | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/debbindiff/__init__.py b/debbindiff/__init__.py
index d25b195..5949954 100644
--- a/debbindiff/__init__.py
+++ b/debbindiff/__init__.py
@@ -17,6 +17,7 @@
 # You should have received a copy of the GNU General Public License
 # along with debbindiff.  If not, see <http://www.gnu.org/licenses/>.
 
+from functools import wraps
 import logging
 from distutils.spawn import find_executable
 
@@ -81,9 +82,11 @@ def tool_required(command):
     tool_required.all.add(command)
     def wrapper(original_function):
         if find_executable(command):
+            @wraps(original_function)
             def tool_check(*args, **kwargs):
                 return original_function(*args, **kwargs)
         else:
+            @wraps(original_function)
             def tool_check(*args, **kwargs):
                 raise RequiredToolNotFound(command)
         return tool_check
diff --git a/debbindiff/comparators/binary.py b/debbindiff/comparators/binary.py
index e28fac8..ba403ef 100644
--- a/debbindiff/comparators/binary.py
+++ b/debbindiff/comparators/binary.py
@@ -20,6 +20,7 @@
 from abc import ABCMeta, abstractproperty, abstractmethod
 from binascii import hexlify
 from contextlib import contextmanager
+from functools import wraps
 import os
 import os.path
 import re
@@ -67,6 +68,7 @@ SMALL_FILE_THRESHOLD = 65536 # 64 kiB
 # decorator for functions which needs to access the file content
 # (and so requires a path to be set)
 def needs_content(original_method):
+    @wraps(original_method)
     def wrapper(self, other, *args, **kwargs):
         with self.get_content(), other.get_content():
             return original_method(self, other, *args, **kwargs)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/debbindiff.git



More information about the Reproducible-commits mailing list