Blog: 2025-03-18: Difference between revisions

From razwiki
Jump to navigation Jump to search
(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...")
 
No edit summary
Line 43: Line 43:
~~~~~~~~~~~^^^^
~~~~~~~~~~~^^^^
IndexError: list index out of range
IndexError: list index out of range
</pre>

IRC figured it out!

<pre>
cchianel │ razzi, might be one of these three: https://github.com/pypy/pyrepl/blob/ca192a80b76700118b9bfd261a3d098b92ccfc31/pyrepl/commands.py#L140-L156 │ 074ABBMFF
│15:41:25 gAy_Dragon │ SirDonNick: https://en.wikipedia.org/wiki/Control_character may be of use? │ 077AA9CEN
│15:41:40 cchianel │ if arg is ever 0, last command is a subclass of the delete-to-end-of-line, but that ring is never appended to │ [a]drien
│15:42:38 cchianel │ GOT IT! │ [D]
│15:42:39 <-- │ minecraftchest1 ([email protected]) has quit (Quit: minecraftchest1) │ [DW]fizi
│15:42:39 -- │ minecraftchest2 is now known as minecraftchest1 │ [twisti]
│15:42:51 cchianel │ Ctrl-W + Ctrl-K │ \x5B
│15:43:06 cchianel │ Ctrl-W = delete backwards │ _0x5fc3
│15:43:16 cchianel │ Ctrl-K = Delete to end of line │ _________
│15:43:27 cchianel │ Do this on an empty line to reproduce │ __builtin
│15:43:38 akk │ Ctrl-W is delete *word* backwards │ _flooded
│15:43:57 SnoopJ │ and ^H is one char │ _janus
│15:44:01 akk │ right │ _koolazer
│15:44:11 SirDonNick │ Dragon: Thanks. (Just as I started mumbling “now I know why old-timers never left home without their IBM ‶yellow card.″”) │ _moep_
│15:44:29 gAy_Dragon │ I checked man-ascii │ _qw
│15:44:32 SnoopJ │ I would guess that 'kill' probably refers to line-kill to the beginning or end of the line │ _val_
│15:44:33 akk │ and ^U is either delete from current point to beginning of line, or delete whole line, depending on the app │ a_fantom
│15:44:36 cchianel │ ^H does not reproducer │ abff
│15:44:37 gAy_Dragon │ ^W kills me. │ abn
│15:44:39 --> │ user69 (realname) ([email protected]) has joined #python │ Abrax
│15:44:43 gAy_Dragon │ because I use it a LOT │ acegallagher
│15:44:49 gAy_Dragon │ and then! │ ACfromTX
│15:44:53 gAy_Dragon │ I use firefox │ achilleas
│15:44:55 gAy_Dragon │ and curse loudly │ acidsys
│15:45:05 grym │ uh huh │ acryo
│15:45:05 gAy_Dragon │ (^w closes tabs) │ ad1m
│15:45:06 --> │ Left_Turn [Left_Turn] (realname) (~Matthew@2a00:23c8:5f85:3301:9407:8d8f:d36f:4b9a) has joined #python │ ad__
│15:45:09 <-- │ jiffe ([email protected]) has quit (Ping timeout: 252 seconds) │ aday56565
│15:45:17 cchianel │ So does the issue go to pyrepl or CPython? │ Adbray_
│15:45:19 <-- │ boomboxnation ([email protected]) has quit (Read error: Connection reset by peer) │ adeliktas
│15:45:50 akk │ gAy_Dragon: About a year ago firefox FINALLY stopped hardcoding ^W to be close window, and now it deletes the last word at least if you have the │ adigitoleo
│ │ appropriate gtk emacs binding settings │ aead
│15:45:51 <-- │ Guest0 (~Guest0@2a02:2a40:52e1:f700:3c49:29e4:321f:2095) has quit (Quit: Client closed) │ aefinity
│15:46:12 akk │ gAy_Dragon: that was my #1 gripe about firefox, how they kept making it harder to override their hardwired ^W │ aeris
│15:46:27 gAy_Dragon │ cchianel: whats the actual issue? │ aesthetics
│15:46:29 <-- │ infernix ([email protected]) has quit (Quit: ZNC - http://znc.sourceforge.net) │ Affliction
│15:46:33 gAy_Dragon │ is it that readline misbehaves? │ agireud
│15:46:42 <-- │ Blankspace (~Blankspac@user/blankspace) has quit (Quit: Client closed) │ agronholm
│15:46:45 SirDonNick │ And ^D kills a certain repl I can't admit to using without inviting scorn. (Well, scorn above my usual background baseline.) │ ahills
│15:46:50 cchianel │ gAy_Dragon, ^W^K crashes CPython │ AhmedAmerican_
│15:46:55 --> │ minecraftchest2 [minecraftchest1] (minecraftchest1) ([email protected]) has joined #python │ aindilis
│15:46:57 cchianel │ in REPL │ akaWolf
│15:47:04 razzi │ Wow great detective work cchianel !! │ akelly
</pre>
</pre>

Revision as of 15:48, 18 March 2025

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

IRC figured it out!

 cchianel │ razzi, might be one of these three: https://github.com/pypy/pyrepl/blob/ca192a80b76700118b9bfd261a3d098b92ccfc31/pyrepl/commands.py#L140-L156         │ 074ABBMFF
           │15:41:25 gAy_Dragon │ SirDonNick: https://en.wikipedia.org/wiki/Control_character may be of use?                                                                            │ 077AA9CEN
           │15:41:40   cchianel │ if arg is ever 0, last command is a subclass of the delete-to-end-of-line, but that ring is never appended to                                         │ [a]drien
           │15:42:38   cchianel │ GOT IT!                                                                                                                                               │ [D]
           │15:42:39        <-- │ minecraftchest1 ([email protected]) has quit (Quit: minecraftchest1)                                                                         │ [DW]fizi
           │15:42:39         -- │ minecraftchest2 is now known as minecraftchest1                                                                                                       │ [twisti]
           │15:42:51   cchianel │ Ctrl-W + Ctrl-K                                                                                                                                       │ \x5B
           │15:43:06   cchianel │ Ctrl-W = delete backwards                                                                                                                             │ _0x5fc3
           │15:43:16   cchianel │ Ctrl-K = Delete to end of line                                                                                                                        │ _________
           │15:43:27   cchianel │ Do this on an empty line to reproduce                                                                                                                 │ __builtin
           │15:43:38        akk │ Ctrl-W is delete *word* backwards                                                                                                                     │ _flooded
           │15:43:57     SnoopJ │ and ^H is one char                                                                                                                                    │ _janus
           │15:44:01        akk │ right                                                                                                                                                 │ _koolazer
           │15:44:11 SirDonNick │ Dragon: Thanks. (Just as I started mumbling “now I know why old-timers never left home without their IBM ‶yellow card.″”)                             │ _moep_
           │15:44:29 gAy_Dragon │ I checked man-ascii                                                                                                                                   │ _qw
           │15:44:32     SnoopJ │ I would guess that 'kill' probably refers to line-kill to the beginning or end of the line                                                            │ _val_
           │15:44:33        akk │ and ^U is either delete from current point to beginning of line, or delete whole line, depending on the app                                           │ a_fantom
           │15:44:36   cchianel │ ^H does not reproducer                                                                                                                                │ abff
           │15:44:37 gAy_Dragon │ ^W kills me.                                                                                                                                          │ abn
           │15:44:39        --> │ user69 (realname) ([email protected]) has joined #python                                                                            │ Abrax
           │15:44:43 gAy_Dragon │ because I use it a LOT                                                                                                                                │ acegallagher
           │15:44:49 gAy_Dragon │ and then!                                                                                                                                             │ ACfromTX
           │15:44:53 gAy_Dragon │ I use firefox                                                                                                                                         │ achilleas
           │15:44:55 gAy_Dragon │ and curse loudly                                                                                                                                      │ acidsys
           │15:45:05       grym │ uh huh                                                                                                                                                │ acryo
           │15:45:05 gAy_Dragon │ (^w closes tabs)                                                                                                                                      │ ad1m
           │15:45:06        --> │ Left_Turn [Left_Turn] (realname) (~Matthew@2a00:23c8:5f85:3301:9407:8d8f:d36f:4b9a) has joined #python                                                │ ad__
           │15:45:09        <-- │ jiffe ([email protected]) has quit (Ping timeout: 252 seconds)                                                                                     │ aday56565
           │15:45:17   cchianel │ So does the issue go to pyrepl or CPython?                                                                                                            │ Adbray_
           │15:45:19        <-- │ boomboxnation ([email protected]) has quit (Read error: Connection reset by peer)                                                              │ adeliktas
           │15:45:50        akk │ gAy_Dragon: About a year ago firefox FINALLY stopped hardcoding ^W to be close window, and now it deletes the last word at least if you have the      │ adigitoleo
           │                    │ appropriate gtk emacs binding settings                                                                                                                │ aead
           │15:45:51        <-- │ Guest0 (~Guest0@2a02:2a40:52e1:f700:3c49:29e4:321f:2095) has quit (Quit: Client closed)                                                               │ aefinity
           │15:46:12        akk │ gAy_Dragon: that was my #1 gripe about firefox, how they kept making it harder to override their hardwired ^W                                         │ aeris
           │15:46:27 gAy_Dragon │ cchianel: whats the actual issue?                                                                                                                     │ aesthetics
           │15:46:29        <-- │ infernix ([email protected]) has quit (Quit: ZNC - http://znc.sourceforge.net)                                                                  │ Affliction
           │15:46:33 gAy_Dragon │ is it that readline misbehaves?                                                                                                                       │ agireud
           │15:46:42        <-- │ Blankspace (~Blankspac@user/blankspace) has quit (Quit: Client closed)                                                                                │ agronholm
           │15:46:45 SirDonNick │ And ^D kills a certain repl I can't admit to using without inviting scorn.  (Well, scorn above my usual background baseline.)                         │ ahills
           │15:46:50   cchianel │ gAy_Dragon, ^W^K crashes CPython                                                                                                                      │ AhmedAmerican_
           │15:46:55        --> │ minecraftchest2 [minecraftchest1] (minecraftchest1) ([email protected]) has joined #python                                                   │ aindilis
           │15:46:57   cchianel │ in REPL                                                                                                                                               │ akaWolf
           │15:47:04      razzi │ Wow great detective work cchianel !!                                                                                                                  │ akelly