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

The coconut interpreter told me to report this #561

Closed
BruceEckel opened this issue Dec 21, 2020 · 10 comments
Closed

The coconut interpreter told me to report this #561

BruceEckel opened this issue Dec 21, 2020 · 10 comments

Comments

@BruceEckel
Copy link

>coconut
Coconut Interpreter:
(type 'exit()' or press Ctrl-D to end)
>>> range(1,10) |> reduce$(*) |> print
362880
>>> range(1,10) |> reduce$(*, initializer = 1000) |> print
cPyparsing.ParseException: Expected end of text, found 'r'  (at char 0), (line:1, col:1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\python\lib\site-packages\coconut\command\command.py", line 291, in handling_exceptions
    yield
  File "c:\python\lib\site-packages\coconut\command\command.py", line 128, in cmd
    self.use_args(parsed_args, interact, original_args=args)
  File "c:\python\lib\site-packages\coconut\command\command.py", line 269, in use_args
    self.start_prompt()
  File "c:\python\lib\site-packages\coconut\command\command.py", line 534, in start_prompt
    compiled = self.handle_input(code)
  File "c:\python\lib\site-packages\coconut\command\command.py", line 550, in handle_input
    return self.comp.parse_block(code)
  File "c:\python\lib\site-packages\coconut\compiler\compiler.py", line 2344, in parse_block
    return self.parse(inputstring, self.file_parser, {}, {"header": "none", "initial": "none"})
  File "c:\python\lib\site-packages\coconut\compiler\compiler.py", line 754, in parse
    parsed = parse(parser, pre_procd)
  File "c:\python\lib\site-packages\coconut\compiler\util.py", line 260, in parse
    return unpack(grammar.parseWithTabs().parseString(text))
  File "cPyparsing.pyx", line 1886, in cPyparsing.ParserElement.parseString
  File "cPyparsing.pyx", line 1781, in cPyparsing.ParserElement._parseCache
  File "cPyparsing.pyx", line 1787, in cPyparsing.ParserElement._parseCache
  File "cPyparsing.pyx", line 1626, in cPyparsing.ParserElement._parseNoCache
  File "cPyparsing.pyx", line 3998, in cPyparsing.And.parseImpl
  File "cPyparsing.pyx", line 270, in cPyparsing.ParseBaseException._from_exception
TypeError: type() takes 1 or 3 arguments
(you should report this at https://github.com/evhub/coconut/issues/new)
Exiting due to TypeError.
@evhub evhub added the bug label Dec 22, 2020
@evhub evhub added this to the v1.5.0 milestone Dec 22, 2020
@evhub
Copy link
Owner

evhub commented Dec 22, 2020

@BruceEckel Thanks for reporting this issue. I believe it should already be resolved on coconut-develop, which you can get via pip install -U coconut-develop, however if you could verify that it works after you do that that would be appreciated.

If it still doesn't work after upgrading to coconut-develop, you should try using coconut --verbose, enter the same code, put the output on this issue, and I'll try to see what I can do.

@BruceEckel
Copy link
Author

Here's what happened with coconut-develop:

C:\Users\Bruce
>coconut-develop
Coconut Interpreter:
(enter 'exit()' or press Ctrl-D to end)
>>> range(1,10) |> reduce$(*, initializer = 1000) |> print
cPyparsing.ParseException: Expected end of text, found 'r'  (at char 0), (line:1, col:1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\python\lib\site-packages\coconut\command\command.py", line 294, in handling_exceptions
    yield
  File "c:\python\lib\site-packages\coconut\command\command.py", line 130, in cmd
    self.use_args(parsed_args, interact, original_args=args)
  File "c:\python\lib\site-packages\coconut\command\command.py", line 272, in use_args
    self.start_prompt()
  File "c:\python\lib\site-packages\coconut\command\command.py", line 544, in start_prompt
    compiled = self.handle_input(code)
  File "c:\python\lib\site-packages\coconut\command\command.py", line 560, in handle_input
    return self.comp.parse_block(code)
  File "c:\python\lib\site-packages\coconut\compiler\compiler.py", line 2485, in parse_block
    return self.parse(inputstring, self.file_parser, {}, {"header": "none", "initial": "none"})
  File "c:\python\lib\site-packages\coconut\compiler\compiler.py", line 780, in parse
    parsed = parse(parser, pre_procd)
  File "c:\python\lib\site-packages\coconut\compiler\util.py", line 264, in parse
    return unpack(grammar.parseWithTabs().parseString(text))
  File "cPyparsing.pyx", line 1886, in cPyparsing.ParserElement.parseString
  File "cPyparsing.pyx", line 1781, in cPyparsing.ParserElement._parseCache
  File "cPyparsing.pyx", line 1787, in cPyparsing.ParserElement._parseCache
  File "cPyparsing.pyx", line 1626, in cPyparsing.ParserElement._parseNoCache
  File "cPyparsing.pyx", line 3998, in cPyparsing.And.parseImpl
  File "cPyparsing.pyx", line 270, in cPyparsing.ParseBaseException._from_exception
TypeError: type() takes 1 or 3 arguments
(you should report this at https://github.com/evhub/coconut/issues/new)
Exiting due to TypeError.

Then I tried coconut-develop --verbose and got this:

C:\Users\Bruce
>coconut-develop --verbose
Using Cython cPyparsing v2.4.5.
Parsed args: Namespace(source=None, dest=None, target=None, interact=False, package=False, standalone=False, line_numbers=False, keep_lines=False, watch=False, run=False, no_write=False, display=False, quiet=False, strict=False, no_tco=False, no_wrap=False, code=None, jobs=None, force=False, minify=False, jupyter=None, mypy=None, argv=None, tutorial=False, documentation=False, style=None, history_file=None, recursion_limit=None, verbose=True, trace=False)
Compiler args: {'target': '', 'strict': False, 'minify': False, 'line_numbers': False, 'keep_lines': False, 'no_tco': False, 'no_wrap': False}
Coconut Interpreter:
(enter 'exit()' or press Ctrl-D to end)
Traceback (most recent call last):
  File "c:\python\lib\site-packages\coconut\command\command.py", line 294, in handling_exceptions
    yield
  File "c:\python\lib\site-packages\coconut\command\command.py", line 130, in cmd
    self.use_args(parsed_args, interact, original_args=args)
  File "c:\python\lib\site-packages\coconut\command\command.py", line 272, in use_args
    self.start_prompt()
  File "c:\python\lib\site-packages\coconut\command\command.py", line 539, in start_prompt
    self.start_running()
  File "c:\python\lib\site-packages\coconut\command\command.py", line 531, in start_running
    self.comp.warm_up()
  File "c:\python\lib\site-packages\coconut\compiler\compiler.py", line 2501, in warm_up
    result = self.parse_any("")
  File "c:\python\lib\site-packages\coconut\compiler\compiler.py", line 2497, in parse_any
    return self.parse(inputstring, self.file_parser, {"strip": True}, {"header": "none", "initial": "none", "final_endline": False})
  File "c:\python\lib\site-packages\coconut\compiler\compiler.py", line 776, in parse
    with logger.gather_parsing_stats():
  File "c:\python\lib\contextlib.py", line 117, in __enter__
    return next(self.gen)
  File "c:\python\lib\site-packages\coconut\terminal.py", line 310, in gather_parsing_stats
    start_time = time.clock()
AttributeError: module 'time' has no attribute 'clock'
(you should report this at https://github.com/evhub/coconut/issues/new)
Exiting due to AttributeError.

Then tried coconut --verbose and got what appears to be the same output (perhaps its the same command?)

C:\Users\Bruce
>coconut --verbose
Using Cython cPyparsing v2.4.5.
Parsed args: Namespace(source=None, dest=None, target=None, interact=False, package=False, standalone=False, line_numbers=False, keep_lines=False, watch=False, run=False, no_write=False, display=False, quiet=False, strict=False, no_tco=False, no_wrap=False, code=None, jobs=None, force=False, minify=False, jupyter=None, mypy=None, argv=None, tutorial=False, documentation=False, style=None, history_file=None, recursion_limit=None, verbose=True, trace=False)
Compiler args: {'target': '', 'strict': False, 'minify': False, 'line_numbers': False, 'keep_lines': False, 'no_tco': False, 'no_wrap': False}
Coconut Interpreter:
(enter 'exit()' or press Ctrl-D to end)
Traceback (most recent call last):
  File "c:\python\lib\site-packages\coconut\command\command.py", line 294, in handling_exceptions
    yield
  File "c:\python\lib\site-packages\coconut\command\command.py", line 130, in cmd
    self.use_args(parsed_args, interact, original_args=args)
  File "c:\python\lib\site-packages\coconut\command\command.py", line 272, in use_args
    self.start_prompt()
  File "c:\python\lib\site-packages\coconut\command\command.py", line 539, in start_prompt
    self.start_running()
  File "c:\python\lib\site-packages\coconut\command\command.py", line 531, in start_running
    self.comp.warm_up()
  File "c:\python\lib\site-packages\coconut\compiler\compiler.py", line 2501, in warm_up
    result = self.parse_any("")
  File "c:\python\lib\site-packages\coconut\compiler\compiler.py", line 2497, in parse_any
    return self.parse(inputstring, self.file_parser, {"strip": True}, {"header": "none", "initial": "none", "final_endline": False})
  File "c:\python\lib\site-packages\coconut\compiler\compiler.py", line 776, in parse
    with logger.gather_parsing_stats():
  File "c:\python\lib\contextlib.py", line 117, in __enter__
    return next(self.gen)
  File "c:\python\lib\site-packages\coconut\terminal.py", line 310, in gather_parsing_stats
    start_time = time.clock()
AttributeError: module 'time' has no attribute 'clock'
(you should report this at https://github.com/evhub/coconut/issues/new)
Exiting due to AttributeError.

evhub added a commit that referenced this issue Dec 23, 2020
@evhub
Copy link
Owner

evhub commented Dec 23, 2020

@BruceEckel This should now be fixed on the latest coconut-develop; just pip install -U coconut-develop>=1.4.3-post_dev63 to get the fix.

@evhub evhub closed this as completed Dec 23, 2020
@evhub evhub added the resolved label Dec 23, 2020
@BruceEckel
Copy link
Author

BruceEckel commented Dec 23, 2020 via email

@BruceEckel
Copy link
Author

When I ran that command a second time it seemed to work. Now the command just hangs:

>coconut-develop
Coconut Interpreter:
(enter 'exit()' or press Ctrl-D to end)
>>> range(1,10) |> reduce$(*, initializer = 1000) |> print


KeyboardInterrupt
>>> range(1,10) |> reduce$(*, initializer = 1000) |> print

CoconutParseError: parsing failed (line 1)
  range(1,10) |> reduce$(*, initializer = 1000) |> print
>>>

KeyboardInterrupt
>>>

@evhub
Copy link
Owner

evhub commented Dec 23, 2020

@BruceEckel You should be able to safely ignore the first error you saw on pip installation. As for the second error, I can't seem to replicate it. Can you show me what happens if you run coconut-develop --verbose instead of just coconut-develop?

Also, fwiw, in case you're wondering what the correct syntax is for that command, you're looking for range(1,10) |> reduce$((*), initializer = 1000) |> print.

@BruceEckel
Copy link
Author

>coconut-develop --verbose
Version 1.4.3-post_dev63 [Ernest Scribbler] running on Python 3.9.1 and Cython cPyparsing v2.4.5.0.1.2
Parsed args: Namespace(source=None, dest=None, target=None, interact=False, package=False, standalone=False, line_numbers=False, keep_lines=False, watch=False, run=False, no_write=False, display=False, quiet=False, strict=False, no_tco=False, no_wrap=False, code=None, jobs=None, force=False, minify=False, jupyter=None, mypy=None, argv=None, tutorial=False, documentation=False, style=None, history_file=None, recursion_limit=None, verbose=True, trace=False)
Compiler args: {'target': '', 'strict': False, 'minify': False, 'line_numbers': False, 'keep_lines': False, 'no_tco': False, 'no_wrap': False}
Coconut Interpreter:
(enter 'exit()' or press Ctrl-D to end)
Time while parsing: 0.546875 seconds
Packrat parsing stats: 192 hits; 1421 misses
Compiler args: {'target': '38', 'strict': False, 'minify': False, 'line_numbers': False, 'keep_lines': False, 'no_tco': False, 'no_wrap': False}
>>> range(1,10) |> reduce$(*, initializer = 1000) |> print
Time while parsing: 0.25 seconds
Packrat parsing stats: 2071 hits; 47324 misses


KeyboardInterrupt
>>> range(1,10) |> reduce$(*, initializer = 1000) |> print
Time while parsing: 0.296875 seconds
Packrat parsing stats: 2071 hits; 47324 misses

It just hangs.

When I tried your corrected syntax, I got:

>>> range(1,10) |> reduce$((*), initializer = 1000) |> print
Time while parsing: 0.1875 seconds
Packrat parsing stats: 1128 hits; 36047 misses
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: reduce() takes no keyword arguments
>>>

@evhub
Copy link
Owner

evhub commented Dec 24, 2020

@BruceEckel No idea why that's hanging for you—I'm running the same command on the same Coconut/Python/cPyparsing version and it gives a parse error as desired. Perhaps there's something wrong with your cPyparsing installation? You could try pip uninstall cPyparsing and then pip install -U coconut-develop cPyparsing. Alternatively, you could try just using pure Python pyparsing instead and run pip uninstall cPyparsing and pip install -U pyparsing.

As for the error with the corrected syntax, that error is exactly what should happen there, since reduce doesn't accept keyword arguments. You should be able to just do range(1,10) |> reduce$((*), ?, 1000) |> print instead, though.

@BruceEckel
Copy link
Author

It looks like a dependency may be overconstrained:

>pip install -U coconut-develop cPyparsing
Requirement already satisfied: coconut-develop in c:\python\lib\site-packages (1.4.3.post0.dev66)
Requirement already satisfied: pygments>=2.3 in c:\python\lib\site-packages (from coconut-develop) (2.7.2)
Requirement already satisfied: prompt-toolkit>=1 in c:\python\lib\site-packages (from coconut-develop) (3.0.8)
Collecting cPyparsing
  Using cached cPyparsing-2.4.5.0.1.2-cp39-cp39-win_amd64.whl (691 kB)
Requirement already satisfied: wcwidth in c:\python\lib\site-packages (from prompt-toolkit>=1->coconut-develop) (0.2.5)
Installing collected packages: cPyparsing
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
coconut 1.4.3 requires cPyparsing<2.4.5.0.1.2,>=2.4.5.0.1.1; platform_python_implementation == "CPython", but you have cpyparsing 2.4.5.0.1.2 which is incompatible.
Successfully installed cPyparsing-2.4.5.0.1.2

And the ? is what I've been hunting for. It's the equivalent of Kotlin's it, but I didn't know whether coconut supported it. Thanks!

@BruceEckel
Copy link
Author

Also when I tried the cPyparsing update with the regular (not coconut-develop) version:

>pip install -U coconut cPyparsing
Requirement already satisfied: coconut in c:\python\lib\site-packages (1.4.3)
Requirement already satisfied: cPyparsing in c:\python\lib\site-packages (2.4.5.0.1.2)
Requirement already satisfied: pygments>=2.3.1 in c:\python\lib\site-packages (from coconut) (2.7.2)
Requirement already satisfied: prompt-toolkit>=1 in c:\python\lib\site-packages (from coconut) (3.0.8)
Collecting cPyparsing
  Using cached cPyparsing-2.4.5.0.1.1.tar.gz (817 kB)
Requirement already satisfied: wcwidth in c:\python\lib\site-packages (from prompt-toolkit>=1->coconut) (0.2.5)
Using legacy 'setup.py install' for cPyparsing, since package 'wheel' is not installed.
Installing collected packages: cPyparsing
  Attempting uninstall: cPyparsing
    Found existing installation: cPyparsing 2.4.5.0.1.2
    Uninstalling cPyparsing-2.4.5.0.1.2:
      Successfully uninstalled cPyparsing-2.4.5.0.1.2
    Running setup.py install for cPyparsing ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\python\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Bruce\\AppData\\Local\\Temp\\pip-install-y1fezzqq\\cpyparsing_a260a431a101420facbd517eb27ccbf2\\setup.py'"'"'; __file__='"'"'C:\\Users\\Bruce\\AppData\\Local\\Temp\\pip-install-y1fezzqq\\cpyparsing_a260a431a101420facbd517eb27ccbf2\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Bruce\AppData\Local\Temp\pip-record-fxiim421\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\python\Include\cPyparsing'
         cwd: C:\Users\Bruce\AppData\Local\Temp\pip-install-y1fezzqq\cpyparsing_a260a431a101420facbd517eb27ccbf2\
    Complete output (12 lines):
    WARNING: The wheel package is not available.
    running install
    running build
    running build_ext
    building 'cPyparsing' extension
    creating build
    creating build\temp.win-amd64-3.9
    creating build\temp.win-amd64-3.9\Release
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\python\include -Ic:\python\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um /TccPyparsing.c /Fobuild\temp.win-amd64-3.9\Release\cPyparsing.obj
    cPyparsing.c
    c:\python\include\pyconfig.h(59): fatal error C1083: Cannot open include file: 'io.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.27.29110\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
    ----------------------------------------
  Rolling back uninstall of cPyparsing
  Moving to c:\python\lib\site-packages\cpyparsing-2.4.5.0.1.2.dist-info\
   from C:\Python\Lib\site-packages\~pyparsing-2.4.5.0.1.2.dist-info
  Moving to c:\python\lib\site-packages\cpyparsing.cp39-win_amd64.pyd
   from C:\Users\Bruce\AppData\Local\Temp\pip-uninstall-k9uortvs\cpyparsing.cp39-win_amd64.pyd
ERROR: Command errored out with exit status 1: 'c:\python\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Bruce\\AppData\\Local\\Temp\\pip-install-y1fezzqq\\cpyparsing_a260a431a101420facbd517eb27ccbf2\\setup.py'"'"'; __file__='"'"'C:\\Users\\Bruce\\AppData\\Local\\Temp\\pip-install-y1fezzqq\\cpyparsing_a260a431a101420facbd517eb27ccbf2\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Bruce\AppData\Local\Temp\pip-record-fxiim421\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\python\Include\cPyparsing' Check the logs for full command output.

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