nebius/SWE-bench-extra huggingface dataset:
Repository: pylhc/generic_parser

Issue:
Use name as flag
When creating parameters: If no flags are given, the name should be used as flag, preceded by "--" 

Comments:

Patch:
diff --git a/generic_parser/entrypoint_parser.py b/generic_parser/entrypoint_parser.py
index 5db3606..cacd5c3 100644
--- a/generic_parser/entrypoint_parser.py
+++ b/generic_parser/entrypoint_parser.py
@@ -330,7 +330,9 @@ class EntryPoint(object):
                                      "As entrypoint does not use 'const', the use is prohibited.")
 
             if param.get("flags", None) is None:
-                raise ParameterError(f"Parameter '{arg_name:s}' does not have flags.")
+                # if flags aren't supplied, it defaults to the name
+                LOG.debug(f'Missing flags parameter. Defaulting to --{arg_name}')
+                param['flags'] = [f'--{arg_name}']
 
     def _read_config(self, cfgfile_path, section=None):
         """ Get content from config file"""
diff --git a/requirements.txt b/requirements.txt
index 84ca099..541393c 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,6 +1,7 @@
-pytest>=3.6
+pytest>=5.2
 pytest-cov>=2.6
-hypothesis>=3.23.0
+hypothesis>=4.36.2
 travis-sphinx>=2.1.0
 Sphinx>=1.8.1
 sphinx-rtd-theme>=0.4.3
+attrs>=19.2.0


Test patch:
diff --git a/tests/test_entrypoint.py b/tests/test_entrypoint.py
index 6617584..291f9b7 100644
--- a/tests/test_entrypoint.py
+++ b/tests/test_entrypoint.py
@@ -69,11 +69,6 @@ def test_wrong_param_creation_name():
         EntryPoint([{"flags": "--flag"}])
 
 
-def test_wrong_param_creation_flags():
-    with pytest.raises(ParameterError):
-        EntryPoint([{"name": "test"}])
-
-
 def test_wrong_param_creation_other():
     with pytest.raises(TypeError):
         EntryPoint([{"name": "test", "flags": "--flag", "other": "unknown"}])
@@ -87,6 +82,32 @@ def test_choices_not_iterable():
                      }])
 
 
+def test_missing_flag_replaced_by_name():
+    ep = EntryPoint([{"name": "test"}])
+
+    assert len(ep.parameter[0]) == 2
+    assert ep.parameter[0]['flags'] == ['--test']
+    assert ep.parameter[0]['name'] == 'test'
+
+
+def test_missing_flag_replaced_by_name_in_multiple_lists():
+    ep = EntryPoint([{"name": "test"},
+                     {"name": "thermos_coffee"},
+                     {"name": "tee_kessel", "flags": ['--tee_kessel']}])
+
+    assert len(ep.parameter[0]) == 2
+    assert ep.parameter[0]['flags'] == ['--test']
+    assert ep.parameter[0]['name'] == 'test'
+
+    assert len(ep.parameter[1]) == 2
+    assert ep.parameter[1]['flags'] == ['--thermos_coffee']
+    assert ep.parameter[1]['name'] == 'thermos_coffee'
+
+    assert len(ep.parameter[2]) == 2
+    assert ep.parameter[2]['flags'] == ['--tee_kessel']
+    assert ep.parameter[2]['name'] == 'tee_kessel'
+
+
 # Argument Tests
Repository: pylover/sunrise

Issue:
Add subtraction styles to calculator class.

Comments:

Patch:
diff --git a/sunrise/actions.py b/sunrise/actions.py
index f70b909..44ca2dd 100644
--- a/sunrise/actions.py
+++ b/sunrise/actions.py
@@ -16,6 +16,7 @@ class Calculator(Action):
         self.operator = {
             'Add': '+',
             'Sub': '-',
+            'subtract': '-',
         }[operator] if operator not in self.operators else operator
         self.numbers = [a, b]
 
@@ -30,7 +31,13 @@ patterns = [
     ),
     (
         re.compile(
-            r'(?P<operator>Add|Sub)\s*(?P<a>\d+)\s*(with|by)\s*(?P<b>\d+)'
+            r'(?P<operator>Add)\s*(?P<a>\d+)\s*(with|by)\s*(?P<b>\d+)'
+        ),
+        Calculator
+    ),
+    (
+        re.compile(
+            r'(?P<operator>Sub|subtract)\s*(?P<b>\d+)\s*(from)\s*(?P<a>\d+)'
         ),
         Calculator
     ),


Test patch:
diff --git a/tests/test_calculator.py b/tests/test_calculator.py
index 7c837ea..36be715 100644
--- a/tests/test_calculator.py
+++ b/tests/test_calculator.py
@@ -4,5 +4,7 @@ from sunrise import do
 def test_parser():
     assert '6' == do('2 + 4')
     assert '6' == do('Add 2 by 4')
+    assert '2' == do('subtract 2 from 4')
+    assert '2' == do('4 - 2')
Repository: pypa/auditwheel

Issue:
libpython3.x is skipped but libpython3.xx is included
howdy,

i noticed when running auditwheel repair on a wheel with dependency on libpython3.8.so or libpython3.9.so, they are not added to the wheel libs directory, but libpython3.10.so and libpython3.11.so are added. I'm not very familiar with the project, but i suspect [the regex detecting libpython](https://github.com/pypa/auditwheel/blob/63c30761e6857491af50fbb1922ecfd4c034ef76/src/auditwheel/policy/external_references.py#L11) could be the culprit

Comments:

Patch:
diff --git a/src/auditwheel/policy/external_references.py b/src/auditwheel/policy/external_references.py
index 1c05b10..23afde8 100644
--- a/src/auditwheel/policy/external_references.py
+++ b/src/auditwheel/policy/external_references.py
@@ -8,7 +8,7 @@ from ..elfutils import filter_undefined_symbols, is_subdir
 from . import load_policies
 
 log = logging.getLogger(__name__)
-LIBPYTHON_RE = re.compile(r"^libpython\d\.\dm?.so(.\d)*$")
+LIBPYTHON_RE = re.compile(r"^libpython\d+\.\d+m?.so(.\d)*$")
 
 
 def lddtree_external_references(lddtree: dict, wheel_path: str) -> dict:


Test patch:
diff --git a/tests/unit/test_policy.py b/tests/unit/test_policy.py
index 9fa21c9..adbdad8 100644
--- a/tests/unit/test_policy.py
+++ b/tests/unit/test_policy.py
@@ -10,6 +10,7 @@ from auditwheel.policy import (
     get_policy_name,
     get_priority_by_name,
     get_replace_platforms,
+    lddtree_external_references,
 )
 
 
@@ -202,3 +203,32 @@ class TestPolicyAccess:
     def test_get_by_name_duplicate(self):
         with pytest.raises(RuntimeError):
             get_priority_by_name("duplicate")
+
+
+class TestLddTreeExternalReferences:
+    """Tests for lddtree_external_references."""
+
+    def test_filter_libs(self):
+        """Test the nested filter_libs function."""
+        filtered_libs = [
+            "ld-linux-x86_64.so.1",
+            "ld64.so.1",
+            "ld64.so.2",
+            "libpython3.7m.so.1.0",
+            "libpython3.9.so.1.0",
+            "libpython3.10.so.1.0",
+            "libpython999.999.so.1.0",
+        ]
+        unfiltered_libs = ["libfoo.so.1.0", "libbar.so.999.999.999"]
+        libs = filtered_libs + unfiltered_libs
+
+        lddtree = {
+            "realpath": "/path/to/lib",
+            "needed": libs,
+            "libs": {lib: {"needed": [], "realpath": "/path/to/lib"} for lib in libs},
+        }
+        full_external_refs = lddtree_external_references(lddtree, "/path/to/wheel")
+
+        # Assert that each policy only has the unfiltered libs.
+        for policy in full_external_refs:
+            assert set(full_external_refs[policy]["libs"]) == set(unfiltered_libs)
Repository: pypa/build

Issue:
Failing Windows 3.9.9 tests
Can someone with Windows experience take a look at why the Windows 3.9.9 tests are failing? Some context might be found at https://github.com/actions/setup-python/issues/267.

Comments:

