Package: osc-plugins-dput
Version: 20180227.1-1
Severity: grave
Justification: renders package unusable
Tags: patch upstream

$ osc -A xxx dput xxx:xxx ~/tmp/build-area/xxx_source.changes
Traceback (most recent call last):
  File "/usr/bin/osc", line 41, in <module>
    r = babysitter.run(osccli)
...
  File "/usr/lib/osc-plugins/dput.py", line 30, in do_dput
    osc_plugins_dput.do_dput(self, subcmd, opts, proj_name, dsc_file)
  File "/usr/share/osc-plugins-dput/osc_plugins_dput.py", line 161, in do_dput
    package_list = osc.core.meta_get_packagelist(conf.config['apiurl'], 
dput.PROJECT_NAME)
  File "/usr/lib/python3/dist-packages/osc/core.py", line 3442, in 
meta_get_packagelist
    u = makeurl(apiurl, ['source', prj], query)
  File "/usr/lib/python3/dist-packages/osc/core.py", line 3316, in makeurl
    return urlunsplit((scheme, netloc, '/'.join([path] + list(l)), query, ''))
TypeError: sequence item 2: expected str instance, bytes found

and with that fixed:

$ osc -A xxx dput xxx:xxx ~/tmp/build-area/xxx_source.changes
Traceback (most recent call last):
  File "/usr/bin/osc", line 41, in <module>
    r = babysitter.run(osccli)
...
  File "/usr/lib/osc-plugins/dput.py", line 30, in do_dput
    osc_plugins_dput.do_dput(self, subcmd, opts, proj_name, dsc_file)
  File "/usr/share/osc-plugins-dput/osc_plugins_dput.py", line 170, in do_dput
    dput._create_package()
  File "/usr/share/osc-plugins-dput/osc_plugins_dput.py", line 84, in 
_create_package
    osc.core.createPackageDir(self.PACKAGE_NAME)
  File "/usr/lib/python3/dist-packages/osc/core.py", line 7078, in 
createPackageDir
    if is_project_dir(prj_dir):
  File "/usr/lib/python3/dist-packages/osc/core.py", line 3088, in 
is_project_dir
    return os.path.exists(os.path.join(d, store, '_project')) and not \
  File "/usr/lib/python3.7/posixpath.py", line 94, in join
    genericpath._check_arg_types('join', a, *p)
  File "/usr/lib/python3.7/genericpath.py", line 155, in _check_arg_types
    raise TypeError("Can't mix strings and bytes in path components") from None
TypeError: Can't mix strings and bytes in path components

I attach a possible patch, although this seems to have been fixed
differently upstream.

-- System Information:
Debian Release: bullseye/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'stable-updates'), (500, 
'buildd-unstable'), (500, 'unstable'), (500, 'stable'), (500, 'oldstable'), (1, 
'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.4.0-1-amd64 (SMP w/4 CPU cores)
Kernel taint flags: TAINT_WARN, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_GB:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages osc-plugins-dput depends on:
ii  osc             0.167.1-1
ii  python3-debian  0.1.36

osc-plugins-dput recommends no packages.

osc-plugins-dput suggests no packages.

-- no debconf information

-- debsums errors found:
debsums: changed file /usr/share/osc-plugins-dput/osc_plugins_dput.py (from 
osc-plugins-dput package)
>From 343315308c7ed9f7f3635be30766c9a8a06581f9 Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@collabora.com>
Date: Mon, 6 Jan 2020 20:02:14 +0000
Subject: [PATCH] Be compatible with Python 3 osc

---
 osc_plugins_dput.py | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/osc_plugins_dput.py b/osc_plugins_dput.py
index f54b4f0..dbdb066 100644
--- a/osc_plugins_dput.py
+++ b/osc_plugins_dput.py
@@ -6,6 +6,7 @@ import os
 import osc.cmdln as cmdln
 import osc.conf as conf
 import osc.core
+import sys
 
 try:
     from debian.deb822 import Changes, Dsc
@@ -126,12 +127,21 @@ class DPut(object):
 
         return fileList
 
+
+if sys.version_info[0] >= 3:
+    def str_cast(s):
+        return s
+else:
+    def str_cast(s):
+        return s.encode('utf-8')
+
+
 @cmdln.option('--maintained-in-git', action='store_true',
               help='add MAINTAINED_IN_GIT.txt')
 def do_dput(self, subcmd, opts, proj_name, dsc_or_changes_file):
     dput = DPut()
 
-    dput.PROJECT_NAME = proj_name.encode("utf8")
+    dput.PROJECT_NAME = str_cast(proj_name)
     dput.WORKING_DIR = tempfile.mkdtemp('_oscdput')
     def cleanup(dirname, initdir):
         os.chdir(initdir)
@@ -144,8 +154,8 @@ def do_dput(self, subcmd, opts, proj_name, dsc_or_changes_file):
     # get debian .change object before moving current path to the
     # working_dir
     changes, dsc, dsc_file = _get_objects_from_file(dsc_or_changes_file)
-    dput.PACKAGE_NAME = dsc.get("Source").encode('utf8') # XXX: needs to be utf8!!!
-    dput.PACKAGE_VERSION = dsc.get("Version")
+    dput.PACKAGE_NAME = str_cast(dsc.get("Source"))
+    dput.PACKAGE_VERSION = str_cast(dsc.get("Version"))
 
     # Filenames in the .dsc are relative to the directory where it appears.
     # We need to make it absolute before we chdir elsewhere.
-- 
2.25.0.rc0

Reply via email to