GithubHelp home page GithubHelp logo

Comments (4)

Brobin avatar Brobin commented on May 28, 2024

Replicated again with the following:

rtv -l http://www.reddit.com/r/linuxmasterrace/comments/316in4/even_rpcmasterrace_knows_you_should_be_running/

Trace

File "build/bdist.linux-x86_64/egg/rtv/page.py", line 293, in _draw_content
  File "build/bdist.linux-x86_64/egg/rtv/submission.py", line 125, in draw_item
  File "build/bdist.linux-x86_64/egg/rtv/submission.py", line 148, in draw_comment
UnicodeEncodeError: 'ascii' codec can't encode character u'\u15e7' in position 15: ordinal not in range(128)

In this example, it is crashing becuase the flair contains a unicode character Antergos [sudo α—§ -Syu]

I'm not sure exactly why this is happening. In helpers.py we set the error handling to 'replace' which should replace the unicode characters with ascii placeholders

encoding = 'utf-8' if config.unicode else 'ascii'
string = string.encode(encoding, 'replace')

from rtv.

Brobin avatar Brobin commented on May 28, 2024

I think the issue might be formatting the string before calling the clean method

Changing line 148 of submission.py

text = clean('{flair} '.format(**data))

To this

text = '{0} '.format(clean(data['flair']))

Resolves the problem.

from rtv.

michael-lazar avatar michael-lazar commented on May 28, 2024

Yup you're right, I just figured this out as well.

Calling '{flair}'.format(**data) in python2 tries to convert the unicode data to a native string before formatting it. You need to explicitly mark the type as unicode.

clean(u'{flair} '.format(**data))

09c4865. Thanks for the detailed bug report.

from rtv.

Brobin avatar Brobin commented on May 28, 2024

Looks good. I'm glad I could help πŸ‘

from rtv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.