Skip to content

Commit

Permalink
Merge branch 'master' into add-3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Dec 26, 2023
2 parents 927cc3b + 780a1e1 commit b3c777f
Show file tree
Hide file tree
Showing 13 changed files with 280 additions and 45 deletions.
18 changes: 14 additions & 4 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
version: 2
---

formats: all
version: 2

build:
image: latest
os: ubuntu-22.04
tools:
python: >-
3.7
python:
version: 3.7
install:
- requirements: requirements/doc.txt

sphinx:
builder: dirhtml
configuration: docs/conf.py
fail_on_warning: true

...
39 changes: 39 additions & 0 deletions CHANGES/.TEMPLATE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{# TOWNCRIER TEMPLATE #}
{% for section, _ in sections.items() %}
{% set underline = underlines[0] %}{% if section %}{{section}}
{{ underline * section|length }}{% set underline = underlines[1] %}

{% endif %}

{% if sections[section] %}
{% for category, val in definitions.items() if category in sections[section]%}
{{ definitions[category]['name'] }}
{{ underline * definitions[category]['name']|length }}

{% if definitions[category]['showcontent'] %}
{% for text, pr_issue_numbers in sections[section][category].items() %}
- {{ text + '\n' }}

*Related issues and pull requests on GitHub:*
{{ pr_issue_numbers | join(', ') }}.

{% endfor %}
{% else %}
- {{ sections[section][category]['']|join(', ') }}

{% endif %}
{% if sections[section][category]|length == 0 %}
No significant changes.

{% else %}
{% endif %}

{% endfor %}
{% else %}
No significant changes.


{% endif %}
{% endfor %}
----
{{ '\n' * 2 }}
28 changes: 28 additions & 0 deletions CHANGES/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
*
!.TEMPLATE.rst
!.gitignore
!README.rst
!*.bugfix
!*.bugfix.rst
!*.bugfix.*.rst
!*.breaking
!*.breaking.rst
!*.breaking.*.rst
!*.contrib
!*.contrib.rst
!*.contrib.*.rst
!*.deprecation
!*.deprecation.rst
!*.deprecation.*.rst
!*.doc
!*.doc.rst
!*.doc.*.rst
!*.feature
!*.feature.rst
!*.feature.*.rst
!*.misc
!*.misc.rst
!*.misc.*.rst
!*.packaging
!*.packaging.rst
!*.packaging.*.rst
2 changes: 2 additions & 0 deletions CHANGES/864.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Upgraded the C-API macros that have been deprecated in
Python 3.9 and later removed in 3.13 -- :user:`webknjaz`.
25 changes: 19 additions & 6 deletions CHANGES/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,32 @@ linking parts of the docs or external sites.
Finally, name your file following the convention that Towncrier
understands: it should start with the number of an issue or a
PR followed by a dot, then add a patch type, like ``feature``,
``doc``, ``misc`` etc., and add ``.rst`` as a suffix. If you
``doc``, ``contrib`` etc., and add ``.rst`` as a suffix. If you
need to add more than one fragment, you may add an optional
sequence number (delimited with another period) between the type
and the suffix.

In general the name will follow ``<pr_number>.<category>.rst`` pattern,
where the categories are:

- ``feature``: Any new feature
- ``bugfix``: A bug fix
- ``doc``: A change to the documentation
- ``misc``: Changes internal to the repo like CI, test and build changes
- ``removal``: For deprecations and removals of an existing feature or behavior
- ``bugfix``: A bug fix for something we deemed an improper undesired
behavior that got corrected in the release to match pre-agreed
expectations.
- ``feature``: A new behavior, public APIs. That sort of stuff.
- ``deprecation``: A declaration of future API removals and breaking
changes in behavior.
- ``breaking``: When something public gets removed in a breaking way.
Could be deprecated in an earlier release.
- ``doc``: Notable updates to the documentation structure or build
process.
- ``packaging``: Notes for downstreams about unobvious side effects
and tooling. Changes in the test invocation considerations and
runtime assumptions.
- ``contrib``: Stuff that affects the contributor experience. e.g.
Running tests, building the docs, setting up the development
environment.
- ``misc``: Changes that are hard to assign to any of the above
categories.

A pull request may have more than one of these components, for example
a code change may introduce a new feature that deprecates an old
Expand Down
15 changes: 15 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
.. _multidict_changes:

=========
Changelog
=========

.. only:: not is_release

To be included in v\ |release| (if present)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. towncrier-draft-entries:: |release| [UNRELEASED DRAFT]

Released versions
^^^^^^^^^^^^^^^^^

.. include:: ../CHANGES.rst
:start-after: .. towncrier release notes start

.. include:: ../HISTORY.rst
34 changes: 28 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,25 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import codecs
import datetime
import os
import re
import sys
from pathlib import Path

_docs_path = os.path.dirname(__file__)
_version_path = os.path.abspath(
os.path.join(_docs_path, "..", "multidict", "__init__.py")
PROJECT_ROOT_DIR = Path(__file__).parents[1].resolve()
IS_RELEASE_ON_RTD = (
os.getenv("READTHEDOCS", "False") == "True"
and os.environ["READTHEDOCS_VERSION_TYPE"] == "tag"
)
with codecs.open(_version_path, "r", "latin1") as fp:
if IS_RELEASE_ON_RTD:
tags.add("is_release")


_docs_path = Path(__file__).parent
_version_path = _docs_path / ".." / "multidict" / "__init__.py"


with _version_path.open(encoding="utf-8") as fp:
try:
_version_info = re.search(
r'^__version__ = "'
Expand All @@ -49,10 +57,13 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
# stdlib-party extensions:
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
# Third-party extensions:
"alabaster",
"sphinxcontrib.towncrier.ext", # provides `towncrier-draft-entries` directive
]


Expand Down Expand Up @@ -103,6 +114,10 @@
# The full version, including alpha/beta/rc tags.
release = "{major}.{minor}.{patch}-{tag}".format(**_version_info)

rst_epilog = f"""
.. |project| replace:: {project}
""" # pylint: disable=invalid-name

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
# language = None
Expand Down Expand Up @@ -340,3 +355,10 @@

# If true, do not generate a @detailmenu in the "Top" node's menu.
# texinfo_no_detailmenu = False

# -- Options for towncrier_draft extension -----------------------------------

towncrier_draft_autoversion_mode = "draft" # or: 'sphinx-version', 'sphinx-release'
towncrier_draft_include_empty = True
towncrier_draft_working_directory = PROJECT_ROOT_DIR
towncrier_draft_config_path = "pyproject.toml" # relative to cwd
28 changes: 26 additions & 2 deletions multidict/_multidict.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,13 +709,21 @@ static inline void
multidict_tp_dealloc(MultiDictObject *self)
{
PyObject_GC_UnTrack(self);
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 9
Py_TRASHCAN_BEGIN(self, multidict_tp_dealloc)
#else
Py_TRASHCAN_SAFE_BEGIN(self);
#endif
if (self->weaklist != NULL) {
PyObject_ClearWeakRefs((PyObject *)self);
};
pair_list_dealloc(&self->pairs);
Py_TYPE(self)->tp_free((PyObject *)self);
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 9
Py_TRASHCAN_END // there should be no code after this
#else
Py_TRASHCAN_SAFE_END(self);
#endif
}

static inline int
Expand Down Expand Up @@ -777,9 +785,12 @@ multidict_add(MultiDictObject *self, PyObject *const *args,
return NULL;
}
#else
static _PyArg_Parser _parser = {NULL, _keywords, "add", 0};
static _PyArg_Parser _parser = {
.keywords = _keywords,
.fname = "add",
.kwtuple = NULL,
};
PyObject *argsbuf[2];

args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames,
&_parser, 2, 2, 0, argsbuf);
if (!args) {
Expand Down Expand Up @@ -1655,6 +1666,9 @@ getversion(PyObject *self, PyObject *md)
static inline void
module_free(void *m)
{
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 9
Py_CLEAR(multidict_str_lower);
#endif
Py_CLEAR(collections_abc_mapping);
Py_CLEAR(collections_abc_mut_mapping);
Py_CLEAR(collections_abc_mut_multi_mapping);
Expand Down Expand Up @@ -1683,6 +1697,13 @@ static PyModuleDef multidict_module = {
PyMODINIT_FUNC
PyInit__multidict()
{
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 9
multidict_str_lower = PyUnicode_InternFromString("lower");
if (multidict_str_lower == NULL) {
goto fail;
}
#endif

PyObject *module = NULL,
*reg_func_call_result = NULL;

Expand Down Expand Up @@ -1813,6 +1834,9 @@ PyInit__multidict()
return module;

fail:
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 9
Py_XDECREF(multidict_str_lower);
#endif
Py_XDECREF(collections_abc_mapping);
Py_XDECREF(collections_abc_mut_mapping);
Py_XDECREF(collections_abc_mut_multi_mapping);
Expand Down
4 changes: 4 additions & 0 deletions multidict/_multilib/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
extern "C" {
#endif

#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 9
static PyObject *multidict_str_lower = NULL;
#else
_Py_IDENTIFIER(lower);
#endif

/* We link this module statically for convenience. If compiled as a shared
library instead, some compilers don't allow addresses of Python objects
Expand Down
4 changes: 4 additions & 0 deletions multidict/_multilib/istr.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ istr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (!ret) {
goto fail;
}
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 9
s = PyObject_CallMethodNoArgs(ret, multidict_str_lower);
#else
s =_PyObject_CallMethodId(ret, &PyId_lower, NULL);
#endif
if (!s) {
goto fail;
}
Expand Down
Loading

0 comments on commit b3c777f

Please sign in to comment.