Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch subprocess.Popen when running on Windows under Positron #1658

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@

- `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)

- 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
Loading