cext: add Python 3.10 support

* Replace "Py_TYPE(obj) = type;" with "Py_SET_TYPE(obj, type);"
* Add pythoncapi_compat.h header file to get Py_SET_TYPE() on Python
  2.7-3.8. Header file added to mercurial/ and
  contrib/python-zstandard/zstd/common/.

In Python 3.10, Py_TYPE(obj) must not longer be used as an l-value.

pythoncapi_compat.h comes from:
https://github.com/pythoncapi/pythoncapi_compat

Differential Revision: https://phab.mercurial-scm.org/D9825
13 jobs for topic/default/python310 in 60 minutes and 33 seconds (queued for 3 seconds)
Status Job ID Name Coverage
  Tests
passed checks-py2 #153761

00:04:03

passed checks-py3 #153762

00:04:09

passed rust-cargo-test-py2 #153763

00:02:27

passed rust-cargo-test-py3 #153764

00:01:27

failed test-py2 #153765

00:21:00

passed test-py2-chg #153771

00:22:35

failed test-py2-pure #153767

01:00:32

passed test-py2-rust #153769

00:22:38

failed test-py3 #153766

00:12:50

passed test-py3-chg #153772

00:07:53

passed test-py3-pure #153768

00:12:53

passed test-py3-rust #153770

00:13:51

 
  Phabricator
skipped phabricator-refresh #153773
 
Name Stage Failure
failed
test-py2-pure Tests The script exceeded the maximum execution time set for the job
$ HGMODULEPOLICY="$TEST_HGMODULEPOLICY" "$PYTHON" tests/run-tests.py --color=always $RUNTEST_ARGS
running 948 tests using 32 parallel processes
ssssssssssssssss.......................................ssss.........s.....s.s...............s...........s.s............s..........s..............................................s........................................s.........................................................s..........................s...................................s........................s.s..s.......ss.s...ssss.........s....................s.....s.............................................s.........s...s.............s............................s........s.....s...ss..........s...............s.........................................................s.......................s...................s............................s....s............................................................................s....................s.......s................s.s.....s........s...s...............s.....s................................s..............................s......
WARNING: Timed out waiting for logs to finish copying from container
Running after_script
WARNING: Failed to inspect build container c216502c892065b212e0a0b3222aac02c0c1fa3aa0c0b6a705148ba596be1a72 context deadline exceeded (docker_command.go:77:0s)
Pulling docker image registry.heptapod.net/mercurial/ci-images/mercurial-core:latest ...
Uploading artifacts for failed job
Pulling docker image octobus/heptapod-runner-helper:x86_64-cce91b92a7cb ...
ERROR: Job failed: execution took longer than 1h0m0s seconds
failed
test-py2 Tests
Skipped test-sparse-fsmonitor.t: skipped
Skipped test-sparse-revlog.t: missing artifact, run "/tmp/mercurial-ci/tests/artifacts/scripts/generate-churning-bundle.py"
Skipped test-verify-repo-operations.py: missing feature: allow slow tests (use --allow-slow-tests)
Failed test-http.t: timed out
# Ran 877 tests, 71 skipped, 1 failed.
python hash seed: 3771705732
Running after_script
Uploading artifacts for failed job
ERROR: Job failed: exit code 1
failed
test-py3 Tests
Skipped test-sparse-fsmonitor.t: skipped
Skipped test-sparse-revlog.t: missing artifact, run "/tmp/mercurial-ci/tests/artifacts/scripts/generate-churning-bundle.py"
Skipped test-verify-repo-operations.py: missing feature: allow slow tests (use --allow-slow-tests)
Failed test-manifest.t: output changed
# Ran 872 tests, 76 skipped, 1 failed.
python hash seed: 206874798
Running after_script
Uploading artifacts for failed job
ERROR: Job failed: exit code 1