Repository: sympy/sympy

Issue:
`diff` raises `SympifyError` since sympy version 1.10
Consider the following script:

~~~ python
import sympy

expr_str = "a*x+b"
expr = sympy.sympify(expr_str)
diff = expr.diff("x")

print(diff)
~~~

With sympy 1.9 the script prints `a` as expected. But sympy 1.10 now raises the following error:

~~~
Traceback (most recent call last):
  File ".../sympy_bug.py", line 5, in <module>
    expr.diff("x")
  File "...\lib\site-packages\sympy\core\expr.py", line 3528, in diff
    return _derivative_dispatch(self, *symbols, **assumptions)
  File "...\lib\site-packages\sympy\core\function.py", line 1923, in _derivative_dispatch
    return Derivative(expr, *variables, **kwargs)
  File "...\lib\site-packages\sympy\core\function.py", line 1307, in __new__
    v = _sympify(v)
  File "...\lib\site-packages\sympy\core\sympify.py", line 528, in _sympify
    return sympify(a, strict=True)
  File "...\lib\site-packages\sympy\core\sympify.py", line 449, in sympify
    raise SympifyError(a)
sympy.core.sympify.SympifyError: SympifyError: 'x'
~~~

Is this a bug or are we supposed to use `diff` differently now? I had a quick look at the changelog but I either overlooked it or it wasn't mentioned.

Discussion:

Patch:
diff --git a/sympy/core/function.py b/sympy/core/function.py
index b5392026a0..d08b678faf 100644
--- a/sympy/core/function.py
+++ b/sympy/core/function.py
@@ -47,7 +47,7 @@
 from .parameters import global_parameters
 from .rules import Transform
 from .singleton import S
-from .sympify import sympify, _sympify
+from .sympify import sympify
 
 from .sorting import default_sort_key, ordered
 from sympy.utilities.exceptions import (sympy_deprecation_warning,
@@ -1304,7 +1304,7 @@ def __new__(cls, expr, *variables, **kwargs):
                 variable_count.append(Tuple(v, count))
                 continue
 
-            v = _sympify(v)
+            v = sympify(v)
             if isinstance(v, Integer):
                 if i == 0:
                     raise ValueError("First variable cannot be a number: %i" % v)


Test patch:
diff --git a/sympy/core/tests/test_function.py b/sympy/core/tests/test_function.py
index 1c22e22b60..cde6fc6b3d 100644
--- a/sympy/core/tests/test_function.py
+++ b/sympy/core/tests/test_function.py
@@ -131,6 +131,8 @@ def test_diff_symbols():
     raises(TypeError, lambda: cos(x).diff((x, y)).variables)
     assert cos(x).diff((x, y))._wrt_variables == [x]
 
+    # issue 23222
+    assert sympify("a*x+b").diff("x") == sympify("a")
 
 def test_Function():
     class myfunc(Function):