Skip to content

Fix pyodide https#6

Merged
rgbkrk merged 4 commits intomainfrom
fix-pyodide-https
Jun 23, 2025
Merged

Fix pyodide https#6
rgbkrk merged 4 commits intomainfrom
fix-pyodide-https

Conversation

@rgbkrk
Copy link
Member

@rgbkrk rgbkrk commented Jun 23, 2025

Slightly improve network needing code usage in the pyodide runtime.

rgbkrk added 4 commits June 23, 2025 11:00
- Fix VerboseTB initialization with fallback approaches for IPython compatibility
- Add pyodide-http package to enable HTTPS support for requests library
- Document working HTTPS solution using requests + StringIO for pandas

Fixes:
1. VerboseTB 'mode' parameter error by trying different initialization approaches
2. HTTPS URLs now work with requests library (pandas.read_csv still needs workaround)

Working HTTPS pattern:
  import requests, pandas as pd, io
  response = requests.get('https://example.com/data.csv')
  df = pd.read_csv(io.StringIO(response.text))

The requests library works with HTTPS out of the box via pyodide-http patching.
Remove comments that single out individual packages in the lists,
making the code cleaner and more consistent.
Replace complex fallback logic with the exact pattern that works in our environment:
- VerboseTB(color_scheme='Neutral') for initialization
- format_exception(exc_value, exc_traceback) with only 2 args

Tested and verified in our exact Pyodide/IPython environment.
Replace VerboseTB with standard traceback formatting to ensure correct
exception type parsing. VerboseTB was causing all exceptions to be
formatted as 'PythonError' instead of preserving the actual exception
type like 'ValueError'.

Now error outputs correctly show:
  ename: 'ValueError' (not 'PythonError')
  evalue: 'test error message'
  traceback: [proper traceback lines]

Fixes test failure in real-execution.test.ts.
@rgbkrk rgbkrk merged commit acd45fc into main Jun 23, 2025
12 checks passed
@rgbkrk rgbkrk deleted the fix-pyodide-https branch June 24, 2025 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant