py-make
py-make copied to clipboard
Demonstrating py2.6 shlex madness
On python 2.6, shlex fails miserably the unit test because it inserts null characters after each character of any command read from the Makefile:
>> assert ("hello world" in u'[\'k\\x00e\\x00y\\x00b\\x00o\\x00a\\x00r\\x00d\\x
00m\\x00a\\x00s\\x00h\\x00i\\x00t\\x00a\\x00l\\x00l\\x00t\\x00o\\x00g\\x00e\\x00
t\\x00h\\x00e\\x00r\\x00t\\x00h\\x00i\\x00s\\x00s\\x00h\\x00o\\x00u\\x00l\\x00d\
\x00n\\x00o\\x00t\\x00r\\x00u\\x00n\\x00o\\x00t\\x00h\\x00e\\x00r\\x00w\\x00i\\x
00s\\x00e\\x00u\\x00n\\x00i\\x00t\\x00t\\x00e\\x00s\\x00t\\x00s\\x00w\\x00i\\x00
l\\x00l\\x00f\\x00a\\x00i\\x00l\']\r\nkeyboardmashitalltogetherthisshouldnotruno
therwiseunittestswillfail\r\nTraceback (most recent call last):\r\n File "<stri
ng>", line 1, in <module>\r\n File "pymake\\_main.py", line 56, in main\r\n
ignore_errors=opts[\'--ignore-errors\'])\r\n File "pymake\\_pymake.py", line 16
7, in execute_makefile_commands\r\n check_call(parsed_cmd)\r\n File "c:\\pyt
hon26\\lib\\subprocess.py", line 483, in check_call\r\n retcode = call(*popen
args, **kwargs)\r\n File "c:\\python26\\lib\\subprocess.py", line 470, in call\
r\n return Popen(*popenargs, **kwargs).wait()\r\n File "c:\\python26\\lib\\s
ubprocess.py", line 623, in __init__\r\n errread, errwrite)\r\n File "c:\\py
thon26\\lib\\subprocess.py", line 833, in _execute_child\r\n startupinfo)\r\n
TypeError: CreateProcess() argument 2 must be string without null bytes or None,
not str\r\n')
If you look carefully, this:
'k\\x00e\\x00y\\x00b\\x00o\\x00a\\x00r\\x00d\\x
00m\\x00a\\x00s\\x00h\\x00i\\x00t\\x00a\\x00l\\x00l\\x00t\\x00o\\x00g\\x00e\\x00
t\\x00h\\x00e\\x00r\\x00t\\x00h\\x00i\\x00s\\x00s\\x00h\\x00o\\x00u\\x00l\\x00d\
\x00n\\x00o\\x00t\\x00r\\x00u\\x00n\\x00o\\x00t\\x00h\\x00e\\x00r\\x00w\\x00i\\x
00s\\x00e\\x00u\\x00n\\x00i\\x00t\\x00t\\x00e\\x00s\\x00t\\x00s\\x00w\\x00i\\x00
l\\x00l\\x00f\\x00a\\x00i\\x00l\'
Is in fact the same as:
keyboardmashitalltogetherthisshouldnotruno therwiseunittestswillfail
But with null characters between each character.
I tried everything I could, but I could not overcome this issue. It does not happen on newer versions of Python.
See this issue for more details. A possible alternative here (but it does not support comments yet) and also interesting reads here and here.
Coverage increased (+0.2%) to 95.935% when pulling f940f353fa54da41699a4f5c5e5e4a3cc8f8f337 on py2-shlex-madness into e7cbe64022c8f137b2deef3e600aea8380ddf476 on master.
Current coverage is 93.49% (diff: 78.94%)
@@ master #3 diff @@
==========================================
Files 6 6
Lines 118 123 +5
Methods 0 0
Messages 0 0
Branches 25 24 -1
==========================================
+ Hits 111 115 +4
- Misses 4 5 +1
Partials 3 3
Powered by Codecov. Last update b882682...f940f35