Skip to content

cgi.escape is deprecated in python 3.4 - #330

Merged
dddomodossola merged 1 commit into
rawpython:masterfrom
Bethany-1:patch-1
Aug 16, 2019
Merged

dddomodossola merged 1 commit into
rawpython:masterfrom
Bethany-1:patch-1

Conversation

@Bethany-1

Copy link
Copy Markdown
Contributor

While setting up the unit test for the Label widget, this bug was found for python 3.4 +:

DeprecationWarning: cgi.escape is deprecated, use html.escape instead

A possible fix is to conditionally import escape like unescape.

cgi.escape is deprecated in python 3.4 and was printing out a warning message.
@dddomodossola

Copy link
Copy Markdown
Collaborator

Thank you a lot @Bethany-1 . Before to merge, are you sure that html.escape is equivalent to cgi.escape?

@Bethany-1

Copy link
Copy Markdown
Contributor Author

Hi @dddomodossola ,

Yes, they have the same functionalities. They both convert characters &, < and > in string to HTML safe sequences.

@dddomodossola
dddomodossola merged commit 32d9b8a into rawpython:master Aug 16, 2019
@dddomodossola

Copy link
Copy Markdown
Collaborator

Merge done @Bethany-1 thank you for the fix.

@Bethany-1

Copy link
Copy Markdown
Contributor Author

Hi @dddomodossola ,
It turns out that html.escape and cgi.escape don't have the same functionality. html.escape defaults to also escaping the quote character. As this is only being used for html text nodes, the resulting text will be the same but the transmitted html will be different. Should we explicitly write quote=True or quote=False?

@dddomodossola

Copy link
Copy Markdown
Collaborator

Hello @Bethany-1 , i suggest to specify quote=False to have the same behaviour of cgi.escape. It was largely tested in remi and we must maintain backward compatibility.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants