aboutsummaryrefslogtreecommitdiffstats
path: root/main/py-setuptools/fix-659.patch
blob: 4035541df11e050bfdd5afb06167637d6b7c8bf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
https://github.com/pypa/setuptools/issues/659

diff -ru setuptools-24.0.2.orig/pkg_resources/__init__.py setuptools-24.0.2/pkg_resources/__init__.py
--- setuptools-24.0.2.orig/pkg_resources/__init__.py	2016-07-04 18:22:36.000000000 +0300
+++ setuptools-24.0.2/pkg_resources/__init__.py	2016-07-19 10:33:34.030885550 +0300
@@ -988,9 +988,9 @@
         """
         extra_evals = (
             req.marker.evaluate({'extra': extra})
-            for extra in self.get(req, ()) + (None,)
+            for extra in self.get(req, ())
         )
-        return not req.marker or any(extra_evals)
+        return not req.marker or any(extra_evals) or req.marker.evaluate()
 
 
 class Environment(object):
diff -ru setuptools-24.0.2.orig/pkg_resources/tests/test_resources.py setuptools-24.0.2/pkg_resources/tests/test_resources.py
--- setuptools-24.0.2.orig/pkg_resources/tests/test_resources.py	2016-07-04 18:22:36.000000000 +0300
+++ setuptools-24.0.2/pkg_resources/tests/test_resources.py	2016-07-19 10:33:34.030885550 +0300
@@ -189,7 +189,7 @@
     def test_environment_marker_evaluation_called(self):
         """
         If one package foo requires bar without any extras,
-        markers should pass for bar without extras.
+        markers should pass for bar.
         """
         parent_req, = parse_requirements("foo")
         req, = parse_requirements("bar;python_version>='2'")
@@ -201,6 +201,14 @@
         req_extras = pkg_resources._ReqExtras({req: parent_req.extras})
         assert req_extras.markers_pass(req)
 
+        # extra should not be present in the marker namespace if
+        # no markers were supplied
+        parent_req, = parse_requirements("foo")
+        req, = parse_requirements("bar;extra==''")
+        req_extras = pkg_resources._ReqExtras({req: parent_req.extras})
+        with pytest.raises(packaging.markers.UndefinedEnvironmentName):
+            req_extras.markers_pass(req)
+
     def test_marker_evaluation_with_extras(self):
         """Extras are also evaluated as markers at resolution time."""
         ad = pkg_resources.Environment([])