Patch:
diff --git a/src/build/env.py b/src/build/env.py
index e6d22b5..80c42d8 100644
--- a/src/build/env.py
+++ b/src/build/env.py
@@ -92,7 +92,12 @@ class IsolatedEnvBuilder:
 
         :return: The isolated build environment
         """
-        self._path = tempfile.mkdtemp(prefix='build-env-')
+        # Call ``realpath`` to prevent spurious warning from being emitted
+        # that the venv location has changed on Windows. The username is
+        # DOS-encoded in the output of tempfile - the location is the same
+        # but the representation of it is different, which confuses venv.
+        # Ref: https://bugs.python.org/issue46171
+        self._path = os.path.realpath(tempfile.mkdtemp(prefix='build-env-'))
         try:
             # use virtualenv when available (as it's faster than venv)
             if _should_use_virtualenv():


Test patch:
diff --git a/tests/test_env.py b/tests/test_env.py
index 9b5506f..831d725 100644
--- a/tests/test_env.py
+++ b/tests/test_env.py
@@ -112,7 +112,7 @@ def test_isolated_env_log(mocker, caplog, package_test_flit):
         ('INFO', 'Installing packages in isolated environment... (something)'),
     ]
     if sys.version_info >= (3, 8):  # stacklevel
-        assert [(record.lineno) for record in caplog.records] == [105, 102, 193]
+        assert [(record.lineno) for record in caplog.records] == [105, 107, 198]
 
 
 @pytest.mark.isolated
Repository: pypa/hatch

Issue:
"Self-referential environments" raises error
Hi

Thank you for a very nice tool :)

Reference to documentation: [Self-referential environments](https://hatch.pypa.io/latest/config/environment/overview/#self-referential-environments)

Using config:
```toml
[tool.hatch.envs.lock]
template = "lock"
```

```bash
$ hatch --version
Hatch, version 1.4.0
$ hatch run lock:pip list
KeyError: 'type'
```

Comments:

Patch:
diff --git a/docs/history.md b/docs/history.md
index 8dde7476..f02541f2 100644
--- a/docs/history.md
+++ b/docs/history.md
@@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 
 ### Unreleased
 
+***Fixed:***
+
+- Fix non-detached inheritance disabling for environments
+
 ### [1.4.0](https://github.com/pypa/hatch/releases/tag/hatch-v1.4.0) - 2022-08-06 ### {: #hatch-v1.4.0 }
 
 ***Added:***
diff --git a/src/hatch/project/config.py b/src/hatch/project/config.py
index a5db13b8..a821723b 100644
--- a/src/hatch/project/config.py
+++ b/src/hatch/project/config.py
@@ -426,8 +426,7 @@ def expand_script_commands(script_name, commands, config, seen, active):
 def _populate_default_env_values(env_name, data, config, seen, active):
     if env_name in seen:
         return
-    elif data.get('detached', False):
-        ensure_valid_environment(data)
+    elif data.pop('detached', False):
         data['template'] = env_name
         data['skip-install'] = True
 
@@ -440,6 +439,7 @@ def _populate_default_env_values(env_name, data, config, seen, active):
         active.append(env_name)
         raise ValueError(f'Circular inheritance detected for field `tool.hatch.envs.*.template`: {" -> ".join(active)}')
     elif template_name == env_name:
+        ensure_valid_environment(data)
         seen.add(env_name)
         return
 


Test patch:
diff --git a/tests/project/test_config.py b/tests/project/test_config.py
index 3f68823d..ee64e86f 100644
--- a/tests/project/test_config.py
+++ b/tests/project/test_config.py
@@ -174,13 +174,22 @@ class TestEnvs:
             'baz': {'type': 'virtual', 'scripts': {'cmd1': 'bar', 'cmd2': 'baz'}},
         }
 
+    def test_self_referential(self, isolation):
+        env_config = {'default': {'option1': 'foo'}, 'bar': {'template': 'bar'}}
+        project_config = ProjectConfig(isolation, {'envs': env_config}, PluginManager())
+
+        assert project_config.envs == {
+            'default': {'type': 'virtual', 'option1': 'foo'},
+            'bar': {'type': 'virtual'},
+        }
+
     def test_detached(self, isolation):
         env_config = {'default': {'option1': 'foo'}, 'bar': {'detached': True}}
         project_config = ProjectConfig(isolation, {'envs': env_config}, PluginManager())
 
         assert project_config.envs == {
             'default': {'type': 'virtual', 'option1': 'foo'},
-            'bar': {'type': 'virtual', 'detached': True, 'skip-install': True},
+            'bar': {'type': 'virtual', 'skip-install': True},
         }
 
     def test_matrices_not_array(self, isolation):
Repository: pypa/setuptools_scm

Issue:
get_version(): normalize=False incompatible with several version schemes
running anything that calls this function with 
-release-branch-semver
-python-simplified-semver

an error is thrown:

e.g. `ValueError: <ScmVersion v2.0.0 dist=0 node=g17520db dirty=True branch=branch-name> can't be parsed as numeric version`

Comments:

Patch:
diff --git a/changelog.d/20240305_102047_allow_non_normalized_semver.md b/changelog.d/20240305_102047_allow_non_normalized_semver.md
new file mode 100644
index 0000000..f5d8567
--- /dev/null
+++ b/changelog.d/20240305_102047_allow_non_normalized_semver.md
@@ -0,0 +1,4 @@
+
+### Fixed
+
+- fix #1018: allow non-normalized versions for semver
diff --git a/src/setuptools_scm/version.py b/src/setuptools_scm/version.py
index 742abe6..0a36742 100644
--- a/src/setuptools_scm/version.py
+++ b/src/setuptools_scm/version.py
@@ -244,10 +244,13 @@ def guess_next_dev_version(version: ScmVersion) -> str:
 def guess_next_simple_semver(
     version: ScmVersion, retain: int, increment: bool = True
 ) -> str:
-    try:
-        parts = [int(i) for i in str(version.tag).split(".")[:retain]]
-    except ValueError:
-        raise ValueError(f"{version} can't be parsed as numeric version") from None
+    if isinstance(version.tag, _v.Version):
+        parts = list(version.tag.release[:retain])
+    else:
+        try:
+            parts = [int(i) for i in str(version.tag).split(".")[:retain]]
+        except ValueError:
+            raise ValueError(f"{version} can't be parsed as numeric version") from None
     while len(parts) < retain:
         parts.append(0)
     if increment:


Test patch:
diff --git a/testing/test_version.py b/testing/test_version.py
index 8a823d8..371c754 100644
--- a/testing/test_version.py
+++ b/testing/test_version.py
@@ -54,6 +54,11 @@ c_non_normalize = Configuration(version_cls=NonNormalizedVersion)
             "1.1.0.dev2",
             id="feature_in_branch",
         ),
+        pytest.param(
+            meta(NonNormalizedVersion("v1.0"), distance=2, branch="default", config=c),
+            "1.0.1.dev2",
+            id="non-normalized-allowed",
+        ),
     ],
 )
 def test_next_semver(version: ScmVersion, expected_next: str) -> None:
Repository: pypa/setuptools_scm

Issue:
setuptools_scm 3.0.6: `version_from_scm()` fails under Python2
When I invoke `setuptools_scm.version_from_scm()` within my Python 2 program, I get a stacktrace:

```
Traceback (most recent call last):
...
  File "/usr/local/lib/python2.7/dist-packages/setuptools_scm/__init__.py", line 28, in version_from_scm
    return _version_from_entrypoint(root, "setuptools_scm.parse_scm")
  File "/usr/local/lib/python2.7/dist-packages/setuptools_scm/__init__.py", line 44, in _version_from_entrypoint
    for ep in iter_matching_entrypoints(config.absolute_root, entrypoint):
AttributeError: 'str' object has no attribute 'absolute_root'
```

This error occurs with version 3.0.6.  Everything worked fine under 2.1.0.

Appears to have been introduced in PR #276, looks similar to #281.

Python 2 is still intended to be supported, right?

Thanks for your work on `setuptools_scm`!  Sorry some of us are still stuck on Python 2 :-/

Comments:

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 506e985..861d321 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,3 +1,8 @@
+v3.1.0
+=======
+
+* fix #297 - correct the invocation in version_from_scm and deprecate it as its exposed by accident
+
 v3.0.6
 ======
 * fix #295 - correctly handle selfinstall from tarballs
diff --git a/src/setuptools_scm/__init__.py b/src/setuptools_scm/__init__.py
index 49c0c4b..72b7b22 100644
--- a/src/setuptools_scm/__init__.py
+++ b/src/setuptools_scm/__init__.py
@@ -24,8 +24,14 @@ version = {version!r}
 
 
 def version_from_scm(root):
+    warnings.warn(
+        "version_from_scm is deprecated please use get_version",
+        category=DeprecationWarning,
+    )
+    config = Configuration()
+    config.root = root
     # TODO: Is it API?
-    return _version_from_entrypoint(root, "setuptools_scm.parse_scm")
+    return _version_from_entrypoint(config, "setuptools_scm.parse_scm")
 
 
 def _call_entrypoint_fn(config, fn):


Test patch:
diff --git a/testing/test_basic_api.py b/testing/test_basic_api.py
index 1a0fa78..c032d23 100644
--- a/testing/test_basic_api.py
+++ b/testing/test_basic_api.py
@@ -46,6 +46,11 @@ def test_root_parameter_creation(monkeypatch):
     setuptools_scm.get_version()
 
 
+def test_version_from_scm(wd):
+    with pytest.warns(DeprecationWarning, match=".*version_from_scm.*"):
+        setuptools_scm.version_from_scm(str(wd))
+
+
 def test_root_parameter_pass_by(monkeypatch, tmpdir):
     assert_root(monkeypatch, tmpdir)
     setuptools_scm.get_version(root=tmpdir.strpath)
Repository: pypa/setuptools_scm

Issue:
tag_regex not working with setuptools_scm 3.4.1
With setuptools_scm 3.4.1, custom tag_regex expressions are not working correctly.

My setup.py contains:

    ...
    setup_args["use_scm_version"] = {
        "tag_regex": r"^(?P<prefix>.*/)?(?P<version>\d+(?:\.\d+){1,2})$"
        }
    setup_args["setup_requires"] = ['setuptools_scm']

    setuptools.setup(**setup_args)

setuptools_scm 3.4.0 works:

    $ python3 setup.py --version
    0.4.1.dev7+gc2397c5'

With 3.4.1:

    $ python3 setup.py --version
    /home/kolbus/.local/lib/python3.6/site-packages/setuptools_scm/version.py:92: UserWarning: tag 'development/0.4.0' no version found
      warnings.warn("tag {!r} no version found".format(tag))
    Traceback (most recent call last):
    ...
      File "/home/kolbus/.local/lib/python3.6/site-packages/setuptools_scm/git.py", line 135, in parse
    branch=branch,
      File "/home/kolbus/.local/lib/python3.6/site-packages/setuptools_scm/version.py", line 205, in meta
        assert parsed_version is not None, "cant parse version %s" % tag
    AssertionError: cant parse version development/0.4.0



Comments:

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 8545f4f..5267e2b 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,3 +1,8 @@
+v3.4.2
+======
+
+* fix #395: correctly transfer tag regex in the Configuration constructor
+
 v3.4.1
 ======
 
diff --git a/src/setuptools_scm/config.py b/src/setuptools_scm/config.py
index 7dee1e4..139512d 100644
--- a/src/setuptools_scm/config.py
+++ b/src/setuptools_scm/config.py
@@ -66,7 +66,7 @@ class Configuration(object):
         self.fallback_version = fallback_version
         self.fallback_root = fallback_root
         self.parse = parse
-        self.tag_regex = DEFAULT_TAG_REGEX
+        self.tag_regex = tag_regex
         self.git_describe_command = git_describe_command
 
     @property


Test patch:
diff --git a/testing/test_config.py b/testing/test_config.py
index 38bc8f4..b8ea265 100644
--- a/testing/test_config.py
+++ b/testing/test_config.py
@@ -1,7 +1,7 @@
 from __future__ import unicode_literals
 
 from setuptools_scm.config import Configuration
-
+import re
 import pytest
 
 
@@ -26,3 +26,9 @@ def test_config_from_pyproject(tmpdir):
     fn = tmpdir / "pyproject.toml"
     fn.write_text("[tool.setuptools_scm]\n", encoding="utf-8")
     assert Configuration.from_file(str(fn))
+
+
+def test_config_regex_init():
+    tag_regex = re.compile(r"v(\d+)")
+    conf = Configuration(tag_regex=tag_regex)
+    assert conf.tag_regex is tag_regex
Repository: pypa/setuptools_scm

Issue:
enable version-tuples/lazy parsed versions in write_to contents
follow up to https://github.com/pytest-dev/pytest/pull/7605

a way to have easy static version tuples or a available layz parsed version to do version comparisation correctly is nice to have,
if only the string is there, users of a library are tempted into potentially hazardous solutions to compare versions too quick and too error prone

Comments:

Patch:
diff --git a/src/setuptools_scm/__init__.py b/src/setuptools_scm/__init__.py
index 6b22b28..beb7168 100644
--- a/src/setuptools_scm/__init__.py
+++ b/src/setuptools_scm/__init__.py
@@ -23,6 +23,7 @@ TEMPLATES = {
 # file generated by setuptools_scm
 # don't change, don't track in version control
 version = {version!r}
+version_tuple = {version_tuple!r}
 """,
     ".txt": "{version}",
 }
