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

unused templates crashes in case of 2.7 if python source countains certain string literal with backslash in it #5

Open
MrCsabaToth opened this issue Jun 28, 2018 · 0 comments

Comments

@MrCsabaToth
Copy link

MrCsabaToth commented Jun 28, 2018

Some of our ancient source files contained strings like this:
r"C:\Users\AncientUser\Documents\whatever.csv"
Notice the r literal modifier. Upon scanning these, there is an exception in six. I'm not sure if this is six bug and even in that case it could be worked around in unused's end.

Finding all unused templates...
Getting global templates...
Done.
Getting app templates...
System check identified some issues:
Done.
Getting python files...
Done.
Creating Index.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................Traceback (most recent call last):
. File "/home/csaba/pycharm/helpers/pycharm/django_manage.py", line 52, in
run_command()
File "/home/csaba/pycharm/helpers/pycharm/django_manage.py", line 46, in run_command
run_module(manage_file, None, 'main', True)
File "/usr/lib/python2.7/runpy.py", line 188, in run_module
fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 82, in _run_module_code
mod_name, mod_fname, mod_loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/csaba/webapp/sportsboard/manage.py", line 15, in
execute_from_command_line(sys.argv)
File "/home/csaba/virtualenvs/live/local/lib/python2.7/site-packages/django/core/management/init.py", line 364, in execute_from_command_line
utility.execute()
File "/home/csaba/virtualenvs/live/local/lib/python2.7/site-packages/django/core/management/init.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/csaba/virtualenvs/live/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/csaba/virtualenvs/live/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/csaba/virtualenvs/live/local/lib/python2.7/site-packages/django_unused/management/commands/unused.py", line 24, in handle
find_unused_templates()
File "/home/csaba/virtualenvs/live/local/lib/python2.7/site-packages/django_unused/management/commands/_templates.py", line 70, in find_unused_templates
content=six.u('/n'.join(f.readlines())))
File "/home/csaba/virtualenvs/live/local/lib/python2.7/site-packages/six.py", line 653, in u
return unicode(s.replace(r'\', r'\\'), "unicode_escape")
UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 268-269: truncated \UXXXXXXXX escape
/home/csaba/virtualenvs/live/local/lib/python2.7/site-packages/backports/tempfile.py:61: RuntimeWarning: Implicitly cleaning up <TemporaryDirectory '/tmp/tmpZSCfP0'>

@MrCsabaToth MrCsabaToth changed the title unused templates crashes in case of 2.7 if python source countains string with backslash unused templates crashes in case of 2.7 if python source countains certain string literal with backslash in it Jun 28, 2018
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

1 participant