After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 720324 - splitlines breaks with python2
splitlines breaks with python2
Status: RESOLVED FIXED
Product: gedit-plugins
Classification: Other
Component: General
3.8.x
Other Linux
: Normal normal
: ---
Assigned To: Matěj Cepl
Gedit maintainers
Depends on:
Blocks:
 
 
Reported: 2013-12-12 13:22 UTC by Matěj Cepl
Modified: 2019-03-23 20:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
suggested patch (3.97 KB, patch)
2013-12-15 22:46 UTC, Matěj Cepl
none Details | Review
some additional PEP8ization fixes. (3.34 KB, patch)
2013-12-15 22:47 UTC, Matěj Cepl
none Details | Review
iter.get_char() returns bytes of UTF-8 encoded text. (3.29 KB, patch)
2015-08-25 15:03 UTC, Matěj Cepl
none Details | Review
iter.get_char() returns bytes of UTF-8 encoded text. (3.29 KB, patch)
2015-08-25 15:28 UTC, Matěj Cepl
none Details | Review
Some PEP8ization fixes. (1.49 KB, patch)
2015-08-25 15:28 UTC, Matěj Cepl
none Details | Review

Description Matěj Cepl 2013-12-12 13:22:28 UTC
On system with python2 I get this traceback whenever I run split lines.

Traceback (most recent call last):
  • File "/usr/lib64/gedit/plugins/joinlines.py", line 79 in <lambda>
    lambda a, w: split_lines(w))],
  • File "/usr/lib64/gedit/plugins/joinlines.py", line 176 in split_lines
    forward_to_word_end(current_word_end)
  • File "/usr/lib64/gedit/plugins/joinlines.py", line 223 in forward_to_word_end
    while ord(char) and (not (char in (' ', '\t', '\n', '\r'))):
TypeError: ord() expected a character, but string of length 2 found

Comment 1 Ignacio Casal Quinteiro (nacho) 2013-12-12 13:26:55 UTC
even though I really don't care about python2 anymore I'd accept a patch for this if somebody else fixes it.
Comment 2 Matěj Cepl 2013-12-15 22:46:31 UTC
Created attachment 264253 [details] [review]
suggested patch

Suggested patch. Please, test how it works with python3 based gedit.
Comment 3 Matěj Cepl 2013-12-15 22:47:38 UTC
Created attachment 264254 [details] [review]
some additional PEP8ization fixes.

Just when running my patch through flake8 I noticed some previous problems with the code.
Comment 4 Matěj Cepl 2013-12-15 22:49:28 UTC
Comment on attachment 264253 [details] [review]
suggested patch

Whole my branch is based on 3.8.3 tag.
Comment 5 jessevdk@gmail.com 2014-04-12 17:06:59 UTC
Is this still relevant? I think we have other places where we explicitly use python3 things.
Comment 6 Ignacio Casal Quinteiro (nacho) 2014-04-12 21:08:57 UTC
I think this was due to the fact rhel 7 was dropping python3 and actually gedit was built without python in that version.
Comment 7 Matěj Cepl 2014-04-14 10:51:33 UTC
(In reply to comment #6)
> I think this was due to the fact rhel 7 was dropping python3 and actually gedit
> was built without python in that version.

Yes, that's the point ... and I thought that changes which wouldn't break Python3 but allow us to use the code with Python2 shouldn't harm anybody. That much.
Comment 8 jessevdk@gmail.com 2014-04-14 11:17:13 UTC
I'm not against keeping py2 compatibility unless it starts to be cumbersome. I noticed that we use py3 features at least in snippets:

https://git.gnome.org/browse/gedit/tree/plugins/snippets/snippets/shareddata.py#n26

Maybe would be good to run something like pyflakes on all python plugins and see what it reports.
Comment 9 Matěj Cepl 2014-04-14 11:55:26 UTC
As long as it will be patches like this I am glad to keep patching. However, when it gets more complicated, we will just loose some plugin or other functionality. We already do loost some (e.g., we don’t have libgit2 in RHEL). Perhaps we can eventually create an EPEL-7 package with additional plugins requiring packages outside of RHEL-7.
Comment 10 Paolo Borelli 2014-07-20 16:16:39 UTC
If it makes your life easier feel free to patch the 3.8 branch.

For master I do not want pacthes that make the string manipulation stuff conditional to the py version. py utf8 handling is already complicated as is without supporting py2 and py3
Comment 11 Matěj Cepl 2015-08-25 15:03:44 UTC
Created attachment 309971 [details] [review]
iter.get_char() returns bytes of UTF-8 encoded text.

Make shell function which returns always one character long string,
either bytes() or unicode() (using py3k terminology).

Fixes BGO# 720324
Comment 12 Matěj Cepl 2015-08-25 15:28:33 UTC
Created attachment 309972 [details] [review]
iter.get_char() returns bytes of UTF-8 encoded text.

Make shell function which returns always one character long string,
either bytes() or unicode() (using py3k terminology).

Fixes BGO# 720324
Comment 13 Matěj Cepl 2015-08-25 15:28:41 UTC
Created attachment 309973 [details] [review]
Some PEP8ization fixes.
Comment 14 Matěj Cepl 2015-12-05 15:44:25 UTC
Commited as bc45084211b36d502f2bc43e176f2cc2133f4418