Repository: sympy/sympy

Issue:
solve dict=True ignored
```
In [22]: solve(Eq(2*x,1), dict=true)
Out[22]: [{x: 1/2}]

In [23]: solve([Eq(x**2-1,0),Gt(x,0)],(x,),dict=True)
Out[23]: x = 1
```

Discussion:

Patch:
diff --git a/sympy/ntheory/factor_.py b/sympy/ntheory/factor_.py
index 8a07346681..0cc90a688d 100644
--- a/sympy/ntheory/factor_.py
+++ b/sympy/ntheory/factor_.py
@@ -1178,8 +1178,7 @@ def factorint(n, limit=None, use_trial=True, use_rho=True, use_pm1=True,
                     facs = factorint(r, limit=limit, use_trial=use_trial,
                                      use_rho=use_rho, use_pm1=use_pm1,
                                      verbose=verbose)
-                    for k, v in facs.items():
-                        factors[k] = factors.get(k, 0) + v
+                    factors.update(facs)
                 raise StopIteration
 
             # ...see if factorization can be terminated
diff --git a/sympy/printing/gtk.py b/sympy/printing/gtk.py
index 02a63e58da..000155c0fc 100644
--- a/sympy/printing/gtk.py
+++ b/sympy/printing/gtk.py
@@ -1,18 +1,20 @@
 from __future__ import print_function, division
 
 from sympy.printing.mathml import mathml
-from sympy.utilities.mathml import c2p
 import tempfile
-import subprocess
+import os
 
 
 def print_gtk(x, start_viewer=True):
     """Print to Gtkmathview, a gtk widget capable of rendering MathML.
 
-    Needs libgtkmathview-bin"""
-    with tempfile.NamedTemporaryFile('w') as file:
+    Needs libgtkmathview-bin
+    """
+    from sympy.utilities.mathml import c2p
+
+    tmp = tempfile.mkstemp()  # create a temp file to store the result
+    with open(tmp, 'wb') as file:
         file.write(c2p(mathml(x), simple=True))
-        file.flush()
 
-        if start_viewer:
-            subprocess.check_call(('mathmlviewer', file.name))
+    if start_viewer:
+        os.system("mathmlviewer " + tmp)
diff --git a/sympy/solvers/solvers.py b/sympy/solvers/solvers.py
index f5a9d80009..89a35f7fb7 100644
--- a/sympy/solvers/solvers.py
+++ b/sympy/solvers/solvers.py
@@ -58,6 +58,7 @@
 
 from types import GeneratorType
 from collections import defaultdict
+import itertools
 import warnings
 
 
@@ -983,6 +984,30 @@ def _sympified_list(w):
             f[i] = fi
 
         if fi.is_Relational:
+            if flags.get('dict', False):
+                solution = reduce_inequalities(f, symbols=symbols)
+                if isinstance(solution, Equality):
+                    return [{solution.lhs: solution.rhs}]
+                solution = list(solution.args)
+                for sol in solution:
+                    # Behavior for types like StrictLessThan is not defined
+                    if not isinstance(sol, (Or, Equality)):
+                        warnings.warn(filldedent('''
+                            Warning: Ignoring dict=True due to
+                            incompatible type of %s.''' % sol))
+                        return reduce_inequalities(f, symbols=symbols)
+                intermediate = [sol for sol in solution
+                                if isinstance(sol, Equality)]
+                solution[:] = [sol.args for sol in solution
+                               if sol not in intermediate]
+                solutions = [intermediate + list(sol)
+                             for sol in itertools.product(*solution)]
+                for i in range(len(solutions)):
+                    ele = {}
+                    for sol in solutions[i]:
+                        ele[sol.lhs] = sol.rhs
+                    solutions[i] = ele
+                return [] if solutions == [{}] else solutions
             return reduce_inequalities(f, symbols=symbols)
 
         if isinstance(fi, Poly):


Test patch:
diff --git a/sympy/ntheory/tests/test_factor_.py b/sympy/ntheory/tests/test_factor_.py
index 20ba14e161..34cd6b8f84 100644
--- a/sympy/ntheory/tests/test_factor_.py
+++ b/sympy/ntheory/tests/test_factor_.py
@@ -1,5 +1,5 @@
 from sympy import (Mul, S, Pow, Symbol, summation, Dict,
-                   factorial as fac, sqrt)
+    factorial as fac)
 from sympy.core.evalf import bitcount
 from sympy.core.numbers import Integer, Rational
 from sympy.core.compatibility import long, range
@@ -161,11 +161,6 @@ def test_factorint():
     assert factorint(64015937) == {7993: 1, 8009: 1}
     assert factorint(2**(2**6) + 1) == {274177: 1, 67280421310721: 1}
 
-    #issue 17676
-    assert factorint(28300421052393658575) == {3: 1, 5: 2, 11: 2, 43: 1, 2063: 2, 4127: 1, 4129: 1}
-    assert factorint(2063**2 * 4127**1 * 4129**1) == {2063: 2, 4127: 1, 4129: 1}
-    assert factorint(2347**2 * 7039**1 * 7043**1) == {2347: 2, 7039: 1, 7043: 1}
-
     assert factorint(0, multiple=True) == [0]
     assert factorint(1, multiple=True) == []
     assert factorint(-1, multiple=True) == [-1]
diff --git a/sympy/solvers/tests/test_solvers.py b/sympy/solvers/tests/test_solvers.py
index 0b98a39428..a04b6fb470 100644
--- a/sympy/solvers/tests/test_solvers.py
+++ b/sympy/solvers/tests/test_solvers.py
@@ -175,6 +175,16 @@ def test_solve_args():
     assert solve([x-1, False], [x], set=True) == ([], set())
 
 
+def test_solve_dict():
+    assert solve(Eq(2*x,1), dict=True) == [{x: S(1)/2}]
+    assert solve([Eq(x**2-1, 0), Gt(x, 0)], (x,), dict=True) == [{x: 1}]
+    assert solve([Eq(x**3-6*x**2+11*x-6, 0), Eq(y**2, 1), Eq(z, 1)],
+            (x, y, z,), dict=True) == [{x: 1, y: -1, z: 1}, {x: 1, y: 1, z: 1},
+                                       {x: 2, y: -1, z: 1}, {x: 2, y: 1, z: 1},
+                                       {x: 3, y: -1, z: 1}, {x: 3, y: 1, z: 1}]
+    assert solve(Gt(x, 0), (x,), dict=True) == And(Lt(0, x), Lt(x, oo))
+
+
 def test_solve_polynomial1():
     assert solve(3*x - 2, x) == [Rational(2, 3)]
     assert solve(Eq(3*x, 2), x) == [Rational(2, 3)]