#207 Fix unicode issue for update command in Python 3
Merged by cqi. Opened by cqi.
cqi/fedpkg fix-fedpkg-update-206  into  master

Download 207.patch

With this patch, in update command, unicode string is used consistently
through the whole process. String written into file by write() method is
handled carefully with or without encoding to byte string for Python 2
and 3 individually.

Issue reported in #206 was not caught due to write() was mocked. This
patch also fixes this problem. Now, during the test, real bodhi.template
and clog file are written into and read from file system. Tests are
updated accordingly.

Fixes #206

Signed-off-by: Chenxiong Qi cqi@redhat.com

pretty please pagure-ci rebuild

Looks good to me. Running nose in my Py2.7 virtualenv works, but tox is reporting some errors. They don't look related to this PR.

1 new commit added

  • Copy pip-pycurl to ensure pycurl is installed correctly

It should be

======================================================================
FAIL: Test verify_sls with an SL that is not June 1st or December 1st. An
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/cqi/code/fedpkg/test/test_utils.py", line 116, in test_verify_sls_invalid_date
    'December 1st'.format(eol))
AssertionError: 

which happens randomly with Python 2.7. Wired. I'll look into it later.

for consistency, you can read it binary a decode everywhere. you should also handle situation, when the encoding fails

For consistency, you can also open bytes and encode everywhere.

For cleaner code here I suggest you read about File I/O in The Conservative Python 3 Porting Guide.

@churchyard Thanks for your comment. I thought consistency of using unicode would be better than the byte string, because less or none fedpkg (even rpkg) handle byte strings. Moving to Python 3 completely is the ultimate goal eventually, then str (unicode string) will be the default.

np ;)

rebased onto 1feed9afbef09510530fef18850f7e1d594e9191

@churchyard Updated patch by using io.open.

Seems that only somewhere...

Nevertheless the original patch fixed it for me.

Seems that only somewhere...

@churchyard Sorry, I don't understand this. What does it mean?

io.open here, good!

normal open here, bad.

normal open here.

binary open here. works, but inconsistent.

This patch now contains 3 kinds of reading text files:

  • text io.open
  • text builtin open with python2 only decoding
  • binary builtin open with decoding

Oh, I see. I missed the others. After this pr gets merged, I'll check if there is any other opens.

rebased onto fdeeaf0ad889f63f3d99af365cfe9ad041fa9bda

@churchyard Fixed. PTAL.

I wonder why don't you use unicode literals here instead?

All opens are consistent here now :)

Great. Going to merge :tada:

Oh, the failure in job is not relative this these changes.

Pull-Request has been merged by cqi

Metadata