0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 23:18:48 -05:00

🐛 Fix undefined name RuntimeException on manage.py script

Python defines [`RuntimeError`](https://docs.python.org/3.7/library/exceptions.html#RuntimeError)
but it does not define `RuntimeException` so a `NameError` will be raised when any of these lines
are executed.

% `python3 -c "RuntimeException('This is a test...')"`
```
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'RuntimeException' is not defined
```

% `flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics`
```
./backend/scripts/manage.py:22:15: F821 undefined name 'RuntimeException'
        raise RuntimeException(f"invalid PREPL_URI: {PREPL_URI}")
              ^
./backend/scripts/manage.py:25:15: F821 undefined name 'RuntimeException'
        raise RuntimeException(f"invalid PREPL_URI: {PREPL_URI}")
              ^
./backend/scripts/manage.py:49:23: F821 undefined name 'RuntimeException'
                raise RuntimeException("unexpected response from PREPL")
                      ^
3     F821 undefined name 'RuntimeException'
3
```
This commit is contained in:
Christian Clauss 2023-02-04 11:33:27 +01:00 committed by Andrey Antukh
parent 517210eeb5
commit 58001f367a

View file

@ -19,10 +19,10 @@ PREPL_URI = "tcp://localhost:6063"
def get_prepl_conninfo(): def get_prepl_conninfo():
uri_data = urlparse(PREPL_URI) uri_data = urlparse(PREPL_URI)
if uri_data.scheme != "tcp": if uri_data.scheme != "tcp":
raise RuntimeException(f"invalid PREPL_URI: {PREPL_URI}") raise RuntimeError(f"invalid PREPL_URI: {PREPL_URI}")
if not isinstance(uri_data.netloc, str): if not isinstance(uri_data.netloc, str):
raise RuntimeException(f"invalid PREPL_URI: {PREPL_URI}") raise RuntimeError(f"invalid PREPL_URI: {PREPL_URI}")
host, port = uri_data.netloc.split(":", 2) host, port = uri_data.netloc.split(":", 2)
@ -46,7 +46,7 @@ def send_eval(expr):
result = json.load(f) result = json.load(f)
tag = result.get("tag", None) tag = result.get("tag", None)
if tag != "ret": if tag != "ret":
raise RuntimeException("unexpected response from PREPL") raise RuntimeError("unexpected response from PREPL")
return result.get("val", None), result.get("exception", None) return result.get("val", None), result.get("exception", None)
def encode(val): def encode(val):