Exceptions when accessing undefined values in Bridged Dicts
adamlwgriffiths opened this issue · 0 comments
adamlwgriffiths commented
I'm trying to implement functionality in the Router beyond just the routes
property.
Specifically, the beforeEach
function.
Using the router example from the documentation, I modify it like so:
router = Router()
def before_each(to_, from_, next):
print(f'before_each({to_}, {from_}, {next})')
print(f'type(to_) = {type(to_)}')
print(f'type(from_) = {type(from_)}')
print(f'to_.keys() = {to_.keys()}')
print(f'to_.values() = {to_.values()}')
print(f'to_.items() = {to_.items()}')
next()
router.beforeEach(pyjs_bridge(before_each))
The output of this is:
before_each([object Window], [object Window], <function >)
brython.min.js:1 type(to_) = <class 'vue.bridge.dict.Dict'>
brython.min.js:1 type(from_) = <class 'vue.bridge.dict.Dict'>
brython.min.js:1 to_.keys() = ('name', 'meta', 'path', 'hash', 'query', 'params', 'fullPath', 'matched')
vue-router.js:22 [vue-router] uncaught error during route navigation:
vue-router.js:2322 name
at Object._b_.AttributeError.$factory (eval at $B.$make_exc (https://cdn.jsdelivr.net/npm/brython@3.10.6/brython.min.js:1:327985), <anonymous>:3:15)
at Object.$B.attr_error (https://cdn.jsdelivr.net/npm/brython@3.10.6/brython.min.js:1:330533)
at $B.JSObj.__getattribute__ (https://cdn.jsdelivr.net/npm/brython@3.10.6/brython.min.js:1:402240)
at Object.$B.$getattr (https://cdn.jsdelivr.net/npm/brython@3.10.6/brython.min.js:1:273895)
at getattr (https://cdn.jsdelivr.net/npm/brython@3.10.6/brython.min.js:1:267994)
at __getitem__497 (eval at run_py (https://cdn.jsdelivr.net/npm/brython@3.10.6/brython.min.js:1:414511), <anonymous>:251:99)
at Object.$B.$getitem (https://cdn.jsdelivr.net/npm/brython@3.10.6/brython.min.js:1:221124)
at eval (eval at run_py (https://cdn.jsdelivr.net/npm/brython@3.10.6/brython.min.js:1:414511), <anonymous>:878:11)
at Generator.next (<anonymous>)
at Object.$B.generator.send (https://cdn.jsdelivr.net/npm/brython@3.10.6/brython.min.js:1:643756)
vue-router.js:2286 Uncaught (in promise) name
at Object._b_.AttributeError.$factory (eval at $B.$make_exc (https://cdn.jsdelivr.net/npm/brython@3.10.6/brython.min.js:1:327985), <anonymous>:3:15)
at Object.$B.attr_error (https://cdn.jsdelivr.net/npm/brython@3.10.6/brython.min.js:1:330533)
at $B.JSObj.__getattribute__ (https://cdn.jsdelivr.net/npm/brython@3.10.6/brython.min.js:1:402240)
at Object.$B.$getattr (https://cdn.jsdelivr.net/npm/brython@3.10.6/brython.min.js:1:273895)
at getattr (https://cdn.jsdelivr.net/npm/brython@3.10.6/brython.min.js:1:267994)
at __getitem__497 (eval at run_py (https://cdn.jsdelivr.net/npm/brython@3.10.6/brython.min.js:1:414511), <anonymous>:251:99)
at Object.$B.$getitem (https://cdn.jsdelivr.net/npm/brython@3.10.6/brython.min.js:1:221124)
at eval (eval at run_py (https://cdn.jsdelivr.net/npm/brython@3.10.6/brython.min.js:1:414511), <anonymous>:878:11)
at Generator.next (<anonymous>)
at Object.$B.generator.send (https://cdn.jsdelivr.net/npm/brython@3.10.6/brython.min.js:1:643756)
As you can see, any attempt to access the values (it seems to be specifically the 'name' value in this case) causes issues.
However, I am able to get out the values the VueRoute actually defined.
Ie. using:
print(f'to_["path"] = {to_["path"]}')
print(f'to_.get("component") = {to_.get("component")}')
Doesn't cause an exception and does lead to output
to_["path"] = /page1
to_.get("component") = None