Skip to content

Conversation

dagwieers
Copy link
Contributor

It appears that sys.argv exposes string literals while our module now
works exclusively with unicode literals. This is problematic for Python2
unicode processing.

This fixes #27

It appears that `sys.argv` exposes string literals while our module now
works exclusively with unicode literals. This is problematic for Python2
unicode processing.
@dagwieers
Copy link
Contributor Author

@tamland Can we get this merged? It fixes a real scenario where unicode characters are provided as arguments.

@dagwieers dagwieers mentioned this pull request Jan 15, 2020
@tamland
Copy link
Owner

tamland commented Jan 16, 2020

I doubt this fixes the problem. There are lots of string literals in the code, which in python 2 are not unicode but string. If you force sys.argv to unicode you would be mixing string and unicode again.

@dagwieers
Copy link
Contributor Author

dagwieers commented Jan 16, 2020

It fixes te following example in Python 2.7

#!/usr/bin/python

import sys
from routing import Plugin

plugin = Plugin()


@plugin.route('/video/<id>')
def video(id='12345'):
    print(id)

print(sys.argv[1:])
plugin.run(sys.argv[1:])

When running it with arguments: python test.py /video/fööbàr 1

If the calling script is using unicode_literals, this issue does not occur.

@mediaminister
Copy link

There are lots of string literals in the code, which in python 2 are not unicode but string. If you force sys.argv to unicode you would be mixing string and unicode again.

Since v0.2.2 import unicode_literals was added, so every string literal is unicode now in Python 2.

from __future__ import absolute_import, division, print_function, unicode_literals

@tamland
Copy link
Owner

tamland commented Jan 17, 2020

Got it.
@dagwieers Could you just add this example as a test case?

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.

error after upgrade from v0.2.1 to v0.2.3 in kodi

3 participants