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.

Issue with Symbol and BigInt from JavaScript

See original GitHub issue

In the following Python code standard JavaScript primitive types (BigInt and Symbol) are missed:

from browser import document, console
import javascript

n = javascript.BigInt(2) # AttributeError: 'module' object has no attribute 'BigInt'
s = javascript.Symbol("abracadabra") # AttributeError: 'module' object has no attribute 'Symbol'

Below the Stacktraces for both this lines

Missed BigInt:

Traceback (most recent call last):
  File http://localhost:63344/WebPython/index.html?_ijt=g7iau0hssgdgcripk8geh4d91s/__main__ line 17, in <module>
    n = javascript.BigInt(2) # Missed BigInt symbol
AttributeError: 'module' object has no attribute 'BigInt'
brython.js:5389 Uncaught Error
    at Object._b_.AttributeError.$factory (eval at $make_exc (brython.js:7929), <anonymous>:41:354)
    at attr_error (brython.js:6844)
    at Object.$B.$getattr (brython.js:6960)
    at eval (eval at $B.loop (brython.js:5368), <anonymous>:21:41)
    at $B.loop (brython.js:5368)
    at idb_load (brython.js:5288)
    at IDBRequest.req.onsuccess (brython.js:5302)

Missed Symbol:

Traceback (most recent call last):
  File http://localhost:63344/WebPython/index.html?_ijt=g7iau0hssgdgcripk8geh4d91s/__main__ line 17, in <module>
    s = javascript.Symbol("abracadabra") # Missed Symbol symbol
AttributeError: 'module' object has no attribute 'Symbol'
brython.js:5389 Uncaught Error
    at Object._b_.AttributeError.$factory (eval at $make_exc (brython.js:7929), <anonymous>:41:354)
    at attr_error (brython.js:6844)
    at Object.$B.$getattr (brython.js:6960)
    at eval (eval at $B.loop (brython.js:5368), <anonymous>:21:41)
    at $B.loop (brython.js:5368)
    at idb_load (brython.js:5288)
    at IDBRequest.req.onsuccess (brython.js:5302)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
PierreQuentelcommented, Sep 24, 2020

Yes, it works:

from browser import window

symbol = window.Symbol("test")
assert symbol.description == "test"
0reactions
redradistcommented, Sep 24, 2020

Yes, it works:

from browser import window

symbol = window.Symbol("test")
assert symbol.description == "test"

Cool !! Thanks, @PierreQuentel !!

Read more comments on GitHub >

github_iconTop Results From Across the Web

BigInt - JavaScript - MDN Web Docs
BigInt values represent numeric values which are too large to be represented by the number primitive.
Read more >
The Essential Guide To JavaScript's Newest Data Type: BigInt
The BigInt data type aims to enable JavaScript programmers to represent integer values larger than the range supported by the Number data ...
Read more >
BigInt in JavaScript - GeeksforGeeks
BigInt is a built-in object in JavaScript that provides a way to represent whole numbers larger than 2 53 -1.
Read more >
BigInt - The Modern JavaScript Tutorial
A bigint is created by appending n to the end of an integer literal or by calling the function BigInt that creates bigints...
Read more >
A guide to using BigInt - LogRocket Blog
BigInt is a relatively new numeric primitive/integer type in JavaScript. It was created to solve the limitations people ran into with the Number ......
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