Skip to content

Commit

Permalink
Merge pull request #1658 from rstudio/bugfix/positron-windows-subprocess
Browse files Browse the repository at this point in the history
Patch `subprocess.Popen` when running on Windows under Positron
  • Loading branch information
t-kalinowski committed Sep 4, 2024
2 parents 922164f + e92d3a0 commit e7a66d1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@

- `as.character()` method for `python.builtin.bytes` gains a `nul` argument,
allowing for convenient handling of embedded NULs in the string. (#1652)

- New `as.character()` method for `python.builtin.str` with support for handling
embedded NULs in strings. (#1653)

- Reticulate will now use the `RETICULATE_VIRTUALENV_ROOT` environment variable
when determining where to resolve virtual environments. (#1657)

- Fixed an error where opening a Python subprocess in Positron on Windows
resulted in "OSError: [WinError 6] The handle is invalid."
(#1658, posit-dev/positron#4457)

# reticulate 1.38.0

- Python Exceptions converted to R conditions are now R lists instead
Expand Down
4 changes: 4 additions & 0 deletions R/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,10 @@ is_rstudio_desktop <- function() {
identical(version$mode, "desktop")
}

is_positron <- function() {
exists(".ps.ark.version", envir = globalenv())
}

clean_version <- function(version) {
gsub("\\.$", "", gsub("[A-Za-z_+].*$", "", version))
}
Expand Down
2 changes: 1 addition & 1 deletion R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ ensure_python_initialized <- function(required_module = NULL) {
remap_output_streams()
set_knitr_python_stdout_hook()

if (is_windows() && identical(.Platform$GUI, "RStudio"))
if (is_windows() && ( is_rstudio() || is_positron() ))
import("rpytools.subprocess")$patch_subprocess_Popen()

# generate 'R' helper object
Expand Down
2 changes: 1 addition & 1 deletion R/repl.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ repl_python <- function(

ensure_python_initialized()
if (is.null(input) &&
Sys.getenv("POSITRON") == "1" &&
is_positron() &&
exists(".ps.reticulate_open", inherits = TRUE)) {

eval(call(".ps.reticulate_open"))
Expand Down

0 comments on commit e7a66d1

Please sign in to comment.