Fix "sre_constants.error: bogus escape: '\\U'" on Windows#26
Fix "sre_constants.error: bogus escape: '\\U'" on Windows#26ColinDuquesnoy wants to merge 1 commit intodatafolklabs:masterfrom ColinDuquesnoy:bugfix/sre_constants_error
Conversation
Here is the traceback I had: ``` C:\Users\colin>boss create ./helloworld -t boss:python Project Description: Spam Project Name: Eggs Project Creator Email: smap@eggs.be Python Module Name: eggs Version: 1 License: MIT Project Url: http://spam-some.eggs Project Creator: EggSpammer Traceback (most recent call last): File "C:\Python34\Scripts\boss-script.py", line 9, in <module> load_entry_point('boss==0.9.20', 'console_scripts', 'boss')() File "C:\Python34\lib\site-packages\boss\cli\main.py", line 62, in main app.run() File "C:\Python34\lib\site-packages\cement\core\foundation.py", line 764, in run self.controller._dispatch() File "C:\Python34\lib\site-packages\cement\core\controller.py", line 472, in _dispatch return func() File "C:\Python34\lib\site-packages\boss\cli\controllers\base.py", line 73, in create src.create_from_template(source, template, self.app.pargs.extra[0]) File "C:\Python34\lib\site-packages\boss\cli\source.py", line 63, in create_from_template tmpl.copy(dest_dir) File "C:\Python34\lib\site-packages\boss\cli\template.py", line 269, in copy dest_path = fs.abspath(re.sub(self.basedir, dest_basedir, tmpl_path)) File "C:\Python34\lib\re.py", line 179, in sub return _compile(pattern, flags).sub(repl, string, count) File "C:\Python34\lib\re.py", line 294, in _compile p = sre_compile.compile(pattern, flags) File "C:\Python34\lib\sre_compile.py", line 568, in compile p = sre_parse.parse(p, flags) File "C:\Python34\lib\sre_parse.py", line 760, in parse p = _parse_sub(source, pattern, 0) File "C:\Python34\lib\sre_parse.py", line 370, in _parse_sub itemsappend(_parse(source, state)) File "C:\Python34\lib\sre_parse.py", line 730, in _parse code = _escape(source, this, state) File "C:\Python34\lib\sre_parse.py", line 361, in _escape raise error("bogus escape: %s" % repr(escape)) sre_constants.error: bogus escape: '\\U' C:\Users\colin> ``` My solution is simply to replace '\\' by '/'. This issue was originally reported in HackEdit/hackedit#14
|
The failing test is not related to this PR. It's just that coverage >= 4.0 doesn't support py32 anymore... |
|
Thank you for the pull request. Is this issue specific to the path, or is it broken using any standard path? |
|
Yes, it happens with any standard "windows" path. I tried with a few official boss templates and my owns, all failed with the same traceback. |
|
You can reproduce this bug with the following code: >>> basedir = r'C:\Users\reneg\.boss\cache\tmp0yyrefpr\python'
>>> tmpl = r'C:\Users\reneg\.boss\cache\tmp0yyrefpr\python\README.md'
>>> destir = 'D:\Documents\helloworld'
>>> import re
>>> re.sub(basedir, destdir, tmpl)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\re.py", line 179, in sub
return _compile(pattern, flags).sub(repl, string, count)
File "C:\Python34\lib\re.py", line 294, in _compile
p = sre_compile.compile(pattern, flags)
File "C:\Python34\lib\sre_compile.py", line 568, in compile
p = sre_parse.parse(p, flags)
File "C:\Python34\lib\sre_parse.py", line 760, in parse
p = _parse_sub(source, pattern, 0)
File "C:\Python34\lib\sre_parse.py", line 370, in _parse_sub
itemsappend(_parse(source, state))
File "C:\Python34\lib\sre_parse.py", line 730, in _parse
code = _escape(source, this, state)
File "C:\Python34\lib\sre_parse.py", line 361, in _escape
raise error("bogus escape: %s" % repr(escape))
sre_constants.error: bogus escape: '\\U'
>>>Running the boss test suite on windows lead to a test failing for the same reason: |
|
Thank you! I've finally learned how to get Windows up and running with Vagrant so I will be able to look into this now. Really appreciate the input. |
|
hi, I try to fix window path bug, #31 , I think re.sub parse '\' as a escape character , but we should consider *nix can have '\' character in a path. I don't think replace \ to / is good solution |
|
Better fix dest_path = fs.abspath(re.sub(self.basedir.replace('\', '/'), dest_basedir.replace('\', '/'), tmpl_path.replace('\', '/'))). |
Here is the traceback I had on Windows:
My solution is simply to replace
\\by/This issue was originally reported in HackEdit/hackedit#14