Blog: 2025-03-18

From razwiki
Revision as of 15:28, 18 March 2025 by Razzi (talk | contribs) (Created page with "Found this python repl bug. I remember hitting the up arrow, thinking I'd assign to <code>_</code> since I wanted to keep using that value, then when I hit <kbd>control+k</kbd> to clear a typo or something I got this error: <pre> new1 $ python Python 3.13.1 (main, Jan 29 2025, 03:21:14) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Found this python repl bug. I remember hitting the up arrow, thinking I'd assign to _ since I wanted to keep using that value, then when I hit control+k to clear a typo or something I got this error:

new1 $ python                                                                                                                    
Python 3.13.1 (main, Jan 29 2025, 03:21:14) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin                                        
Type "help", "copyright", "credits" or "license" for more information.                                                           
>>> import sqlite                                                                                                                                                                
Traceback (most recent call last):                                                                                               
  File "<python-input-0>", line 1, in <module>
    import sqlite                                                                                                                                                                
ModuleNotFoundError: No module named 'sqlite'                                           
>>> import sqlite3                                              
>>> sqlite3.connect('test.db')                                                                                                                                                   
<sqlite3.Connection object at 0x104197f10>                                                                                       
>>> Traceback (most recent call last):                                                                                                                                           
  File "<frozen runpy>", line 198, in _run_module_as_main       
  File "<frozen runpy>", line 88, in _run_code                                                                                   
  File "/usr/local/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/__main__.py", line 6, in <module>
    __pyrepl_interactive_console()                                                                   
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^                                                                   
  File "/usr/local/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/main.py", line 59, in interactive_console
    run_multiline_interactive_console(console)                                                       
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^                                                       
  File "/usr/local/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/simple_interact.py", line 151, in run_multiline_interactive_console
    statement = multiline_input(more_lines, ps1, ps2)                                                
  File "/usr/local/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/readline.py", line 389, in multiline_input                                                  
    return reader.readline()                                                                                                                                                     
           ~~~~~~~~~~~~~~~^^                
  File "/usr/local/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/reader.py", line 801, in readline                                                           
    self.handle1()                                                                                                                                                               
    ~~~~~~~~~~~~^^                                                                      
  File "/usr/local/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/reader.py", line 784, in handle1                                                            
    self.do_cmd(cmd)                                                                    
    ~~~~~~~~~~~^^^^^                        
  File "/usr/local/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/reader.py", line 709, in do_cmd                                                             
    command.do()                                  
    ~~~~~~~~~~^^                                  
  File "/usr/local/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/commands.py", line 154, in do                                                               
    self.kill_range(r.pos, eol)                   
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^                   
  File "/usr/local/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/commands.py", line 71, in kill_range                                                        
    r.kill_ring[-1] = r.kill_ring[-1] + text                                                         
                      ~~~~~~~~~~~^^^^                                                                
IndexError: list index out of range