| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
warnings.warn_explicit() (GH-97803)
In `_warnings.c`, in the C equivalent of `warnings.warn_explicit()`, if the module globals are given (and not None), the warning will attempt to get the source line for the issued warning. To do this, it needs the module's loader.
Previously, it would only look up `__loader__` in the module globals. In https://github.com/python/cpython/issues/86298 we want to defer to the `__spec__.loader` if available.
The first step on this journey is to check that `loader == __spec__.loader` and issue another warning if it is not. This commit does that.
Since this is a PoC, only manual testing for now.
```python
# /tmp/foo.py
import warnings
import bar
warnings.warn_explicit(
'warning!',
RuntimeWarning,
'bar.py', 2,
module='bar knee',
module_globals=bar.__dict__,
)
```
```python
# /tmp/bar.py
import sys
import os
import pathlib
# __loader__ = pathlib.Path()
```
Then running this: `./python.exe -Wdefault /tmp/foo.py`
Produces:
```
bar.py:2: RuntimeWarning: warning!
import os
```
Uncomment the `__loader__ = ` line in `bar.py` and try it again:
```
sys:1: ImportWarning: Module bar; __loader__ != __spec__.loader (<_frozen_importlib_external.SourceFileLoader object at 0x109f7dfa0> != PosixPath('.'))
bar.py:2: RuntimeWarning: warning!
import os
```
Automerge-Triggered-By: GH:warsaw
|
|
|
| |
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
|
|
|
|
|
| |
Remove the open issues section from the import reference
Tracking in https://github.com/python/cpython/issues/97850 instead.
|
|
|
| |
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
|
|
|
|
|
|
|
| |
`__spec__.parent` (#97879)
Also remove `importlib.util.set_package()` which was already slated for removal.
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
|
|
|
|
|
| |
:c:type:`<C type>` -> :c:expr:`<C type>`
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* gh-95975: Move except/*/finally ref labels to more precise locations
* Add section headers to fix :keyword: role and aid navigation
* Move see also to the introduction rather than a particular subsection
* Fix other minor Sphinx syntax issues with except
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
* Suppress redundant link to same section for except too
* Don't link try/except/else/finally keywords if in the same section
* Format try/except/finally as keywords in modified sections
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
|
|
|
|
| |
generator.throw (GH-96428)
|
| |
|
|
|
|
| |
This represents the official SC stance, see
https://github.com/python/steering-council/issues/142#issuecomment-1252172695
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* gh-95994: clarify escaped newlines.
* Rephrase ambiguous sentence.
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
* Use `<newline>` in escape sequences table.
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(#94624)
* gh-94619: Remove long deprecated methods module_repr() and load_module()
Closes #94619
* Update Misc/NEWS.d/next/Library/2022-07-06-14-57-33.gh-issue-94619.PRqKVX.rst
Fix typo
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Brett Cannon <brett@python.org>
|
|
|
|
|
|
|
|
|
|
| |
(GH-95527)
If an HTTP link is redirected to a same looking HTTPS link, the latter can
be used directly without changes in readability and behavior.
It protects from a men-in-the-middle attack.
This change does not affect Python examples.
|
| |
|
|
|
|
|
|
| |
Support for bytes broke sometime between Python 3.2 and 3.6 and has been broken ever since. Trying to bring back supports is surprisingly difficult in the face of -b and checking for keys in sys.path_importer_cache. Since the support was broken for so long, trying to overcome the difficulty of bringing back the support has been deemed not worth it.
Co-authored-by: Eryk Sun <eryksun@gmail.com>
Co-authored-by: Brett Cannon <brett@python.org>
|
|
|
|
|
| |
(GH-94551)
Discussion: https://discuss.python.org/t/slight-grammar-fix-throughout-adverbs-dont-need-hyphen/17021
|
|
|
| |
Closes #93675
|
|
|
|
| |
Fix the formatting for "await x" and "not x" in the operator
precedence table.
|
| |
|
| |
|
|
|
|
| |
(GH-91668)
|
|
|
| |
Automerge-Triggered-By: GH:brettcannon
|
|
|
| |
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
|
| |
|
|
|
|
| |
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
|
| |
|
|
|
| |
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
|
|
|
|
| |
the specified exception type (GH-32027)
|
| |
|
| |
|
| |
|
|
|
|
| |
(GH-29479)
|
|
|
| |
Automerge-Triggered-By: GH:pablogsal
|
|
|
|
|
| |
Calling int(a) when type(a) implements __trunc__ but not __int__
or __index__ now raises a DeprecationWarning.
|
|
|
|
| |
Improve tests for context in nested except handlers. (GH-29236)
|
|
|
|
| |
Also ignored some `make suspicious` false positives while assuring
true positives were properly seen by rstlint.
|
|
|
|
| |
(GH-24663)
|
| |
|
| |
|
|
|
|
| |
`__slots__` (GH-30109)
|
| |
|
| |
|
| |
|
|
|
|
| |
descriptor howto (GH-29909)
|
|
|
|
| |
the exception instance (GH-29780)
|
|
|
|
|
|
|
|
|
|
|
| |
summary (#29232)
This does two changes that are quite related.
0. it add that variable binding can occur in pattern matching, an update of 3.10
which seems to have been omitted from the list of bindings
1. Given how long the sentence already was, with even subcases in the middle of
the sentence, the commit breaks the sentence into an actual list.
|
|
|
|
| |
A similar sentence is present in the 'Invocation from super' section of
the descriptor HOWTO, where it is already correct.
|
|
|
|
|
| |
required by CPython (GH-29170)
It is now considered a historical accident that e.g. `for` loops and the `iter()` built-in function do not require the iterators they work with to define `__iter__`, only `__next__`.
|