insights-core icon indicating copy to clipboard operation
insights-core copied to clipboard

Python 2.7 and 2.6 test fails on second pass

Open bfahr opened this issue 3 years ago • 0 comments

When running python 2.6 and 2.7 tests, the first pass is successful. If you run the tests a second time then an error occurs:

>               newchars, decodedbytes = self.decode(data, self.errors)
E               LookupError: unknown error handler name 'surrogateescape'

If all *.pyc files are removed before running the tests a second time then no error occurs. The full error output:

insights/tests/test_spec_serialization.py:31: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
insights/core/spec_factory.py:121: in content
    self._content = self.load()
insights/core/spec_factory.py:254: in load
    return [l.rstrip("\n") for l in f]
../venv27/lib64/python2.7/codecs.py:684: in next
    return self.reader.next()
../venv27/lib64/python2.7/codecs.py:615: in next
    line = self.readline()
../venv27/lib64/python2.7/codecs.py:530: in readline
    data = self.read(readsize, firstline=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <closed file u'/tmp/tmpjhEdeO/data/test_spec_serialization.pyc', mode 'rb' at 0x7f9e242f1930>, size = 72, chars = -1, firstline = True

    def read(self, size=-1, chars=-1, firstline=False):
    
        """ Decodes data from the stream self.stream and returns the
                resulting object.
    
                chars indicates the number of characters to read from the
                stream. read() will never return more than chars
                characters, but it might return less, if there are not enough
                characters available.
    
                size indicates the approximate maximum number of bytes to
                read from the stream for decoding purposes. The decoder
                can modify this setting as appropriate. The default value
                -1 indicates to read and decode as much as possible.  size
                is intended to prevent having to decode huge files in one
                step.
    
                If firstline is true, and a UnicodeDecodeError happens
                after the first line terminator in the input only the first line
                will be returned, the rest of the input will be kept until the
                next call to read().
    
                The method should use a greedy read strategy meaning that
                it should read as much data as is allowed within the
                definition of the encoding and the given size, e.g.  if
                optional encoding endings or state markers are available
                on the stream, these should be read too.
            """
        # If we have lines cached, first merge them back into characters
        if self.linebuffer:
            self.charbuffer = "".join(self.linebuffer)
            self.linebuffer = None
    
        # read until we get the required number of characters (if available)
        while True:
            # can the request can be satisfied from the character buffer?
            if chars < 0:
                if size < 0:
                    if self.charbuffer:
                        break
                elif len(self.charbuffer) >= size:
                    break
            else:
                if len(self.charbuffer) >= chars:
                    break
            # we need more data
            if size < 0:
                newdata = self.stream.read()
            else:
                newdata = self.stream.read(size)
            # decode bytes (those remaining from the last call included)
            data = self.bytebuffer + newdata
            try:
>               newchars, decodedbytes = self.decode(data, self.errors)
E               LookupError: unknown error handler name 'surrogateescape'

../venv27/lib64/python2.7/codecs.py:477: LookupError

bfahr avatar Jul 15 '21 18:07 bfahr