Skip to content

Conversation

@philippjfr
Copy link
Contributor

The problem here was that it was calling type.__repr__ which is missing the self argument. Instead we should simply call repr(type). There is however a secondary problem, which is that since we are rendering straight to the DOM the < and > in the type repr get taken as an HTML tag and we still don't get any output. We will have to consider whether to always escape < and > when rendered into the DOM which would unfortunately mean that we cannot have strings be directly interpreted as HTML (e.g. breaking @pzwang's rick-roll demo in the PyCon keynote).

Partially Fixes #120

@philippjfr philippjfr added the status: ready PR that is ready for review label May 2, 2022
@philippjfr philippjfr requested a review from fpliger May 2, 2022 16:44
@fpliger
Copy link
Contributor

fpliger commented May 3, 2022

That's a great topic....

My 2 cents is that we should provide ways for users to decide what they want to do on 2 levels: the pyscript component level (with an attribute to <py-script>, <py-repl> and any other element that outputs to the dom. The attribute could be auto-escape or something like that) and on the Higher level language level (that users can call directly wrapping their output). What do you think @philippjfr @pzwang ?

@philippjfr
Copy link
Contributor Author

I agree that configurability is probably our only way out of this problem. Let's open another issue about this and then merge this PR because this fix is independent of that issue.

@fpliger fpliger added status: accepted PR that has been reviewed and accepted and removed status: ready PR that is ready for review labels May 4, 2022
Copy link
Contributor

@fpliger fpliger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@fpliger fpliger merged commit 9011f86 into main May 4, 2022
@fpliger fpliger deleted the repr_type_fix branch May 4, 2022 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: accepted PR that has been reviewed and accepted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running the type() function inside the pyscript raises a JsException

3 participants