------------------------------------------------------------------------------
To reply, visit https://hellosplat.com/s/beanbag/tickets/3843/
------------------------------------------------------------------------------

New update by mark*****@gmai***** (Google Code)
For Beanbag, Inc. > Review Board > Ticket #3843


Reply:

    Found the issue, we have mixed description in DB where some are ascii and 
some utf-8. We have a customization where we change the change description and 
commit it to perforce.
    
    There was an issue in our code where we were handling the description as 
string. It worked if the encoding was ascii as default python encoding is ascii 
but when the description had utf-8 encoding we were not decoding it as utf-8. 
Since we were doing some manipulation on the string like regex search and 
replace and split it was throwing errors.
    
    Therefore whereever we found the issue we fixed it and now we got a utf-8 
encoded changelist description which we wanted to update to perforce
    
    For that we use amend_commit_description. Problem with this function is 
uses plain text therefore it doesn't do encoding
    
    p.communicate(input_string)
    
    >>> Preparing to amend change --rbtools-pending-cln:549348
    >>> Running: p4 change -o 549348
    Traceback (most recent call last):
      File "/tmp/rbtool-for-mac/bin/rbt", line 24, in <module>
        load_entry_point(version_string, 'console_scripts', 'rbt')()
      File 
"/tmp/rbtool-for-mac/lib/RBTools/RBTools-0.7.5-py2.7.egg/rbtools/commands/main.py",
 line 133, in main
        command.run_from_argv([RB_MAIN, command_name] + args)
      File 
"/tmp/rbtool-for-mac/lib/RBTools/RBTools-0.7.5-py2.7.egg/rbtools/commands/__init__.py",
 line 622, in run_from_argv
        exit_code = self.main(*args) or 0
      File 
"/tmp/rbtool-for-mac/lib/RBTools/RBTools-0.7.5-py2.7.egg/rbtools/commands/post.py",
 line 941, in main
        base_dir=base_dir)
      File 
"/tmp/rbtool-for-mac/lib/RBTools/RBTools-0.7.5-py2.7.egg/rbtools/commands/post.py",
 line 537, in post_request
        self.add_review_info(changenum, 
review_request.absolute_url.replace('***.com', '***.com'))
      File 
"/tmp/rbtool-for-mac/lib/RBTools/RBTools-0.7.5-py2.7.egg/rbtools/commands/post.py",
 line 657, in add_review_info
        self.tool.amend_commit_description(change_dict['Description'], 
self.revisions)
      File 
"/tmp/rbtool-for-mac/lib/RBTools/RBTools-0.7.5-py2.7.egg/rbtools/clients/perforce.py",
 line 1517, in amend_commit_description
        self.p4.modify_change(new_change)
      File 
"/tmp/rbtool-for-mac/lib/RBTools/RBTools-0.7.5-py2.7.egg/rbtools/clients/perforce.py",
 line 53, in modify_change
        return self.run_p4(['change', '-i'], input_string=new_change_spec)
      File 
"/tmp/rbtool-for-mac/lib/RBTools/RBTools-0.7.5-py2.7.egg/rbtools/clients/perforce.py",
 line 160, in run_p4
        p.communicate(input_string)  # Send input, wait, set returncode
      File "/usr/lib/python2.7/subprocess.py", line 740, in communicate
        self.stdin.write(input)
    UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in 
position 1671: ordinal not in range(128)
    
    So to fix this error I encoded the input string as below
    p.communicate(input_string.encode('utf-8'))

-- 
You received this message because you are subscribed to the Google Groups 
"reviewboard-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to reviewboard-issues+unsubscr...@googlegroups.com.
To post to this group, send email to reviewboard-issues@googlegroups.com.
Visit this group at https://groups.google.com/group/reviewboard-issues.
For more options, visit https://groups.google.com/d/optout.

Reply via email to