Opened 11 months ago

Closed 6 weeks ago

Last modified 6 weeks ago

#3565 closed task (fixed)

Porting Python Scripting Library to Python 3

Reported by: annakrat Owned by: grass-dev@…
Priority: normal Milestone: 7.8.0
Component: Python Version: svn-trunk
Keywords: gsoc2018, python3 Cc:
CPU: Unspecified Platform: All

Description

This ticket is created to gather comments and patches to port this library to Python 3 as part of GSoC 2018.

Related pages:

trac wiki page on Python3 porting

GSoC 2018

Attachments (3)

patch_utils_sanjeet.diff (2.2 KB) - added by annakrat 11 months ago.
patch for lib/python/script/utils.py and tests by Sanjeet
patch_utils_encode_decode_only_text.diff (4.3 KB) - added by annakrat 11 months ago.
encode and decode functions changed to accept only text, otherwise throw error
patch_core_run_command_unicode.diff (2.8 KB) - added by sanjeet 11 months ago.
Hi, Here is a quick dirty patch to know if this is what you meant when you said we need to have 'encoding' parameter passed to our functions. For now, I have only added this conversion in the 'run_command()'. I am just using the encoding parameter directly from kwargs instead of passing it as a keyword argument in the functions definiton. It is being popped from the kwargs dictionary so as not to pass it to the next function in line. I thought, in the similar manner we could call the 'make_unicode()' in other functions (read_command, make_command, start_command,...) where they can make use of it if they are called directly from the scripts instead of other functions. Is this correct?

Download all attachments as: .zip

Change History (7)

Changed 11 months ago by annakrat

Attachment: patch_utils_sanjeet.diff added

patch for lib/python/script/utils.py and tests by Sanjeet

Changed 11 months ago by annakrat

encode and decode functions changed to accept only text, otherwise throw error

comment:1 Changed 11 months ago by annakrat

I changed Sanjeet's patch to change the behavior of encode and decode functions in utils.py, so that they don't accept anything else than string or bytes with Python3. Before they could be used with int, floats and None, but it's supposed to do encoding/decoding not converting, that should be done explicitly. To not break existing code, new behavior is only with Python 3.

Changed 11 months ago by sanjeet

Hi, Here is a quick dirty patch to know if this is what you meant when you said we need to have 'encoding' parameter passed to our functions. For now, I have only added this conversion in the 'run_command()'. I am just using the encoding parameter directly from kwargs instead of passing it as a keyword argument in the functions definiton. It is being popped from the kwargs dictionary so as not to pass it to the next function in line. I thought, in the similar manner we could call the 'make_unicode()' in other functions (read_command, make_command, start_command,...) where they can make use of it if they are called directly from the scripts instead of other functions. Is this correct?

comment:2 Changed 11 months ago by annakrat

Actually what I meant is using the encoding parameter only for stdin, stderr and stdout, the same way as Python Popen class. The arguments are already being encoded in start_command function. BTW, if you submit a patch, it should somehow work, I can see just by looking at it that it can't work. Or call it pseudocode in that case.

comment:3 Changed 6 weeks ago by martinl

Resolution: fixed
Status: newclosed

Reported issue solved, see ongoing development in trunk.

comment:4 Changed 6 weeks ago by martinl

Milestone: 8.0.07.8.0
Note: See TracTickets for help on using tickets.