Your message dated Wed, 17 Apr 2019 23:48:31 +0000
with message-id <[email protected]>
and subject line Bug#916372: fixed in pastebinit 1.5-2.1
has caused the Debian Bug report #916372,
regarding pastebinit: multiple deprecation warnings under Python 3.7
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
916372: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916372
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: pastebinit
Version: 1.5-2
Severity: normal
Tags: patch

Hi,

After the upgrade to Pyton 3.7, pastebinit starts to emit 2 warnings.

$ python3.6 /usr/bin/pastebinit /tmp/test.txt
http://paste.debian.net/1055727/
$ python3.7 /usr/bin/pastebinit /tmp/test.txt
/usr/bin/pastebinit:42: DeprecationWarning: dist() and linux_distribution() 
functions are deprecated in Python 3.5
  release = platform.linux_distribution()[0].lower()
/usr/bin/pastebinit:413: DeprecationWarning: pasteURLopener style of invoking 
requests is deprecated. Use newer urlopen functions/methods
  url_opener = pasteURLopener()
http://paste.debian.net/1055728/

The attached patches silence the warnings for me. I only tested it
against paste.debian.net, but I see no reason why any of the changes I
did would be a problem for other sites.

Note that the first patch adds a new dependency, so you also want
something like this:

diff -Nru pastebinit-1.5/debian/control pastebinit-1.5/debian/control
--- pastebinit-1.5/debian/control       2018-04-15 12:04:53.000000000 -0300
+++ pastebinit-1.5/debian/control       2018-12-13 15:01:31.000000000 -0200
@@ -11,7 +11,7 @@

 Package: pastebinit
 Architecture: all
-Depends: python3, ${misc:Depends}
+Depends: python3, python3-distro, ${misc:Depends} Breaks: bikeshed (<< 1.21)
 Replaces: bikeshed (<< 1.21)
 Description: command-line pastebin client

-- System Information:
Debian Release: buster/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'testing-debug'), (500, 
'unstable'), (500, 'testing'), (1, 'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.18.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=pt_BR.UTF-8, LC_CTYPE=pt_BR.UTF-8 (charmap=UTF-8), 
LANGUAGE=pt_BR:pt:en (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages pastebinit depends on:
ii  python3         3.7.1-2
ii  python3-distro  1.3.0-1

pastebinit recommends no packages.

pastebinit suggests no packages.

-- no debconf information
Description: move away from deprecated platform functions
 The linux_distribution function from the platform has been deprecated in
 Python 3.5. `distro` is the natural sucessor, however it is a new dependency.
Author: Antonio Terceiro <[email protected]>

--- a/pastebinit
+++ b/pastebinit
@@ -38,8 +38,8 @@ defaultPB = "pastebin.com"
 
 # Now try to override it with a distributor pastebin
 try:
-    import platform
-    release = platform.linux_distribution()[0].lower()
+    import distro
+    release = distro.linux_distribution(full_distribution_name=False)[0].lower()
     if release == 'debian':
         defaultPB = "paste.debian.net"
     elif release == 'fedora':
Description: update urlopen usage
 The URLOpener classes from the urllib.request are deprecated in Python 3.5.
 Replace them with a more modern usage of urlopen().
 .
 Note that this patch removes the special handling of HTTP 401
 ("Unauthorized").

Author: Antonio Terceiro <[email protected]>

--- a/pastebinit
+++ b/pastebinit
@@ -27,11 +27,11 @@ if sys.version[0] == "2":
     from ConfigParser import NoOptionError
     from ConfigParser import SafeConfigParser as ConfigParser
     from urllib import urlencode
-    from urllib import FancyURLopener
+    from urllib import request
 else:
     from configparser import ConfigParser, NoOptionError
     from urllib.parse import urlencode
-    from urllib.request import FancyURLopener
+    from urllib import request
 
 # Set the default pastebin
 defaultPB = "pastebin.com"
@@ -72,12 +72,13 @@ try:
     version = "1.5"
     configfile = os.path.expanduser("~/.pastebinit.xml")
 
-    # Custom urlopener to handle 401's
-    class pasteURLopener(FancyURLopener):
+    class PasteRequest(request.Request):
         version = "Pastebinit v%s" % version
 
-        def http_error_401(self, url, fp, errcode, errmsg, headers, data=None):
-            return None
+        def __init__(self, *args, **opts):
+            super(PasteRequest, self).__init__(*args, **opts)
+            if 'User-agent' not in self.headers:
+                self.add_header('User-agent', self.version)
 
     def preloadPastebins():
         # Check several places for config files:
@@ -410,25 +411,25 @@ try:
         else:
             post_format = 'standard'
 
-        url_opener = pasteURLopener()
+        req = PasteRequest(fetch_url)
 
         if post_format == 'json':
             if json:
                 params = json.dumps(params)
-                url_opener.addheader('Content-type', 'text/json')
+                req.add_header('Content-type', 'text/json')
             else:
                 print(_("Could not find any json library."), file=sys.stderr)
                 sys.exit(1)
         else:
             # Convert to a format usable with the HTML POST
-            params = urlencode(params)
+            params = bytes(urlencode(params), encoding='US-ASCII')
 
         # Send the informations and be redirected to the final page
         if verbose:
             print("POSTing to: %s\nParams: %s" % (
                 fetch_url, str(params)), file=sys.stderr)
         try:
-            page = url_opener.open(fetch_url, params)
+            page = request.urlopen(req, params)
         except Exception as e:
             print(_("Failed to contact the server: %s") % e, file=sys.stderr)
             sys.exit(1)

Attachment: signature.asc
Description: PGP signature


--- End Message ---
--- Begin Message ---
Source: pastebinit
Source-Version: 1.5-2.1

We believe that the bug you reported is fixed in the latest version of
pastebinit, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Simon Quigley <[email protected]> (supplier of updated pastebinit package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Fri, 12 Apr 2019 18:10:40 -0500
Source: pastebinit
Architecture: source
Version: 1.5-2.1
Distribution: unstable
Urgency: medium
Maintainer: Rolf Leggewie <[email protected]>
Changed-By: Simon Quigley <[email protected]>
Closes: 916372
Changes:
 pastebinit (1.5-2.1) unstable; urgency=medium
 .
   * Non-maintainer upload.
   * Fix deprecation warnings under Python 3.6 and 3.7 (Closes: #916372).
     - Thanks to Antonio Terceiro for the patches!
Checksums-Sha1:
 85baa02c27778655618ff61e518bfd798e0754a0 1920 pastebinit_1.5-2.1.dsc
 adae02d88a6a2c3036247529f12ff74aa329f2a7 6944 pastebinit_1.5-2.1.debian.tar.xz
 e6225175bf0394ac5c13c06dd0d3934190f53a8b 6455 
pastebinit_1.5-2.1_source.buildinfo
Checksums-Sha256:
 a03f58626ec0b754c36b7cae276a6dd35afe34750a438dc0061c7f3ff78acd72 1920 
pastebinit_1.5-2.1.dsc
 688202377ebfa251e01141e8b90a68aa73cbf96e93072012ebd34fcb377fc023 6944 
pastebinit_1.5-2.1.debian.tar.xz
 af1a37c28cdcf15d67a2f9ff5ebd26f6596d2f3093a077ba635f5c5e38da80cb 6455 
pastebinit_1.5-2.1_source.buildinfo
Files:
 1cb65afbd030663b5b817c05c81196c1 1920 misc optional pastebinit_1.5-2.1.dsc
 ced03eb70d6bbcb0491aafd322111b22 6944 misc optional 
pastebinit_1.5-2.1.debian.tar.xz
 ade9ec260985962a0613161dd3430cfb 6455 misc optional 
pastebinit_1.5-2.1_source.buildinfo

-----BEGIN PGP SIGNATURE-----

iQJOBAEBCAA4FiEEXHq+og+GMEWcyMi14n8s+EWML6QFAlyxG1saHHRzaW1vbnEy
QGxpbnV4cGFkYXdhbi5uZXQACgkQ4n8s+EWML6QoOw//RB8ClW4q+baM5yBVFXQa
DgnbphC/+xqQrN8RlW/7n1fsXxo+1HXkkWHyy7Tn8pDIZ4Ktq0dlu4nDsP9i2nPj
q0jN4Jjdp9uk/cztNJIh13g6c4OtmRp8Wp4k/yx2/vlodeAzYEQ7C5U2jyTp+wCE
IXPde+bauoE0tfN3ptXA4pH+vuLgaFAc8IDH1hgYdm5QfGQcNgQmC2tlDngvxT5d
Vnl4+fptXkP6tnCaZn2+cfF9uMmQDvUWPwNgDP9zYzVOdjoQ2152Z6XHDcuHv6Iq
DwV5MCSel0J2a8rBMxG9+9ozbIpjL+A9tmvWMRHngosbBnZo4LBpAIVdUFjbx3go
CWPJ/kJd8qOZd2V++DUMcyvgRSfG5FQ/IfeU94TMDLr+U3pH3KK328h2xbyyPe3m
vZ78l0folSYM7I6poCrN1yJ8NTm97ZORcRo0J4YYDLMr1H5bfUV8LioFQGd1ZfUf
CgCpKFl4ofjrWufHUkd3Ksp1Cy9I+IxsofgOCvaenik/BVLHKl8JTXAU+Ma5wFIE
JYeZAfKpTGHB0lMwSuonm+0UKnO4XOQUZVM/si5XClBi1n2R/6+PZ2NI+A7zxnC+
myHAHc3Mc3+CWzr9EaaZxuIY77CPNOvo19PCsyDhk+rk4fDB6zHVJTWuVRUyMJ/x
71BiqXroHMoeogz+Wa+HMjI=
=2cl3
-----END PGP SIGNATURE-----

--- End Message ---

Reply via email to