Control: tags -1 upstream
Control: forwarded -1 https://github.com/yaml/pyyaml/pull/181


On Sat, 29 Dec 2018 05:40:43 +0100 Niels Thykier <ni...@thykier.net> wrote:
> Package: python3-yaml
> Version: 3.13-1
> Severity: normal
> 
> Hi,
> 
> I spotted this in the CI job of britney2[1].
> 
> [...]
> 
> Presumably this is (or will be) fixed in a new upstream release but it
> might make sense to cherry-pick that fix for buster to avoid breakage
> in sid + buster at the moment.
> 
> Thanks,
> ~Niels
> 
> [1] https://salsa.debian.org/release-team/britney2/-/jobs/99062
> 
> 


Hi,

The pyyaml upstream seems to be in a ... "interesting" state at the
moment with the 4.X major version.

Anyway, I found a pull request submitted upstream that (among other)
fixes this issue and added it as a "forwarded" for this bug.  From this
branch/PR, please cherry-pick the following commit (also attached):

https://github.com/yaml/pyyaml/pull/181/commits/7eaa43474d0f6ecca5f89287ba27f420702523cc

Thanks,
~Niels

From 7eaa43474d0f6ecca5f89287ba27f420702523cc Mon Sep 17 00:00:00 2001
From: Florian Bruhin <g...@the-compiler.org>
Date: Wed, 27 Jun 2018 14:50:15 +0200
Subject: [PATCH] Import Hashable from collections.abc

In Python 3.7, importing ABCs directly from the 'collections' module shows a
warning (and in Python 3.8 it will stop working) - see
https://github.com/python/cpython/commit/c66f9f8d3909f588c251957d499599a1680e2320

Since this is only done in lib3/ which is Python 3 only, we can unconditionally
import it from collections.abc instead.

This fixes the following DeprecationWarning:

.../site-packages/yaml/__init__.py:75: in load
    return loader.get_single_data()
.../site-packages/yaml/constructor.py:37: in get_single_data
    return self.construct_document(node)
.../site-packages/yaml/constructor.py:46: in construct_document
    for dummy in generator:
.../site-packages/yaml/constructor.py:398: in construct_yaml_map
    value = self.construct_mapping(node)
.../site-packages/yaml/constructor.py:204: in construct_mapping
    return super().construct_mapping(node, deep=deep)
.../site-packages/yaml/constructor.py:126: in construct_mapping
    if not isinstance(key, collections.Hashable):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

name = 'Hashable'

    def __getattr__(name):
        # For backwards compatibility, continue to make the collections ABCs
        # through Python 3.6 available through the collections module.
        # Note, no new collections ABCs were added in Python 3.7
        if name in _collections_abc.__all__:
            obj = getattr(_collections_abc, name)
            import warnings
            warnings.warn("Using or importing the ABCs from 'collections' instead "
                          "of from 'collections.abc' is deprecated, "
                          "and in 3.8 it will stop working",
>                         DeprecationWarning, stacklevel=2)
E           DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
---
 lib3/yaml/constructor.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib3/yaml/constructor.py b/lib3/yaml/constructor.py
index 981543a..193d91d 100644
--- a/lib3/yaml/constructor.py
+++ b/lib3/yaml/constructor.py
@@ -5,7 +5,7 @@
 from .error import *
 from .nodes import *
 
-import collections, datetime, base64, binascii, re, sys, types
+import collections.abc, datetime, base64, binascii, re, sys, types
 
 class ConstructorError(MarkedYAMLError):
     pass
@@ -123,7 +123,7 @@ def construct_mapping(self, node, deep=False):
         mapping = {}
         for key_node, value_node in node.value:
             key = self.construct_object(key_node, deep=deep)
-            if not isinstance(key, collections.Hashable):
+            if not isinstance(key, collections.abc.Hashable):
                 raise ConstructorError("while constructing a mapping", node.start_mark,
                         "found unhashable key", key_node.start_mark)
             value = self.construct_object(value_node, deep=deep)

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to