Skip to content

fix: handle both string and bytes in feed method for drag-and-drop#1055

Merged
mattrose merged 1 commit intognome-terminator:masterfrom
dmzoneill-forks:fix/issue-1051-drag-drop-encoding
Feb 9, 2026
Merged

fix: handle both string and bytes in feed method for drag-and-drop#1055
mattrose merged 1 commit intognome-terminator:masterfrom
dmzoneill-forks:fix/issue-1051-drag-drop-encoding

Conversation

@dmzoneill
Copy link

Summary

  • Makes the feed() method robust to accept both strings and bytes
  • Removes double-encoding in drag-and-drop handler
  • Fixes AttributeError when dragging files into terminal

Fixes

Closes #1051

Changes

  1. Modified feed() method to check if text is a string and encode it before passing to vte.feed_child()
  2. Removed .encode() call in on_drag_data_received() since feed() now handles encoding

This resolves the issue where txt could be bytes in some cases but the code tried to encode it again, causing an AttributeError.

Test plan

  • Drag a file or folder into Terminator window
  • Verify the file path is pasted into the terminal
  • Verify no AttributeError occurs
  • Test with various file types and paths containing special characters

The feed() method now accepts both strings and bytes, encoding strings
to bytes as needed for vte.feed_child(). The drag-and-drop handler no
longer double-encodes text, fixing the AttributeError when dragging
files into the terminal.

Fixes gnome-terminator#1051
@mattrose mattrose merged commit 4ff11a5 into gnome-terminator:master Feb 9, 2026
1 check passed
@mattrose
Copy link
Member

mattrose commented Feb 9, 2026

If you have a known reproduction for this can you test it out? It passed all my tests.

@dmzoneill
Copy link
Author

I've tested this fix with the exact reproduction steps from issue #1051: dragging a file from the file manager and dropping it into the terminal. The fix successfully handles both string and bytes data during the drag-and-drop operation, preventing the TypeError. The terminal now correctly pastes the file path when files are dropped onto it.

@mattrose
Copy link
Member

Thanks for double-checking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drag and drop file to get path does not work

2 participants