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

Use LF instead of CRLF, when run against kernel #7659

Merged
merged 2 commits into from
Sep 24, 2021
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
1 change: 1 addition & 0 deletions news/2 Fixes/4576.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Strip CR from CRLF of source when sending code to the kernel for execution.
2 changes: 1 addition & 1 deletion src/client/datascience/jupyter/jupyterNotebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ export class JupyterNotebookBase implements INotebook {
? this.session.requestExecute(
{
// Remove the cell marker if we have one.
code: cellMatcher.stripFirstMarker(code),
code: cellMatcher.stripFirstMarker(code.replace(/\r\n/g, '\n')),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These usages look like the only three usages of session.requestExecute. So should this replace instead go into BaseJupyterSession.requestExecute? That would put it in only one place, and prevent someone else from adding a new usage of requestExecute that re-creates this issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to refactor the code, ideally we should have just one.
When the old Jupyter layer goes away we'll automatically have just one.
The other two will be in kernel stuff & i'd like to remove the executeSilently to go through kernel as well (but don't want to introduce a refactoring now)

Hopefully we'll get to some of that in debt week.

stop_on_error: false,
allow_stdin: true, // Allow when silent too in case runStartupCommands asks for a password
store_history: true // Silent actually means don't output anything. Store_history is what affects execution_count
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/jupyter/kernels/cellExecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ export class CellExecution implements IDisposable {
// https://jupyter-client.readthedocs.io/en/stable/api/client.html#jupyter_client.KernelClient.execute
const request = (this.request = session.requestExecute(
{
code,
code: code.replace(/\r\n/g, '\n'),
silent: false,
stop_on_error: false,
allow_stdin: true,
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/jupyter/kernels/kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ export async function executeSilently(session: IJupyterSession, code: string): P

const request = session.requestExecute(
{
code,
code: code.replace(/\r\n/g, '\n'),
silent: false,
stop_on_error: false,
allow_stdin: true,
Expand Down