mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-21 11:31:15 -03:00
Fix compatibility with Python 3.6 for OpenSUSE Leap 15.6
Nightlies for opensuse/leap:15.6 are failing because their /bin/python3 is Python 3.6 (the "python311" package creates only /bin/python311). Python3.6 has been EOL for 3.5 years but OpenSuse leap is not even EOL. Given that we don't write a lot of Python, let's support this for now.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import asyncio
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
import os
|
||||
from pathlib import Path
|
||||
@@ -235,23 +234,35 @@ async def main():
|
||||
return 1 if failcount else 0
|
||||
|
||||
|
||||
@dataclass
|
||||
# TODO(python>=3.7): @dataclass
|
||||
class TestSkip:
|
||||
arg: str
|
||||
|
||||
def __init__(self, arg: str):
|
||||
self.arg = arg
|
||||
|
||||
|
||||
@dataclass
|
||||
class TestFail:
|
||||
arg: str
|
||||
duration_ms: Optional[int]
|
||||
error_message: Optional[str]
|
||||
|
||||
def __init__(
|
||||
self, arg: str, duration_ms: Optional[int], error_message: Optional[str]
|
||||
):
|
||||
self.arg = arg
|
||||
self.duration_ms = duration_ms
|
||||
self.error_message = error_message
|
||||
|
||||
|
||||
@dataclass
|
||||
class TestPass:
|
||||
arg: str
|
||||
duration_ms: int
|
||||
|
||||
def __init__(self, arg: str, duration_ms: Optional[int]):
|
||||
self.arg = arg
|
||||
self.duration_ms = duration_ms
|
||||
|
||||
|
||||
TestResult = Union[TestSkip, TestFail, TestPass]
|
||||
|
||||
@@ -334,9 +345,22 @@ async def run_test(
|
||||
return TestFail(arg, None, "Error in test driver. This should be unreachable.")
|
||||
|
||||
|
||||
if sys.version_info < (3, 7):
|
||||
|
||||
def asyncio_run(coro):
|
||||
loop = asyncio.get_event_loop()
|
||||
try:
|
||||
return loop.run_until_complete(coro)
|
||||
finally:
|
||||
if not loop.is_closed():
|
||||
loop.close()
|
||||
|
||||
else:
|
||||
asyncio_run = asyncio.run
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
ret = asyncio.run(main())
|
||||
ret = asyncio_run(main())
|
||||
sys.exit(ret)
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(130)
|
||||
|
||||
Reference in New Issue
Block a user