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 #153761
checks-py2

00:04:03

passed #153762
checks-py3

00:04:09

passed #153763
rust-cargo-test-py2

00:02:27

passed #153764
rust-cargo-test-py3

00:01:27

failed #153765
test-py2

00:21:00

passed #153771
test-py2-chg

00:22:35

failed #153767
test-py2-pure

01:00:32

passed #153769
test-py2-rust

00:22:38

failed #153766
test-py3

00:12:50

passed #153772
test-py3-chg

00:07:53

passed #153768
test-py3-pure

00:12:53

passed #153770
test-py3-rust

00:13:51

 
  Phabricator
skipped #153773
phabricator-refresh
 
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