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 707026 - Shell commands in snippets trigger error message
Shell commands in snippets trigger error message
Status: RESOLVED FIXED
Product: gedit
Classification: Applications
Component: snippets
3.8.x
Other Linux
: Normal normal
: ---
Assigned To: Gedit maintainers
Gedit maintainers
Depends on:
Blocks:
 
 
Reported: 2013-08-29 08:20 UTC by Baptiste Mispelon
Modified: 2014-01-18 22:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Rough attempt at a fix (905 bytes, patch)
2013-08-29 08:20 UTC, Baptiste Mispelon
none Details | Review
Proper format-patch as requested (1.26 KB, patch)
2013-08-29 08:56 UTC, Baptiste Mispelon
committed Details | Review

Description Baptiste Mispelon 2013-08-29 08:20:55 UTC
Created attachment 253471 [details] [review]
Rough attempt at a fix

Hi,

When trying to use a shell command in the snippets, as described in the documentation [1], an error message always appear and the shell command's output is never inserted.

Steps to reproduce
------------------

1) Create a new snippet:

Content of the snippet: $(date)
Tab trigger: foobar

2) In editor window, type "foobar" (without quotes) then press <TAB>


Expected result:
----------------
"foobar" is replaced by the current date and time


Actual result:
--------------

An error message pops out after ~1sec saying:
> Execution of the shell command (date) exceeded the maximum time; execution aborted.


Additional information:
-----------------------

When opened from a terminal, a python traceback is displayed when the error happens:

    Traceback (most recent call last):
  • File "/usr/lib/python3.3/site-packages/gi/overrides/GLib.py", line 700 in <lambda>
    func_fdtransform = lambda _, cond, data: func(channel, cond, data)
  • File "/usr/lib/python3.3/site-packages/gi/overrides/GLib.py", line 631 in <lambda>
    return (lambda a1, a2, data: callback(a1, a2, *data), user_data)
  • File "/usr/lib/gedit/plugins/snippets/placeholder.py", line 445 in process_cb
    self.shell_output += line     TypeError: Can't convert 'bytes' object to str implicitly


From a quick look, this breakage seems to have been introduced in commit ebbb4e5ae48269dbfcf758b7865351d010937320.

The attached patch fixes the issue on my machine.

Let me know if I can help any further,
Thanks.


[1] https://wiki.gnome.org/Apps/Gedit/Plugins/Snippets
Comment 1 Paolo Borelli 2013-08-29 08:49:54 UTC
Thanks! the patch makes sense to me, this is probably a fallout of the python3 conversion.

Could you attach the patch as a "git format-patch" so that we can commit it giving you the proper credit? See https://wiki.gnome.org/GnomeLove/SubmittingPatches for more details
Comment 2 Baptiste Mispelon 2013-08-29 08:56:23 UTC
Created attachment 253477 [details] [review]
Proper format-patch as requested
Comment 3 Paolo Borelli 2013-08-29 09:00:19 UTC
Review of attachment 253477 [details] [review]:

pushed, thank you!
Comment 4 Paolo Borelli 2013-08-29 09:00:37 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.
Comment 5 Baptiste Mispelon 2013-08-29 09:02:14 UTC
Thanks for the quick and friendly response.

Have a nice day!
Comment 6 Adam Williamson 2014-01-17 22:43:01 UTC
Can this fix please be backported to the 3.8 branch? Just ran into this bug on Fedora 19, which is still supported for another 6 months. I'll backport the fix downstream, but seems like something that should be done upstream too. Thanks!
Comment 7 Ignacio Casal Quinteiro (nacho) 2014-01-18 14:45:53 UTC
Adam go ahead and push it upstream, as far as they don't add new strings I am fine with it.
Comment 8 Adam Williamson 2014-01-18 17:09:34 UTC
I don't have any gnome.org commit privs, I'm not a GNOME dev.
Comment 9 Sébastien Wilmet 2014-01-18 22:29:21 UTC
Backported to gnome-3-8.