"pastebinit -i file" to paste.openstack.org fails: Object of type 'bytes' is not JSON serializable

Bug #1785821 reported by Paulo Marcel Coelho Aragão
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pastebinit (Ubuntu)
Fix Released
Undecided
Unassigned
Focal
Confirmed
Undecided
Unassigned
Hirsute
Won't Fix
Undecided
Unassigned
Impish
Won't Fix
Undecided
Unassigned

Bug Description

pastebinit from a file to paste.openstack.org fails:

paulo:~/tmp$ pastebinit -i /etc/lsb-release -b paste.openstack.org
Traceback (most recent call last):
  File "/usr/bin/pastebinit", line 417, in <module>
    params = json.dumps(params)
  File "/usr/lib/python3.6/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python3.6/json/encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'bytes' is not JSON serializable

It doesn't seem to depend on the file type: I tried with quite a few and the error was the same each time.

It works as expected when reading from stdin:

paulo:~/tmp$ cat /etc/lsb-release | pastebinit -b paste.openstack.org
http://paste.openstack.org/show/727520

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: pastebinit 1.5-2
ProcVersionSignature: Ubuntu 4.15.0-30.32-generic 4.15.18
Uname: Linux 4.15.0-30-generic x86_64
ApportVersion: 2.20.9-0ubuntu7.2
Architecture: amd64
CurrentDesktop: XFCE
Date: Tue Aug 7 10:37:10 2018
InstallationDate: Installed on 2018-04-28 (101 days ago)
InstallationMedia: Xubuntu 18.04 LTS "Bionic Beaver" - Release amd64 (20180426)
PackageArchitecture: all
SourcePackage: pastebinit
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Paulo Marcel Coelho Aragão (marcelpaulo) wrote :
Revision history for this message
Unit 193 (unit193) wrote :

Howdy,

This is fixable with a very simple patch, though I'm not sure what the downside of it is:

--- a/usr/bin/pastebinit/pastebinit 2016-03-01 00:52:32.000000000 -0500
+++ b/usr/bin/pastebinit/pastebinit 2019-07-06 19:39:43.280603245 -0400
@@ -349,7 +348,7 @@
             content = sys.stdin.read()
         else:
             try:
- with open(filename, "rb") as fd:
+ with open(filename, "r") as fd:
                     content = fd.read()
             except KeyboardInterrupt:
                 print(_("KeyboardInterrupt caught."), file=sys.stderr)

Thomas Ward (teward)
Changed in pastebinit (Ubuntu):
status: New → Confirmed
Changed in pastebinit (Ubuntu Hirsute):
status: New → Confirmed
Changed in pastebinit (Ubuntu Focal):
status: New → Confirmed
Changed in pastebinit (Ubuntu Hirsute):
status: Confirmed → New
Lukas Märdian (slyon)
Changed in pastebinit (Ubuntu):
status: Confirmed → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pastebinit - 1.5.1-1ubuntu1

---------------
pastebinit (1.5.1-1ubuntu1) devel; urgency=medium

  * d/p/0001-Fix-pasting-files-to-JSON-based-bins.patch:
    - Fix pasting files to JSON based bins. (LP: #1785821)
  * d/p/0002-Allow-private-to-be-configured.patch:
    - Allow 'private' to be configured.
  * d/p/0003-Update-Openstack-s-pastebin-site-paste.openstack.org.patch:
    - Update Openstack's pastebin site, paste.openstack.org → paste.opendev.org
  * d/p/0004-Fix-distro.linux_distribution-deprecation.patch:
    - Fix distro.linux_distribution deprecation. (LP: #1844128)
  * d/copyright: Correct paths.
  * d/control:
    - Replace d/compat with debhelper-compat, bump to 13.
    - R³: no.
  * Update Standards-Version to 4.6.0.

 -- Unit 193 <email address hidden> Tue, 23 Nov 2021 21:53:34 -0500

Changed in pastebinit (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote :

The Hirsute Hippo has reached End of Life, so this bug will not be fixed for that release.

Changed in pastebinit (Ubuntu Hirsute):
status: New → Won't Fix
Revision history for this message
Brian Murray (brian-murray) wrote :

Ubuntu 21.10 (Impish Indri) has reached end of life, so this bug will not be fixed for that specific release.

Changed in pastebinit (Ubuntu Impish):
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.