UCSD-PL / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
0 stars 7 forks source link

weird exception thrown both in the web version and the local version #15

Open rlisahuang opened 1 year ago

rlisahuang commented 1 year ago

If we paste the code below into the editor, either the web version or the local version:

import matplotlib.pyplot as plt
import pandas as pd
import io

csv = '''
ID,group,time,success
P1,control,18.6,1
P2,control,15.42,1
P3,control,25.55,0
P4,control,12.56,0
P5,control,8.67,1
P6,experiment,7.31,0
P7,experiment,9.66,0
P8,experiment,13.64,1
P9,experiment,14.92,1
P10,experiment,18.47,1
'''

# weird error for this line if there is nothing else after this line
b = pd.read_csv(io.StringIO(csv))

you will see some weird exception thrown for the last line. The exception differs between the web and the local versions.

However, if you add one new line after the last line,

b = pd.read_csv(io.StringIO(csv))
# insert new line here

the error disappears.

rlisahuang commented 1 year ago

Web version: Screenshot 2023-02-17 at 1 09 50 PM

Local version:

Screenshot 2023-02-17 at 1 10 38 PM

It is not a Python error, because running in REPL / by pressing the Run button shows no error.

rlisahuang commented 1 year ago

May be related to #18 . But this one is different in a sense that you could provide extra lines at the end of the starter code file to avoid the bug.

rlisahuang commented 1 year ago

Update: this error does not happen when no modules are used in the last line, or when the module is numpy

rlisahuang commented 1 year ago

Easy fix for now: force every starter code file to have at least one extra line at the end