Skip to content

Commit efd785a

Browse files
authored
Merge pull request #3276 from A5rocks/clean-up-logic
2 parents 79bdcf7 + ca2e9a1 commit efd785a

3 files changed

Lines changed: 28 additions & 23 deletions

File tree

.github/workflows/ci.yml

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,11 @@ jobs:
182182
# lsp_extract_file: ''
183183
# extra_name: ', with non-IFS LSP'
184184

185-
# ***REMEMBER*** to remove the 3.14 line once windows+cffi works again
186185
continue-on-error: >-
187186
${{
188187
(
189188
endsWith(matrix.python, '-dev')
190189
|| endsWith(matrix.python, '-nightly')
191-
|| matrix.python == '3.14'
192190
)
193191
&& true
194192
|| false
@@ -202,18 +200,11 @@ jobs:
202200
- name: Setup python
203201
uses: actions/setup-python@v5
204202
with:
205-
# This allows the matrix to specify just the major.minor version while still
206-
# expanding it to get the latest patch version including alpha releases.
207-
# This avoids the need to update for each new alpha, beta, release candidate,
208-
# and then finally an actual release version. actions/setup-python doesn't
209-
# support this for PyPy presently so we get no help there.
210-
#
211-
# 'CPython' -> '3.9.0-alpha - 3.9.X'
212-
# 'PyPy' -> 'pypy-3.9'
213-
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
203+
python-version: '${{ matrix.python }}'
214204
architecture: '${{ matrix.arch }}'
215205
cache: pip
216206
cache-dependency-path: test-requirements.txt
207+
allow-prereleases: true
217208
- name: Run tests
218209
run: ./ci.sh
219210
shell: bash
@@ -276,9 +267,10 @@ jobs:
276267
- name: Setup python
277268
uses: actions/setup-python@v5
278269
with:
279-
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
270+
python-version: '${{ matrix.python }}'
280271
cache: pip
281272
cache-dependency-path: test-requirements.txt
273+
allow-prereleases: true
282274
- name: Check Formatting
283275
if: matrix.check_formatting == '1'
284276
run:
@@ -328,9 +320,10 @@ jobs:
328320
- name: Setup python
329321
uses: actions/setup-python@v5
330322
with:
331-
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
323+
python-version: '${{ matrix.python }}'
332324
cache: pip
333325
cache-dependency-path: test-requirements.txt
326+
allow-prereleases: true
334327
- name: Run tests
335328
run: ./ci.sh
336329
- if: always()
@@ -356,19 +349,29 @@ jobs:
356349
# `nodejs` for pyright (`node-env` pulls in nodejs but that takes a while and can time out the test).
357350
# `perl` for a platform independent `sed -i` alternative
358351
run: apk update && apk add python3-dev bash nodejs perl
352+
359353
- name: Retrieve the project source from an sdist inside the GHA artifact
360354
# must be after `apk add` because it relies on `bash` existing
361355
uses: re-actors/checkout-python-sdist@release/v2
362356
with:
363357
source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
364358
workflow-artifact-name: ${{ env.dists-artifact-name }}
359+
365360
- name: Enter virtual environment
366361
run: python -m venv .venv
362+
367363
- name: Run tests
368364
run: source .venv/bin/activate && ./ci.sh
365+
369366
- name: Get Python version for codecov flag
370367
id: get-version
371-
run: echo "version=$(python -V | cut -d' ' -f2 | cut -d'.' -f1,2)" >> "${GITHUB_OUTPUT}"
368+
shell: python
369+
run: |
370+
import sys, os
371+
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
372+
f.write("version=" + ".".join(map(str, sys.version_info[:2])))
373+
f.write("\n")
374+
372375
- if: always()
373376
uses: codecov/codecov-action@v3
374377
with:
@@ -425,11 +428,14 @@ jobs:
425428
- name: import & run module
426429
run: coverage run -m tests.cython.run_test_cython
427430

428-
- name: get Python version for codecov flag
431+
- name: Get Python version for codecov flag
429432
id: get-version
430-
run: >-
431-
echo "version=$(python -V | cut -d' ' -f2 | cut -d'.' -f1,2)"
432-
>> "${GITHUB_OUTPUT}"
433+
shell: python
434+
run: |
435+
import sys, os
436+
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
437+
f.write("version=" + ".".join(map(str, sys.version_info[:2])))
438+
f.write("\n")
433439
434440
- run: |
435441
coverage combine

src/trio/_subprocess.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -736,8 +736,7 @@ async def read_output(
736736

737737
# Opening the process does not need to be inside the nursery, so we put it outside
738738
# so any exceptions get directly seen by users.
739-
# options needs a complex TypedDict. The overload error only occurs on Unix.
740-
proc = await open_process(command, **options) # type: ignore[arg-type, call-overload, unused-ignore]
739+
proc = await _open_process(command, **options) # type: ignore[arg-type]
741740
async with trio.open_nursery() as nursery:
742741
try:
743742
if input_ is not None:
@@ -1164,7 +1163,7 @@ async def open_process(
11641163
async def run_process(
11651164
command: StrOrBytesPath,
11661165
*,
1167-
stdin: bytes | bytearray | memoryview | int | HasFileno | None = None,
1166+
stdin: bytes | bytearray | memoryview | int | HasFileno | None = b"",
11681167
shell: Literal[True],
11691168
**kwargs: Unpack[UnixRunProcessArgs],
11701169
) -> subprocess.CompletedProcess[bytes]: ...
@@ -1173,7 +1172,7 @@ async def run_process(
11731172
async def run_process(
11741173
command: Sequence[StrOrBytesPath],
11751174
*,
1176-
stdin: bytes | bytearray | memoryview | int | HasFileno | None = None,
1175+
stdin: bytes | bytearray | memoryview | int | HasFileno | None = b"",
11771176
shell: bool = False,
11781177
**kwargs: Unpack[UnixRunProcessArgs],
11791178
) -> subprocess.CompletedProcess[bytes]: ...

src/trio/_tests/test_subprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ async def test_run_process_internal_error(monkeypatch: pytest.MonkeyPatch) -> No
733733
async def very_broken_open(*args: object, **kwargs: object) -> str:
734734
return "oops"
735735

736-
monkeypatch.setattr(trio._subprocess, "open_process", very_broken_open)
736+
monkeypatch.setattr(trio._subprocess, "_open_process", very_broken_open)
737737
with RaisesGroup(AttributeError, AttributeError):
738738
await run_process(EXIT_TRUE, capture_stdout=True)
739739

0 commit comments

Comments
 (0)