summaryrefslogtreecommitdiff
path: root/nose
diff options
context:
space:
mode:
authorBuck Golemon <workitharder@gmail.com>2011-04-30 20:30:19 -0700
committerBuck Golemon <workitharder@gmail.com>2011-04-30 20:30:19 -0700
commit3caefdad7c5f6eba672a4683877394bf282d9f54 (patch)
tree05c57e747fd64e12d7a17191a9c7c822c4a735ed /nose
parentf3f3889756e42ffae238cd0b40c0fbb0413e6129 (diff)
downloadnose-3caefdad7c5f6eba672a4683877394bf282d9f54.tar.gz
Make the bytes_ function idempotent.
Previously, bytes_(b'') would throw an exception.
Diffstat (limited to 'nose')
-rw-r--r--nose/pyversion.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/nose/pyversion.py b/nose/pyversion.py
index 105f910..36ddcfd 100644
--- a/nose/pyversion.py
+++ b/nose/pyversion.py
@@ -70,8 +70,8 @@ else:
# definition so that things can do stuff based on its associated class)
class UnboundMethod:
def __init__(self, cls, func):
- # Make sure we have all the same attributes as the original function,
- # so that the AttributeSelector plugin will work correctly...
+ # Make sure we have all the same attributes as the original function,
+ # so that the AttributeSelector plugin will work correctly...
self.__dict__ = func.__dict__.copy()
self._func = func
self.__self__ = UnboundSelf(cls)
@@ -122,6 +122,8 @@ def ismethod(obj):
# Make a pseudo-bytes function that can be called without the encoding arg:
if sys.version_info >= (3, 0):
def bytes_(s, encoding='utf8'):
+ if isinstance(s, bytes):
+ return s
return bytes(s, encoding)
else:
def bytes_(s, encoding=None):