Autoreload on jupyter conflicts with non-ASCII characters produced by Cursor

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

I’m facing an annoying issue while use Cursor to edit my package and use the updates in the same time on jupyter lab. The cursor uses non-ASCII characters in the code comments and then this prevents autoreload doing its job.

[autoreload of ******.modules.**.**** failed: Traceback (most recent call last):
  File "/opt/global/lib/python3.12/site-packages/IPython/extensions/autoreload.py", line 322, in check
    elif self.deduper_reloader.maybe_reload_module(m):
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/global/lib/python3.12/site-packages/IPython/extensions/deduperreload/deduperreload.py", line 545, in maybe_reload_module
    new_source_code = f.read()
                      ^^^^^^^^
  File "/usr/lib/python3.12/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 6130: ordinal not in range(128)
]

Steps to Reproduce

install a package using pip install -e .

Operating System

Linux

Version Information

Version: 2.4.37 (Universal)
VSCode Version: 1.105.1
Commit: 7b9c34466f5c119e93c3e654bb80fe9306b6cc70
Date: 2026-02-12T23:15:35.107Z
Build Type: Stable
Release Track: Default
Electron: 39.2.7
Chromium: 142.0.7444.235
Node.js: 22.21.1
V8: 14.2.231.21-electron.0
OS: Darwin arm64 25.1.0

For AI issues: which model did you use?

Opus 4.6 MAX

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey, thanks for the report. This is a two-sided issue, so it’s worth breaking it down:

From Cursor’s side: AI models (including Opus) sometimes insert “nice-looking” Unicode characters into comments, like curly quotes, long dashes, and so on. The 0xe2 byte in your error is the start of a multi-byte UTF-8 character, which matches this.

From the Python and Jupyter side: the autoreload extension is trying to read your source files using the ASCII codec instead of UTF-8, so it crashes on any non-ASCII byte.

Temporary workarounds you can try right now:

  1. Add a .cursorrules file (or use Cursor Settings > Rules) with something like:

    Always use only ASCII characters in code comments. Do not use curly quotes, em dashes, or any non-ASCII characters.
    

    This should significantly reduce the model inserting those characters.

  2. On the Python side, add # -*- coding: utf-8 -*- at the top of your source files and or set the PYTHONIOENCODING=utf-8 environment variable before starting Jupyter. This tells Python to use UTF-8 instead of ASCII when reading source files.

Could you share the Request ID (chat context menu > Copy Request ID) from the session where this happened, and an example of the exact characters the model inserted? That would help with the investigation.

1 Like

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.