diff options
author | Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de> | 2012-04-09 11:38:35 +0200 |
---|---|---|
committer | Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de> | 2012-04-09 11:38:35 +0200 |
commit | 48e9ff716b956e20641b87f93de299b7343c10ce (patch) | |
tree | e6717a3902501a217d77ac8fe00e452183e1f528 /py | |
parent | testrunner: also generate junitxml for each test driver instance (diff) | |
download | pypy-48e9ff716b956e20641b87f93de299b7343c10ce.tar.gz pypy-48e9ff716b956e20641b87f93de299b7343c10ce.tar.bz2 pypy-48e9ff716b956e20641b87f93de299b7343c10ce.zip |
upgrade py and _pytest to current tip
Diffstat (limited to 'py')
-rw-r--r-- | py/_builtin.py | 7 | ||||
-rw-r--r-- | py/_error.py | 1 | ||||
-rw-r--r-- | py/_io/capture.py | 4 | ||||
-rw-r--r-- | py/_path/common.py | 5 | ||||
-rw-r--r-- | py/_xmlgen.py | 14 |
5 files changed, 22 insertions, 9 deletions
diff --git a/py/_builtin.py b/py/_builtin.py index 6a057bbc2f..67971f0afc 100644 --- a/py/_builtin.py +++ b/py/_builtin.py @@ -113,9 +113,12 @@ if sys.version_info >= (3, 0): # some backward compatibility helpers _basestring = str - def _totext(obj, encoding=None): + def _totext(obj, encoding=None, errors=None): if isinstance(obj, bytes): - obj = obj.decode(encoding) + if errors is None: + obj = obj.decode(encoding) + else: + obj = obj.decode(encoding, errors) elif not isinstance(obj, str): obj = str(obj) return obj diff --git a/py/_error.py b/py/_error.py index a9085106b8..f70b671c22 100644 --- a/py/_error.py +++ b/py/_error.py @@ -23,6 +23,7 @@ _winerrnomap = { 2: errno.ENOENT, 3: errno.ENOENT, 17: errno.EEXIST, + 13: errno.EBUSY, # empty cd drive, but ENOMEDIUM seems unavailiable 22: errno.ENOTDIR, 267: errno.ENOTDIR, 5: errno.EACCES, # anything better? diff --git a/py/_io/capture.py b/py/_io/capture.py index 59bdf0b2e2..e558b80034 100644 --- a/py/_io/capture.py +++ b/py/_io/capture.py @@ -12,7 +12,7 @@ if sys.version_info < (3,0): class TextIO(StringIO): def write(self, data): if not isinstance(data, unicode): - data = unicode(data, getattr(self, '_encoding', 'UTF-8')) + data = unicode(data, getattr(self, '_encoding', 'UTF-8'), 'replace') StringIO.write(self, data) else: TextIO = StringIO @@ -260,7 +260,7 @@ class StdCaptureFD(Capture): res = f.read() enc = getattr(f, 'encoding', None) if enc: - res = py.builtin._totext(res, enc) + res = py.builtin._totext(res, enc, 'replace') f.truncate(0) f.seek(0) l.append(res) diff --git a/py/_path/common.py b/py/_path/common.py index 527b4c1e1f..642e3ad0c8 100644 --- a/py/_path/common.py +++ b/py/_path/common.py @@ -64,7 +64,10 @@ class Checkers: else: if bool(value) ^ bool(meth()) ^ invert: return False - except (py.error.ENOENT, py.error.ENOTDIR): + except (py.error.ENOENT, py.error.ENOTDIR, py.error.EBUSY): + # EBUSY feels not entirely correct, + # but its kind of necessary since ENOMEDIUM + # is not accessible in python for name in self._depend_on_existence: if name in kw: if kw.get(name): diff --git a/py/_xmlgen.py b/py/_xmlgen.py index 72897a5a28..07f6b76599 100644 --- a/py/_xmlgen.py +++ b/py/_xmlgen.py @@ -52,7 +52,7 @@ class Tag(list): def unicode(self, indent=2): l = [] SimpleUnicodeVisitor(l.append, indent).visit(self) - return "".join(l) + return u("").join(l) def __repr__(self): name = self.__class__.__name__ @@ -122,11 +122,13 @@ class SimpleUnicodeVisitor(object): if visitmethod is not None: break else: - visitmethod = self.object + visitmethod = self.__object self.cache[cls] = visitmethod visitmethod(node) - def object(self, obj): + # the default fallback handler is marked private + # to avoid clashes with the tag name object + def __object(self, obj): #self.write(obj) self.write(escape(unicode(obj))) @@ -182,7 +184,11 @@ class SimpleUnicodeVisitor(object): value = getattr(attrs, name) if name.endswith('_'): name = name[:-1] - return ' %s="%s"' % (name, escape(unicode(value))) + if isinstance(value, raw): + insert = value.uniobj + else: + insert = escape(unicode(value)) + return ' %s="%s"' % (name, insert) def getstyle(self, tag): """ return attribute list suitable for styling. """ |