@@ -80,8 +81,19 @@ def dump_version(root, version, write_to, template=None):
                 os.path.splitext(target)[1], target
             )
         )
+
+    # version_tuple: each field is converted to an int if possible or kept as string
+    fields = tuple(version.split("."))
+    version_fields = []
+    for field in fields:
+        try:
+            v = int(field)
+        except ValueError:
+            v = field
+        version_fields.append(v)
+
     with open(target, "w") as fp:
-        fp.write(template.format(version=version))
+        fp.write(template.format(version=version, version_tuple=tuple(version_fields)))
 
 
 def _do_parse(config):


Test patch:
diff --git a/testing/test_basic_api.py b/testing/test_basic_api.py
index c5104f5..5111542 100644
--- a/testing/test_basic_api.py
+++ b/testing/test_basic_api.py
@@ -101,9 +101,13 @@ def test_dump_version(tmpdir):
 
     dump_version(sp, "1.0", "first.txt")
     assert tmpdir.join("first.txt").read() == "1.0"
-    dump_version(sp, "1.0", "first.py")
+
+    dump_version(sp, "1.0.dev42", "first.py")
     content = tmpdir.join("first.py").read()
-    assert repr("1.0") in content
+    lines = content.splitlines()
+    assert "version = '1.0.dev42'" in lines
+    assert "version_tuple = (1, 0, 'dev42')" in lines
+
     import ast
 
     ast.parse(content)
