FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Boolean object property in Python function parameter · Issue #24 · Submersible/node-python-bridge · GitHub

Repository navigation

Boolean object property in Python function parameter #24

Description

var s = {
    a: "asd",
    b: 1,
    c: true,
};

let rtn = await python`print(${s})`;

The s.c parameter leads to an exception thrown. Strings/numbers work, arrays as well. Only boolean and null values (including NaN) throw errors:

(node:4232) UnhandledPromiseRejectionWarning: Error: Traceback (most recent call last):
  File "...\node_modules\python-bridge\node_python_bridge.py", line 94, in <module>
    value = eval(_compile(data['code'], '<input>', 'eval'), _locals)
  File "<input>", line 1, in <module>
NameError: name 'true' is not defined

The easiest solution I found was to adapt _locals, but I have no idea if that leads to other problems (maybe also for Infinity/NaN?):

_locals = {'__name__': '__console__', '__doc__': None, 'true': True, 'false': False, 'null': None}

The cleaner solution could be to use json.loads to convert JSON input strings to a Python dict?

Activity

  1. added a commit that references this issue on Mar 21, 2019
  2. munro commented on Mar 21, 2019

    Member

    Fixed in python-bridge@1.1.0 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL