UnicodeDecodeError in detect_encoding in ipython interactive
- Dominant language
- Python
- Stars
- 3.2k
- Forks
- 245
- Avg merge
- 13m
- Merged PRs (30d)
- 5
Description
Running the following interactively crashes the debugger with a unicode decode error:
``` python
In[0]: import pudb.ipython
In[1]: %pdb
In[2]: def a():
1/0
In[3]: a()
pudb/lowlevel.py", line 142: if first.startswith(BOM_UTF8):
*** UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)
```
Monkey-pathing like this resolves the problem
``` python
pudb.lowlevel.detect_encoding = lambda _: ("utf-8", [])
```
**Environment:**
Ubuntu 14.04
ipython 2.1.0 & 4.0.0
pudb 2015.3
$ echo $LANG
en_US.UTF-8
In[3]: sys.getdefaultencoding()
Out[3]: 'ascii'
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the interactive reproducer using pudb.ipython, %pdb, and the failing function, then inspect pudb/lowlevel.py at line 142 where detect_encoding handles BOM_UTF8. Reproduce the UnicodeDecodeError under the reported ASCII default encoding and verify that the debugger no longer crashes while detecting the UTF-8 encoding.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100