Repository: pypa/setuptools_scm

Issue:
v6 breaks on Centos7 due to older git
Hi,

Changes between v5 and v6 results in downstream packages failing to build/install on Centos7, e.g. black

Centos7 seems to come with git 1.8.3.1 which doesn't support the `%cI` format as used by `get_head_date()` resulting in the following error when using pre-commit+black:
```
File "/tmp/pip-build-env-y421rvu8/overlay/lib/python3.7/site-packages/setuptools_scm/git.py", line 124, in parse
        node_date = wd.get_head_date() or date.today()
      File "/tmp/pip-build-env-y421rvu8/overlay/lib/python3.7/site-packages/setuptools_scm/git.py", line 64, in get_head_date
        return datetime.strptime(date_part, r"%Y-%m-%d").date()
      File "/opt/checksec/canopy/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
        tt, fraction, gmtoff_fraction = _strptime(data_string, format)
      File "/opt/checksec/canopy/lib/python3.7/_strptime.py", line 359, in _strptime
        (data_string, format))
    ValueError: time data '%cI' does not match format '%Y-%m-%d'
```

Installing either a newer git or `setuptools_scm~=5.0` works around the issue.

Comments:

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 2bfe2d9..ecbcf81 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,3 +1,8 @@
+v6.0.1
+=======
+
+*  fix #537: drop node_date on old git to avoid errors on missing %cI
+
 v6.0.0
 ======
 
diff --git a/src/setuptools_scm/git.py b/src/setuptools_scm/git.py
index b1a85ab..c7f301b 100644
--- a/src/setuptools_scm/git.py
+++ b/src/setuptools_scm/git.py
@@ -61,6 +61,9 @@ class GitWorkdir:
             return
         # TODO, when dropping python3.6 use fromiso
         date_part = timestamp.split("T")[0]
+        if "%c" in date_part:
+            trace("git too old -> timestamp is ", timestamp)
+            return None
         return datetime.strptime(date_part, r"%Y-%m-%d").date()
 
     def is_shallow(self):


Test patch:
diff --git a/testing/test_git.py b/testing/test_git.py
index d934c02..8080574 100644
--- a/testing/test_git.py
+++ b/testing/test_git.py
@@ -8,7 +8,7 @@ from datetime import datetime
 from os.path import join as opj
 from setuptools_scm.file_finder_git import git_find_files
 from datetime import date
-
+from unittest.mock import patch, Mock
 
 pytestmark = pytest.mark.skipif(
     not has_command("git", warn=False), reason="git executable not found"
@@ -307,3 +307,12 @@ def test_git_getdate(wd):
     assert git_wd.get_head_date() == today
     meta = git.parse(os.fspath(wd.cwd))
     assert meta.node_date == today
+
+
+def test_git_getdate_badgit(
+    wd,
+):
+    wd.commit_testfile()
+    git_wd = git.GitWorkdir(os.fspath(wd.cwd))
+    with patch.object(git_wd, "do_ex", Mock(return_value=("%cI", "", 0))):
+        assert git_wd.get_head_date() is None