Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coconut crashes with AttributeError: 'frozenset' object has no attribute 'append' with python 3.12 #805

Closed
aufildelanuit opened this issue Nov 23, 2023 · 1 comment

Comments

@aufildelanuit
Copy link

aufildelanuit commented Nov 23, 2023

I am not a proficient coconut user. I tried to install coconut to give it a try on Fedora 39, but coconut seems to crash at the first command, no matter what I type.

OS: Linux (Fedora 39)
Python version: 3.12
Coconut version: v3.0.3
Shell: bash or xonsh
Terminal: kitty or gnome-terminal
Install method: pip or pipx

How to reproduce the issue:

  • have python 3.12 installed as the default python interpreter
  • install coconut with either pip or pipx
  • start the coconut prompt by typing coconut in a shell
  • type anything (e.g., 1+1) in the prompt

Here is the traceback (user directory replaced with ~):

Traceback (most recent call last):                                                                        
  File "~/.local/pipx/.cache/586ad7c83fd090d/lib64/python3.12/site-packages/coconut/command/command.py", line 476, in handling_exceptions                                                                
    yield                                                                                                 
  File "~/.local/pipx/.cache/586ad7c83fd090d/lib64/python3.12/site-packages/coconut/command/command.py", line 398, in execute_args                                                                       
    self.start_prompt()                                                                                   
  File "~/.local/pipx/.cache/586ad7c83fd090d/lib64/python3.12/site-packages/coconut/command/command.py", line 769, in start_prompt                                                                       
    compiled = self.handle_input(code)                                                                    
               ^^^^^^^^^^^^^^^^^^^^^^^                                                                    
  File "~/.local/pipx/.cache/586ad7c83fd090d/lib64/python3.12/site-packages/coconut/command/command.py", line 785, in handle_input                                                                       
    return self.parse_block(code)                                                                         
           ^^^^^^^^^^^^^^^^^^^^^^                                                                         
  File "~/.local/pipx/.cache/586ad7c83fd090d/lib64/python3.12/site-packages/coconut/command/command.py", line 215, in parse_block                                                                        
    return self.comp.parse_block(code, keep_state=True)                                                   
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                   
  File "~/.local/pipx/.cache/586ad7c83fd090d/lib64/python3.12/site-packages/coconut/compiler/compiler.py", line 4647, in parse_block                                                                     
    return self.parse(inputstring, self.file_parser, {}, {"header": "none", "initial": "none"}, **kwargs) 
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
  File "~/.local/pipx/.cache/586ad7c83fd090d/lib64/python3.12/site-packages/coconut/compiler/compiler.py", line 1247, in parse                                                                           
    parsed = parse(parser, pre_procd, inner=False)                                                        
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                        
  File "~/.local/pipx/.cache/586ad7c83fd090d/lib64/python3.12/site-packages/coconut/compiler/util.py", line 445, in parse                                                                                
    result = prep_grammar(grammar).parseString(text)                                                      
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "cPyparsing.pyx", line 2516, in cPyparsing.ParserElement.parseString                               
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 4947, in cPyparsing.And.parseImpl                                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 4947, in cPyparsing.And.parseImpl                                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 4964, in cPyparsing.And.parseImpl                                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 4964, in cPyparsing.And.parseImpl                                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5825, in cPyparsing.ZeroOrMore.parseImpl                                    
  File "cPyparsing.pyx", line 5731, in cPyparsing._MultipleMatch.parseImpl                                
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5192, in cPyparsing.MatchFirst.parseImpl                                    
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5423, in cPyparsing.ParseElementEnhance.parseImpl                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5192, in cPyparsing.MatchFirst.parseImpl                                    
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5192, in cPyparsing.MatchFirst.parseImpl                                    
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5192, in cPyparsing.MatchFirst.parseImpl                                    
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5192, in cPyparsing.MatchFirst.parseImpl                                    
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 4947, in cPyparsing.And.parseImpl                                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 4947, in cPyparsing.And.parseImpl                                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 4947, in cPyparsing.And.parseImpl                                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5423, in cPyparsing.ParseElementEnhance.parseImpl                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5192, in cPyparsing.MatchFirst.parseImpl                                    
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5027, in cPyparsing.Or.parseImpl                                            
  File "cPyparsing.pyx", line 2002, in cPyparsing.ParserElement.tryParse                                  
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 4947, in cPyparsing.And.parseImpl                                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 4964, in cPyparsing.And.parseImpl                                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5192, in cPyparsing.MatchFirst.parseImpl                                    
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5423, in cPyparsing.ParseElementEnhance.parseImpl                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5423, in cPyparsing.ParseElementEnhance.parseImpl                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 4947, in cPyparsing.And.parseImpl                                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5192, in cPyparsing.MatchFirst.parseImpl                                    
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5423, in cPyparsing.ParseElementEnhance.parseImpl                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5423, in cPyparsing.ParseElementEnhance.parseImpl                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5192, in cPyparsing.MatchFirst.parseImpl                                    
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5192, in cPyparsing.MatchFirst.parseImpl                                    
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                        
  File "cPyparsing.pyx", line 5192, in cPyparsing.MatchFirst.parseImpl                                    
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5423, in cPyparsing.ParseElementEnhance.parseImpl                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5192, in cPyparsing.MatchFirst.parseImpl                                    
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 4947, in cPyparsing.And.parseImpl                                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5192, in cPyparsing.MatchFirst.parseImpl                                    
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5423, in cPyparsing.ParseElementEnhance.parseImpl                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "cPyparsing.pyx", line 5423, in cPyparsing.ParseElementEnhance.parseImpl                           
  File "cPyparsing.pyx", line 2317, in cPyparsing.ParserElement._parseIncremental                         
  File "~/.local/pipx/.cache/586ad7c83fd090d/lib64/python3.12/site-packages/coconut/compiler/util.py", line 684, in parseImpl                                                                            
    with self.wrapped_context():                                                                          
  File "/usr/lib64/python3.12/contextlib.py", line 137, in __enter__                                      
    return next(self.gen)                                                                                 
           ^^^^^^^^^^^^^^                                                                                 
  File "~/.local/pipx/.cache/586ad7c83fd090d/lib64/python3.12/site-packages/coconut/compiler/util.py", line 669, in wrapped_context                                                                      
    ParserElement.packrat_context.append(self.wrapper)                                                    
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^   
AttributeError: 'frozenset' object has no attribute 'append'                                              
(you should report this at https://github.com/evhub/coconut/issues/new)                                   
Coconut exiting with error: AttributeError

Edit: I could reproduce this issue in docker containers with all python versions from 3.7 to 3.12 (untested below 3.7), so I guess either I am doing something wrong, or there is a problem with coconut v3.0.3.

@evhub
Copy link
Owner

evhub commented Nov 24, 2023

Duplicate of #804. Will be resolved in the next release shortly—until then you just need to downgrade cPyparsing with

pip install cPyparsing==2.4.7.2.2.1

@evhub evhub closed this as completed Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants