Using hg command line with Py3 does not work.

Jurko Gospodnetić avatarJurko Gospodnetić created an issue

When you use the hg command line, data returned by the subprocess.POpen object's communicate() function are byte streams. Because of that, calling splitline() on them returns a list of file names as bytes objects.

Later on when setuptools tries to do some regexs pattern matching on those file names you get an exception 'TypeError: can't use a string pattern on a bytes-like object'.

Stack trace:

File "C:\Program Files\Python\Python32\lib\site-packages\distribute-0.6.24-py3.2.egg\setuptools\command\egg_info.py", line 179, in run
    self.find_sources()
  File "C:\Program Files\Python\Python32\lib\site-packages\distribute-0.6.24-py3.2.egg\setuptools\command\egg_info.py", line 254, in find_sources

    mm.run()
  File "C:\Program Files\Python\Python32\lib\site-packages\distribute-0.6.24-py3.2.egg\setuptools\command\egg_info.py", line 311, in run
    self.prune_file_list()
  File "C:\Program Files\Python\Python32\lib\site-packages\distribute-0.6.24-py3.2.egg\setuptools\command\egg_info.py", line 346, in prune_file_l
ist
    self.filelist.exclude_pattern(None, prefix=build.build_base)
  File "C:\Program Files\Python\Python32\lib\distutils\filelist.py", line 235, in exclude_pattern
    if pattern_re.search(self.files[i]):
TypeError: can't use a string pattern on a bytes-like object

I'm running this with Python 3.2.2 on Windows XP x86 SP3.

Used Python packages:

  • distribute 0.6.24
  • setuptools_hg 0.3

The issue can be quick-fixed in my case by replacing:

    return stdout.splitlines()

with

    return (x.decode('utf-8') for x in stdout.splitlines())

at the end of find_files_with_cmd() but I am pretty sure this is not a completely valid or clean fix.

Note that using the mercurial package with Py3 is not supported. :-(

Hope this helps, Jurko Gospodnetić

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.