Repository: pypa/setuptools

Issue:
[BUG] namespace_packages deprecation warning: TypeError: expected string or bytes-like object
### setuptools version

62.3.0

### Python version

3.10

### OS

macOS

### Additional environment information

_No response_

### Description

Calling the `setup` function of a package using the `namespace_packages` parameter raises an error rather than the expected `SetuptoolsDeprecationWarning`.

https://github.com/pypa/setuptools/blob/1b7642be56c767bf064c2d0ab1bbd16f8ca3be38/setuptools/dist.py#L283-L287
raises a `TypeError: expected string or bytes-like object` on line 287 because `msg` is a tuple.

### Expected behavior

I expect a `SetuptoolsDeprecationWarning` to be raised, not an error.

### How to Reproduce

`python -m build --wheel` on a package that is using the deprecated `namespace_packages` option.

### Output

```console
$ python -m build --wheel
* Creating virtualenv isolated environment...
* Installing packages in isolated environment... (babel, cython, numpy==1.17.3; python_version=="3.8", numpy==1.19.3; python_version=="3.9", numpy==1.21.3; python_version=="3.10", setuptools>=45, setuptools_scm>=6.4.0, wheel)
* Getting dependencies for wheel...
Traceback (most recent call last):
  File "/Users/emily/miniconda3/envs/main/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 363, in <module>
    main()
  File "/Users/emily/miniconda3/envs/main/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 345, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/Users/emily/miniconda3/envs/main/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
    return hook(config_settings)
  File "/private/var/folders/zh/dy02ljyd4mj5_nfm158hwcr00000gn/T/build-env-sif8cxfe/lib/python3.10/site-packages/setuptools/build_meta.py", line 177, in get_requires_for_build_wheel
    return self._get_build_requires(
  File "/private/var/folders/zh/dy02ljyd4mj5_nfm158hwcr00000gn/T/build-env-sif8cxfe/lib/python3.10/site-packages/setuptools/build_meta.py", line 159, in _get_build_requires
    self.run_setup()
  File "/private/var/folders/zh/dy02ljyd4mj5_nfm158hwcr00000gn/T/build-env-sif8cxfe/lib/python3.10/site-packages/setuptools/build_meta.py", line 174, in run_setup
    exec(compile(code, __file__, 'exec'), locals())
  File "setup.py", line 65, in <module>
    setup(
  File "/private/var/folders/zh/dy02ljyd4mj5_nfm158hwcr00000gn/T/build-env-sif8cxfe/lib/python3.10/site-packages/setuptools/__init__.py", line 87, in setup
    return distutils.core.setup(**attrs)
  File "/private/var/folders/zh/dy02ljyd4mj5_nfm158hwcr00000gn/T/build-env-sif8cxfe/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 109, in setup
    _setup_distribution = dist = klass(attrs)
  File "/private/var/folders/zh/dy02ljyd4mj5_nfm158hwcr00000gn/T/build-env-sif8cxfe/lib/python3.10/site-packages/setuptools/dist.py", line 477, in __init__
    _Distribution.__init__(
  File "/private/var/folders/zh/dy02ljyd4mj5_nfm158hwcr00000gn/T/build-env-sif8cxfe/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 293, in __init__
    self.finalize_options()
  File "/private/var/folders/zh/dy02ljyd4mj5_nfm158hwcr00000gn/T/build-env-sif8cxfe/lib/python3.10/site-packages/setuptools/dist.py", line 901, in finalize_options
    ep(self)
  File "/private/var/folders/zh/dy02ljyd4mj5_nfm158hwcr00000gn/T/build-env-sif8cxfe/lib/python3.10/site-packages/setuptools/dist.py", line 922, in _finalize_setup_keywords
    ep.load()(self, ep.name, value)
  File "/private/var/folders/zh/dy02ljyd4mj5_nfm158hwcr00000gn/T/build-env-sif8cxfe/lib/python3.10/site-packages/setuptools/dist.py", line 287, in check_nsp
    warnings.warn(msg, SetuptoolsDeprecationWarning)
TypeError: expected string or bytes-like object

ERROR Backend subproccess exited when trying to invoke get_requires_for_build_wheel
```



Discussion:

Resolving patch:
diff --git a/setuptools/dist.py b/setuptools/dist.py
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -282,7 +282,7 @@ def check_nsp(dist, attr, value):
             )
         msg = (
             "The namespace_packages parameter is deprecated, "
-            "consider using implicit namespaces instead (PEP 420).",
+            "consider using implicit namespaces instead (PEP 420)."
         )
         warnings.warn(msg, SetuptoolsDeprecationWarning)
 


Test patch: