Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multidict views C ext #275

Merged
merged 33 commits into from
Sep 23, 2018
Merged

Multidict views C ext #275

merged 33 commits into from
Sep 23, 2018

Conversation

iemelyanov
Copy link
Contributor

No description provided.

@webknjaz webknjaz removed their request for review August 16, 2018 13:09
@codecov
Copy link

codecov bot commented Aug 16, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@ca9121d). Click here to learn what that means.
The diff coverage is 73.39%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #275   +/-   ##
=========================================
  Coverage          ?   93.48%           
=========================================
  Files             ?       10           
  Lines             ?      936           
  Branches          ?        0           
=========================================
  Hits              ?      875           
  Misses            ?       61           
  Partials          ?        0
Impacted Files Coverage Δ
multidict/_multidict_base.py 73.39% <73.39%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ca9121d...b828f48. Read the comment docs.

multidict/_multidict.pyx Show resolved Hide resolved
static INLINE void
_init_view(_Multidict_ViewObject *self, PyObject *md)
{
self->md = md;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please incref md here and drop increfs from _init_view calls

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

PyObject *impl = NULL,
*iter = NULL;

if (self->md == NULL) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When self->md is NULL?

Anyway even if it could be (broken code?) -- better to raise an exception.
Returning None from __iter__ violates iterator protocol.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is useless check. I'll remove it.

Py_RETURN_NONE;
}

impl = _PyObject_CallMethodId(self->md, &PyId_impl, NULL);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check for impl == NULL is needed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same for any PyObject_Call*

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thx

0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
0, /* tp_doc */
0, /* tp_traverse */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MultiDict stores any objects as values.
As a consequence, it can have circular deps to itself.
This implies tp_traverse and tp_clear slot implementation for all views and iterators.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thx

return 0;
}

while ((item = PyIter_Next(iter)) != NULL) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If returned value is NULL you need to check for exception by PyErr_Occuired().
See https://docs.python.org/3/c-api/iter.html?highlight=pyiter_next#c.PyIter_Next for code example.

The same for other PyIter_Next() usages in the file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks

Copy link
Member

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks perfect!

Thanks!

@asvetlov asvetlov merged commit 08fe793 into aio-libs:master Sep 23, 2018
@asvetlov
Copy link
Member

Thanks!

