mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 04:55:51 +01:00
Fix generation of #line directives in Python 2
When using Python 2 (which is done in the Makefile), all #line directives from the test code were generated with the line number 1. This traces back to the change in the method name for generators in Python 2 (next) vs Python 3 (__next__). Override both methods so that the script remains compatible with both Python 2 and Python 3.
This commit is contained in:
parent
7776141a16
commit
667f7f8369
@ -76,17 +76,24 @@ class FileWrapper(io.FileIO):
|
||||
super(FileWrapper, self).__init__(file_name, 'r')
|
||||
self.line_no = 0
|
||||
|
||||
# Override the generator function in a way that works in both Python 2
|
||||
# and Python 3.
|
||||
def __next__(self):
|
||||
"""
|
||||
Iterator return impl.
|
||||
:return: Line read from file.
|
||||
"""
|
||||
line = super(FileWrapper, self).__next__()
|
||||
parent = super(FileWrapper, self)
|
||||
if hasattr(parent, '__next__'):
|
||||
line = parent.__next__() # Python 3
|
||||
else:
|
||||
line = parent.next() # Python 2
|
||||
if line:
|
||||
self.line_no += 1
|
||||
# Convert byte array to string with correct encoding
|
||||
return line.decode(sys.getdefaultencoding())
|
||||
return None
|
||||
next = __next__
|
||||
|
||||
|
||||
def split_dep(dep):
|
||||
|
Loading…
Reference in New Issue
Block a user