Skip to content

Commit

Permalink
Merge pull request hylang#2461 from Kodiologist/pypy-update
Browse files Browse the repository at this point in the history
Update PyPy testing
  • Loading branch information
Kodiologist authored Jun 30, 2023
2 parents e4b00cb + 15abf28 commit 18af19e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
matrix:
name-prefix: ['']
os: [ubuntu-latest]
python: [3.8, 3.9, '3.10', 3.11, 3.12-dev, pypy-3.9, pyodide]
python: [3.8, 3.9, '3.10', 3.11, 3.12-dev, pypy-3.10, pyodide]
include:
# To keep the overall number of runs low, we test Windows and MacOS
# only on the latest CPython.
Expand Down
14 changes: 10 additions & 4 deletions docs/interop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,16 @@ You can use :ref:`hy2py` to convert a Hy program to Python. The output will
still import ``hy``, and thus require Hy to be installed in order to run; see
:ref:`implicit-names` for details and workarounds.

To execute Hy code from a string, use :func:`hy.read` to convert it to
:ref:`models <models>` and then :func:`hy.eval` to evaluate it. There is no Hy
equivalent of :func:`exec` because :func:`hy.eval` works even when the input
isn't equivalent to a single Python expression.
To execute Hy code from a string, use :hy:func:`hy.read-many` to convert it to
:ref:`models <models>` and then :hy:func:`hy.eval` to evaluate it:

.. code-block:: python
>>> hy.eval(hy.read_many("(setv x 1) (+ x 1)"))
2
There is no Hy equivalent of :func:`exec` because :hy:func:`hy.eval` works
even when the input isn't equivalent to a single Python expression.

You can use :meth:`hy.REPL.run` to launch the Hy REPL from Python, as in
``hy.REPL(locals = locals()).run()``.
Expand Down
4 changes: 2 additions & 2 deletions hy/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pathlib import Path

import hy
from hy._compat import PY3_9, PYPY
from hy._compat import PY3_9
from hy.compiler import hy_compile, hy_eval
from hy.errors import HyLanguageError, filtered_hy_exceptions, hy_exc_handler
from hy.importer import runhy
Expand Down Expand Up @@ -270,7 +270,7 @@ def proc_opt(opt, arg=None, item=None, i=None):
set_path(filename)
# Ensure __file__ is set correctly in the code we're about
# to run.
if PY3_9 and not PYPY:
if PY3_9:
if not filename.is_absolute():
filename = Path.cwd() / filename
if platform.system() == "Windows":
Expand Down
5 changes: 2 additions & 3 deletions tests/test_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import pytest

from hy._compat import PY3_9, PYODIDE, PYPY
from hy._compat import PY3_9, PYODIDE

if PYODIDE:
pytest.skip(
Expand Down Expand Up @@ -681,7 +681,6 @@ def test_output_buffering(tmp_path):
assert tf.read_text().splitlines() == ["line 1", "line 2"]


@pytest.mark.skipif(PYPY, reason = 'https://foss.heptapod.net/pypy/pypy/-/issues/3881')
def test_uufileuu(tmp_path, monkeypatch):
# `__file__` should be set the same way as in Python.
# https://github.com/hylang/hy/issues/2318
Expand All @@ -691,7 +690,7 @@ def test_uufileuu(tmp_path, monkeypatch):
(tmp_path / "realdir" / "pyex.py").write_text('print(__file__)')

def file_is(arg, expected_py3_9):
expected = expected_py3_9 if PY3_9 and not PYPY else Path(arg)
expected = expected_py3_9 if PY3_9 else Path(arg)
output, _ = run_cmd(["python3", arg + "pyex.py"])
assert output.rstrip() == str(expected / "pyex.py")
output, _ = run_cmd(["hy", arg + "hyex.hy"])
Expand Down

0 comments on commit 18af19e

Please sign in to comment.