Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git-restore-mtime fails on python 3 (3.4 and 3.5) #23

Closed
gebailey opened this issue Apr 22, 2016 · 2 comments
Closed

git-restore-mtime fails on python 3 (3.4 and 3.5) #23

gebailey opened this issue Apr 22, 2016 · 2 comments

Comments

@gebailey
Copy link
Contributor

I've packaged git-tools for Fedora and am now receiving bugzilla reports related to Python 3:
https://bugzilla.redhat.com/show_bug.cgi?id=1322472

I've created a sample git repo and am attempting to use git-restore-mtime on it using various python interpreters.

When running git-restore-mtime using the Python 3.4 interpreter, I get:

[gbailey@spock test]$ python3.4 -V
Python 3.4.4
[gbailey@spock test]$ python3.4 /usr/bin/git-restore-mtime 
Traceback (most recent call last):
  File "/usr/bin/git-restore-mtime", line 165, in <module>
    lsfileslist.add(os.path.relpath(line.strip(), workdir))
  File "/usr/lib64/python3.4/posixpath.py", line 448, in relpath
    start_list = [x for x in abspath(start).split(sep) if x]
TypeError: Can't convert 'bytes' object to str implicitly

When running git-restore-mtime using the Python 3.5 interpreter, I get:

[gbailey@spock test]$ python3.5 -V
Python 3.5.1
[gbailey@spock test]$ python3.5 /usr/bin/git-restore-mtime 
Traceback (most recent call last):
  File "/usr/bin/git-restore-mtime", line 165, in <module>
    lsfileslist.add(os.path.relpath(line.strip(), workdir))
  File "/usr/lib64/python3.5/posixpath.py", line 459, in relpath
    genericpath._check_arg_types('relpath', path, start)
  File "/usr/lib64/python3.5/genericpath.py", line 145, in _check_arg_types
    raise TypeError("Can't mix strings and bytes in path components") from None
TypeError: Can't mix strings and bytes in path components
gebailey added a commit to gebailey/git-tools that referenced this issue Dec 20, 2016
MestreLion#23

git-restore-mtime fails on python3 since output from subprocesses is
interpreted as bytes instead of strings.

Modify calls to subprocess methods to pass "universal_newlines=True", so that
output is returned as strings instead, which more closely resembles how python2
interprets things.  This also allows the script to still run on python2 as the
"universal_newlines" keyword is ignored.

With this change, there's no need for the python2 vs. python3 text() method, so
its definition and usages were removed as well.

Tested on Linux: python 2.7, python 3.4, python 3.5
@Coacher
Copy link

Coacher commented Apr 9, 2017

Same here on Gentoo linux.

@MestreLion
Copy link
Owner

Fixed by PR #26

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

No branches or pull requests

3 participants