question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Maximum number of arguments in Python

See original GitHub issue

Hey! Quoting your documentation,

When I say it supports everything I really mean everything:

I hate to be that guy, but I’m using your library (which is really amazing, by the way) and I actually encountered this issue in a poorly designed JS file. Reproduction:

test_str = "arr = new Array({})".format(','.join([str(x) for x in range(257)]))
import js2py
ctx = js2py.EvalJs()
ctx.execute(test_str)

💥

Traceback (most recent call last):
  File "/home/liam/.virtualenvs/scraper/lib/python3.5/site-packages/js2py/evaljs.py", line 171, in execute
    compiled = cache[hashkey]
KeyError: b'bT(\xc0iho\x10\xc1q\xe6\x8c\xd1 \xe8U'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/liam/.virtualenvs/scraper/lib/python3.5/site-packages/js2py/evaljs.py", line 174, in execute
    compiled = cache[hashkey] = compile(code, '<EvalJS snippet>', 'exec')
  File "<EvalJS snippet>", line 3
SyntaxError: more than 255 arguments

I guess not much you can do, right? Maybe document it?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:19 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
PiotrDabkowskicommented, Nov 18, 2016

There is no point solving this specific issue, there are much more edge cases which are almost impossible to solve with the current approach - eg recursion limit of python. I will solve all the problems by implementing a proper interpreter.

0reactions
hut8commented, Nov 17, 2016

Hey @PiotrDabkowski looks like this thread got pretty off-topic. My use case is actually for Arrays only. I think that one AST transformation here would suffice. Specifically, if you could change:

Array( ... ) ➡️ [ ... ]

that would solve my real-life problem 😄 I’m not a JS guru like yourself, but I believe array literals and the Array constructor are exactly equivalent. I’ve done this in the interim for the project I’m working on but I used a horrible regex hack that I’m pretty ashamed of.

For the actual code that I was testing to crash this, it was at: http://www.startimes.com/f.aspx?t=36588040 (check out var topics = Array(...). The code is so poorly architected that this simple web scraping project I’m working on turned into what felt like cryptanalysis 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is a maximum number of arguments in a Python function?
In Python 3.7 and newer, there is no limit. This is the result of work done in issue #27213 and issue #12844; #27213...
Read more >
4 Examples to Learn Python Max function - jQuery-AZ
The max() function is used to return the maximum value for two or more arguments passed to it. If an iterable like a...
Read more >
Python - Advanced Parameter Handling For Functions
Python lets us define a function that handles an unknown and unlimited number of argument values. Examples of built-in functions with a unlimited...
Read more >
Are there guidelines on how many parameters a function ...
The ideal number of arguments for a function is zero (niladic). Next comes one (monadic), followed closely by two (dyadic). Three arguments (triadic)...
Read more >
Python max() - Programiz
The max() function returns the largest item in an iterable. It can also be used to find the largest item between two or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found