aio-libs-github-bot bot pushed a commit that referenced this pull request Apr 6, 2021
Bumps [towncrier](https://github.com/hawkowl/towncrier) from 19.2.0 to 21.3.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/twisted/towncrier/blob/master/NEWS.rst">towncrier's changelog</a>.</em></p>
<blockquote>
<h1>towncrier 21.3.0 (2021-04-02)</h1>
<p>No significant changes since the previous release candidate.</p>
<h1>towncrier 21.3.0.rc1 (2021-03-21)</h1>
<h2>Features</h2>
<ul>
<li>Ticket number from file names will be stripped down to avoid ticket links such as <code>[#7](https://github.com/hawkowl/towncrier/issues/007)</code>. (<code>[#126](twisted/towncrier#126) &lt;https://github.com/hawkowl/towncrier/issues/126&gt;</code>_)</li>
<li>Allow definition of the project <code>version</code> and <code>name</code> in the configuration file.
This allows use of towncrier seamlessly with non-Python projects. (<code>[#165](twisted/towncrier#165) &lt;https://github.com/hawkowl/towncrier/issues/165&gt;</code>_)</li>
<li>Improve news fragment file name parsing to allow using file names like
<code>123.feature.1.ext</code> which are convenient when one wants to use an appropriate
extension (e.g. <code>rst</code>, <code>md</code>) to enable syntax highlighting. (<code>[#173](twisted/towncrier#173) &lt;https://github.com/hawkowl/towncrier/issues/173&gt;</code>_)</li>
<li>The new <code>--edit</code> option of the <code>create</code> subcommand launches an editor for entering the contents of the newsfragment. (<code>[#275](twisted/towncrier#275) &lt;https://github.com/hawkowl/towncrier/issues/275&gt;</code>_)</li>
<li>CPython 3.8 and 3.9 are now part of our automated test matrix and are officially supported. (<code>[#291](twisted/towncrier#291) &lt;https://github.com/hawkowl/towncrier/issues/291&gt;</code>_)</li>
<li>When searching for the project, first check for an existing importable instance.
This helps if the version is only available in the installed version and not the source. (<code>[#297](twisted/towncrier#297) &lt;https://github.com/hawkowl/towncrier/issues/297&gt;</code>_)</li>
<li>Support building with PEP 517. (<code>[#314](twisted/towncrier#314) &lt;https://github.com/hawkowl/towncrier/issues/314&gt;</code>_)</li>
</ul>
<h2>Bugfixes</h2>
<ul>
<li>Configuration errors found during command line execution now trigger a message to stderr and no longer show a traceback. (<code>[#84](twisted/towncrier#84) &lt;https://github.com/hawkowl/towncrier/issues/84&gt;</code>_)</li>
<li>A configuration error is triggered when the newsfragment files couldn't be discovered. (<code>[#85](twisted/towncrier#85) &lt;https://github.com/hawkowl/towncrier/issues/85&gt;</code>_)</li>
<li>Invoking towncrier as <code>python -m towncrier</code> works. (<code>[#163](twisted/towncrier#163) &lt;https://github.com/hawkowl/towncrier/issues/163&gt;</code>_)</li>
<li><code>check</code> subcommand defaults to UTF-8 encoding when <code>sys.stdout.encoding</code> is <code>None</code>.
This happens, for example, with Python 2 on GitHub Actions or when the output is piped. (<code>[#175](twisted/towncrier#175) &lt;https://github.com/hawkowl/towncrier/issues/175&gt;</code>_)</li>
<li>Specifying <code>title_format</code> disables default top line creation to avoid duplication. (<code>[#180](twisted/towncrier#180) &lt;https://github.com/hawkowl/towncrier/issues/180&gt;</code>_)</li>
</ul>
<h2>Improved Documentation</h2>
<ul>
<li>The README now mentions the possibility to name the configuration file
<code>towncrier.toml</code> (in addition to <code>pyproject.toml</code>). (<code>[#172](twisted/towncrier#172) &lt;https://github.com/hawkowl/towncrier/issues/172&gt;</code>_)</li>
<li><code>start_line</code> corrected to <code>start_string</code> in the readme to match the long standing implementation. (<code>[#277](twisted/towncrier#277) &lt;https://github.com/hawkowl/towncrier/issues/277&gt;</code>_)</li>
</ul>
<h1>towncrier 19.9.0 (2021-03-20)</h1>
<p>No significant changes.</p>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/twisted/towncrier/commit/eab34611b93a4ba6e3805cd546a674d88dbd43cf"><code>eab3461</code></a> Update NEWS.rst</li>
<li><a href="https://github.com/twisted/towncrier/commit/bd963c351853d8977cd37c501b2b1b85d7cb0217"><code>bd963c3</code></a> add back the newsfragment...</li>
<li><a href="https://github.com/twisted/towncrier/commit/3bf4479562f0cc6ff828fe93fffb94fadc4c731d"><code>3bf4479</code></a> Bump version to 21.3.0</li>
<li><a href="https://github.com/twisted/towncrier/commit/3237ebd09527cecfd758c0fb472a3f5c7ccb1acb"><code>3237ebd</code></a> remove misc section</li>
<li><a href="https://github.com/twisted/towncrier/commit/6eab89476cd4b3849563496c19d07905109c9f61"><code>6eab894</code></a> Correct underlines setting to toml in readme</li>
<li><a href="https://github.com/twisted/towncrier/commit/4143e0ff55177cca5747d18624d614e593ebe3c3"><code>4143e0f</code></a> add 332.misc</li>
<li><a href="https://github.com/twisted/towncrier/commit/05eea3f2240bfebee4522e1c1180893f7a79a509"><code>05eea3f</code></a> Release 21.3.0rc1</li>
<li><a href="https://github.com/twisted/towncrier/commit/2841c12f2e7ebfc40d9cc3228ca468d339225549"><code>2841c12</code></a> Release 19.9.0 (<a href="https://github-redirect.dependabot.com/hawkowl/towncrier/issues/331">#331</a>)</li>
<li><a href="https://github.com/twisted/towncrier/commit/7267fb56e2a34b4f81b4e0005e3f4eeddaa71b2b"><code>7267fb5</code></a> twisted-alike (so similar) automatic publishing on gha (<a href="https://github-redirect.dependabot.com/hawkowl/towncrier/issues/315">#315</a>)</li>
<li><a href="https://github.com/twisted/towncrier/commit/499c8f7990f82d7decd32f139ec7a1c2d1b25719"><code>499c8f7</code></a> use incremental to canonicalize versions for release (<a href="https://github-redirect.dependabot.com/hawkowl/towncrier/issues/329">#329</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/hawkowl/towncrier/compare/19.2.0...21.3.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=towncrier&package-manager=pip&previous-version=19.2.0&new-version=21.3.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants