Repository: sympy/sympy

Issue:
Lambdify crashes on empty tuple
Sometimes I have a large set of expressions grouped in various tuples to be used in combination with CSE. However, I noticed that `lambidfy` actually crashes due to a simple `SyntaxError` if one of those tuples is empty. Here is a simple example:
```python
import sympy as sm
from sympy.printing.numpy import NumPyPrinter

a = sm.symbols("a")
sm.lambdify((a,), ((), (a,)), printer=NumPyPrinter)
```
This gives the following error in `lambdify`:
```
.../sympy/utilities/lambdify.py:903) in lambdify
    c = compile(funcstr, filename, 'exec')

  File <lambdifygenerated-2>:2
    return ((,), (a,),)
             ^
SyntaxError: invalid syntax
```

Discussion:

Patch:
diff --git a/.mailmap b/.mailmap
index 42af95d451..ea505c1ba9 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1276,6 +1276,7 @@ Sebastian Krause <sebastian.krause@gmx.de>
 Sebastian Kreft <skreft@gmail.com>
 Sebastian Krämer <basti.kr@gmail.com> basti.kr <devnull@localhost>
 Segev Finer <segev208@gmail.com>
+Senku <mohakmalviya2000@gmail.com>
 Sergey B Kirpichev <skirpichev@gmail.com>
 Sergey Pestov <pestov-sa@yandex.ru>
 Sergiu Ivanov <unlimitedscolobb@gmail.com>
diff --git a/sympy/utilities/lambdify.py b/sympy/utilities/lambdify.py
index edc3367120..a062903290 100644
--- a/sympy/utilities/lambdify.py
+++ b/sympy/utilities/lambdify.py
@@ -963,6 +963,8 @@ def _recursive_to_string(doprint, arg):
             left, right = "[", "]"
         elif isinstance(arg, tuple):
             left, right = "(", ",)"
+            if not arg:
+                return "()"
         else:
             raise NotImplementedError("unhandled type: %s, %s" % (type(arg), arg))
         return left +', '.join(_recursive_to_string(doprint, e) for e in arg) + right


Test patch:
diff --git a/sympy/utilities/tests/test_lambdify.py b/sympy/utilities/tests/test_lambdify.py
index 5659a49a49..6cf2d5dc57 100644
--- a/sympy/utilities/tests/test_lambdify.py
+++ b/sympy/utilities/tests/test_lambdify.py
@@ -1871,3 +1871,11 @@ class MatrixTestCase(LambdifyDocstringTestCase):
             docstring_limit=test_case.docstring_limit,
         )
         assert lambdified_expr.__doc__ == test_case.expected_docstring
+
+
+def test_lambdify_empty_tuple():
+    a = symbols("a")
+    expr = ((), (a,))
+    f = lambdify(a, expr)
+    result = f(1)
+    assert result == ((), (1,)), "Lambdify did not handle the empty tuple correctly."