brython-dev / brython

Brython (Browser Python) is an implementation of Python 3 running in the browser
BSD 3-Clause "New" or "Revised" License
6.38k stars 510 forks source link

Brython Error on Linux - unable to load scripts #2052

Closed ceffiong closed 2 years ago

ceffiong commented 2 years ago

Hello,

I have the following error in a linux machine. I'm loading the scripts locally not from a CDN.

SyntaxError: identifier starts immediately after numeric literal[Learn More] brython.min.js:1:352189 ReferenceError: BRYTHON is not defined[Learn More] brython_stdlib.js:1:1 ReferenceError: brython is not defined[Learn More] localhost:5500:1:1

Is there a workaround for this?

Thanks

PierreQuentel commented 2 years ago

Hello,

Thanks for reporting this. I can't reproduce the bug, can you give an example of a complete HTML page that raises this error ?

ceffiong commented 2 years ago

Hi Pierre,

Sure:

index.html

<!doctype html>
<html lang="en">
    <head>
        <!-- Required meta tags -->
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- Bootstrap CSS -->
        <link href="./css/bootstrap.min.css" rel="stylesheet">

        <title>Custom Timing Collector</title>

        <script src="./js/brython.min.js">
        </script>
        <script src="./js/brython_stdlib.js">
        </script>
    </head>
    <body onload="brython()">
        <!-- A grey horizontal navbar that becomes vertical on small screens -->
        <nav class="navbar navbar-expand-sm bg-light">
            <div class="container-fluid">
            <!-- Links -->
            <ul class="navbar-nav">
                <li class="nav-item">
                    <h1>Custom timing results  </h1>
                </li>
            </ul>
            </div>
        </nav>

        <div class="container">

            <div id="megacells" style="margin-top: 30px; margin-bottom:30px;" class="list-group fs-6">
              <a href="#" class="list-group-item list-group-item-action active disabled">
                <h5>List of available megacells</h5>
              </a>
            </div>
            <div id="name"></div>
        </div>

        <script type="text/python" src="./py/main.py">
        </script>
        <h1>Megacell</h1>
        <ul id="megacells"></ul>

        <script src="./js/bootstrap.bundle.min.js"></script>

    </body>
</html>

main.py

from browser import document, window import webbrowser

def megacells():
    #megacell_list = os.walk(os.getcwd() + "/database").__next__()[1]
    #return list(reversed(megacell_list))
    return "Charles"

name = megacells()
document['name'].textContent = name

Device

$hostnamectl Static hostname: localhost.localdomain Transient hostname: * Icon name: computer-vm Chassis: vm Machine ID: Boot ID: * Virtualization: vmware Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-1062.1.2.el7.x86_64 Architecture: x86-64

Please let me know if you need additional information. You can remove all links to bootstrap for your test.

Regards,

PierreQuentel commented 2 years ago

The code ran without error for me.

But, from the position of the error message in brython.min.js, I suspect that it is because the Javascript engine you use does not support Javascript BigInt, and throws the error when it encounters Javascript code like

len = 1n

Do you have the possibility to upgrade the browser to a newer version ?

ceffiong commented 2 years ago

I tried a different browser and it also worked. I think the problem is the old default browser in cent os.

Thanks for looking into it. Regards

On Thu 29. Sep 2022 at 13:13, Pierre Quentel @.***> wrote:

The code ran without error for me.

But, from the position of the error message in brython.min.js, I suspect that it is because the Javascript engine you use does not support Javascript BigInt https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt, and throws the error when it encounters Javascript code like

len = 1n

Do you have the possibility to upgrade the browser to a newer version ?

— Reply to this email directly, view it on GitHub https://github.com/brython-dev/brython/issues/2052#issuecomment-1262131079, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAMEF2SFXVHOMVFWPBBF5LWAV2WJANCNFSM6AAAAAAQYG3E7E . You are receiving this because you authored the thread.Message ID: @.***>

--

====================

Charles EFFIONG, PhD

LinkedIn http://fr.linkedin.com/in/effiongcharles

PierreQuentel commented 2 years ago

I am closing the issue then. Thanks again !