Skip to content

Commit 9540e84

Browse files
authored
Merge branch 'main' into fixcodecomment
2 parents 7513513 + 88dc84b commit 9540e84

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+563
-1468
lines changed

.github/CODEOWNERS

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ Programs/_bootstrap_python.c @ericsnowcurrently
8181
Programs/python.c @ericsnowcurrently
8282
Tools/build/generate_global_objects.py @ericsnowcurrently
8383

84+
# Initialization
85+
Doc/library/sys_path_init.rst @FFY00
86+
Doc/c-api/init_config.rst @FFY00
87+
88+
# getpath
89+
**/*getpath* @FFY00
90+
91+
# site
92+
**/*site.py @FFY00
93+
Doc/library/site.rst @FFY00
94+
8495
# Exceptions
8596
Lib/test/test_except*.py @iritkatriel
8697
Objects/exceptions.c @iritkatriel
@@ -97,7 +108,7 @@ Modules/_hacl/** @gpshead
97108
**/*logging* @vsajip
98109

99110
# venv
100-
**/*venv* @vsajip
111+
**/*venv* @vsajip @FFY00
101112

102113
# Launcher
103114
/PC/launcher.c @vsajip

Doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ check: _ensure-pre-commit
294294

295295
.PHONY: serve
296296
serve:
297-
@echo "The serve target was removed, use htmlview instead (see bpo-36329)"
297+
@echo "The serve target was removed, use htmllive instead (see gh-80510)"
298298

299299
# Targets for daily automated doc build
300300
# By default, Sphinx only rebuilds pages where the page content has changed.

Doc/deprecations/pending-removal-in-future.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,6 @@ although there is currently no date scheduled for their removal.
145145
* ``splitvalue()``
146146
* ``to_bytes()``
147147

148-
* :mod:`urllib.request`: :class:`~urllib.request.URLopener` and
149-
:class:`~urllib.request.FancyURLopener` style of invoking requests is
150-
deprecated. Use newer :func:`~urllib.request.urlopen` functions and methods.
151-
152148
* :mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial
153149
writes.
154150

Doc/library/urllib.request.rst

Lines changed: 4 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ The :mod:`urllib.request` module defines the following functions:
6767
the response headers as it is specified in the documentation for
6868
:class:`~http.client.HTTPResponse`.
6969

70-
For FTP, file, and data URLs and requests explicitly handled by legacy
71-
:class:`URLopener` and :class:`FancyURLopener` classes, this function
70+
For FTP, file, and data URLs, this function
7271
returns a :class:`urllib.response.addinfourl` object.
7372

7473
Raises :exc:`~urllib.error.URLError` on protocol errors.
@@ -1339,15 +1338,15 @@ environment settings::
13391338

13401339
>>> import urllib.request
13411340
>>> proxies = {'http': 'http://proxy.example.com:8080/'}
1342-
>>> opener = urllib.request.FancyURLopener(proxies)
1341+
>>> opener = urllib.request.build_opener(urllib.request.ProxyHandler(proxies))
13431342
>>> with opener.open("http://www.python.org") as f:
13441343
... f.read().decode('utf-8')
13451344
...
13461345

13471346
The following example uses no proxies at all, overriding environment settings::
13481347

13491348
>>> import urllib.request
1350-
>>> opener = urllib.request.FancyURLopener({})
1349+
>>> opener = urllib.request.build_opener(urllib.request.ProxyHandler({}}))
13511350
>>> with opener.open("http://www.python.org/") as f:
13521351
... f.read().decode('utf-8')
13531352
...
@@ -1412,121 +1411,6 @@ some point in the future.
14121411
Cleans up temporary files that may have been left behind by previous
14131412
calls to :func:`urlretrieve`.
14141413

1415-
.. class:: URLopener(proxies=None, **x509)
1416-
1417-
.. deprecated:: 3.3
1418-
1419-
Base class for opening and reading URLs. Unless you need to support opening
1420-
objects using schemes other than :file:`http:`, :file:`ftp:`, or :file:`file:`,
1421-
you probably want to use :class:`FancyURLopener`.
1422-
1423-
By default, the :class:`URLopener` class sends a :mailheader:`User-Agent` header
1424-
of ``urllib/VVV``, where *VVV* is the :mod:`urllib` version number.
1425-
Applications can define their own :mailheader:`User-Agent` header by subclassing
1426-
:class:`URLopener` or :class:`FancyURLopener` and setting the class attribute
1427-
:attr:`version` to an appropriate string value in the subclass definition.
1428-
1429-
The optional *proxies* parameter should be a dictionary mapping scheme names to
1430-
proxy URLs, where an empty dictionary turns proxies off completely. Its default
1431-
value is ``None``, in which case environmental proxy settings will be used if
1432-
present, as discussed in the definition of :func:`urlopen`, above.
1433-
1434-
Additional keyword parameters, collected in *x509*, may be used for
1435-
authentication of the client when using the :file:`https:` scheme. The keywords
1436-
*key_file* and *cert_file* are supported to provide an SSL key and certificate;
1437-
both are needed to support client authentication.
1438-
1439-
:class:`URLopener` objects will raise an :exc:`OSError` exception if the server
1440-
returns an error code.
1441-
1442-
.. method:: open(fullurl, data=None)
1443-
1444-
Open *fullurl* using the appropriate protocol. This method sets up cache and
1445-
proxy information, then calls the appropriate open method with its input
1446-
arguments. If the scheme is not recognized, :meth:`open_unknown` is called.
1447-
The *data* argument has the same meaning as the *data* argument of
1448-
:func:`urlopen`.
1449-
1450-
This method always quotes *fullurl* using :func:`~urllib.parse.quote`.
1451-
1452-
.. method:: open_unknown(fullurl, data=None)
1453-
1454-
Overridable interface to open unknown URL types.
1455-
1456-
1457-
.. method:: retrieve(url, filename=None, reporthook=None, data=None)
1458-
1459-
Retrieves the contents of *url* and places it in *filename*. The return value
1460-
is a tuple consisting of a local filename and either an
1461-
:class:`email.message.Message` object containing the response headers (for remote
1462-
URLs) or ``None`` (for local URLs). The caller must then open and read the
1463-
contents of *filename*. If *filename* is not given and the URL refers to a
1464-
local file, the input filename is returned. If the URL is non-local and
1465-
*filename* is not given, the filename is the output of :func:`tempfile.mktemp`
1466-
with a suffix that matches the suffix of the last path component of the input
1467-
URL. If *reporthook* is given, it must be a function accepting three numeric
1468-
parameters: A chunk number, the maximum size chunks are read in and the total size of the download
1469-
(-1 if unknown). It will be called once at the start and after each chunk of data is read from the
1470-
network. *reporthook* is ignored for local URLs.
1471-
1472-
If the *url* uses the :file:`http:` scheme identifier, the optional *data*
1473-
argument may be given to specify a ``POST`` request (normally the request type
1474-
is ``GET``). The *data* argument must in standard
1475-
:mimetype:`application/x-www-form-urlencoded` format; see the
1476-
:func:`urllib.parse.urlencode` function.
1477-
1478-
1479-
.. attribute:: version
1480-
1481-
Variable that specifies the user agent of the opener object. To get
1482-
:mod:`urllib` to tell servers that it is a particular user agent, set this in a
1483-
subclass as a class variable or in the constructor before calling the base
1484-
constructor.
1485-
1486-
1487-
.. class:: FancyURLopener(...)
1488-
1489-
.. deprecated:: 3.3
1490-
1491-
:class:`FancyURLopener` subclasses :class:`URLopener` providing default handling
1492-
for the following HTTP response codes: 301, 302, 303, 307 and 401. For the 30x
1493-
response codes listed above, the :mailheader:`Location` header is used to fetch
1494-
the actual URL. For 401 response codes (authentication required), basic HTTP
1495-
authentication is performed. For the 30x response codes, recursion is bounded
1496-
by the value of the *maxtries* attribute, which defaults to 10.
1497-
1498-
For all other response codes, the method :meth:`~BaseHandler.http_error_default` is called
1499-
which you can override in subclasses to handle the error appropriately.
1500-
1501-
.. note::
1502-
1503-
According to the letter of :rfc:`2616`, 301 and 302 responses to POST requests
1504-
must not be automatically redirected without confirmation by the user. In
1505-
reality, browsers do allow automatic redirection of these responses, changing
1506-
the POST to a GET, and :mod:`urllib` reproduces this behaviour.
1507-
1508-
The parameters to the constructor are the same as those for :class:`URLopener`.
1509-
1510-
.. note::
1511-
1512-
When performing basic authentication, a :class:`FancyURLopener` instance calls
1513-
its :meth:`prompt_user_passwd` method. The default implementation asks the
1514-
users for the required information on the controlling terminal. A subclass may
1515-
override this method to support more appropriate behavior if needed.
1516-
1517-
The :class:`FancyURLopener` class offers one additional method that should be
1518-
overloaded to provide the appropriate behavior:
1519-
1520-
.. method:: prompt_user_passwd(host, realm)
1521-
1522-
Return information needed to authenticate the user at the given host in the
1523-
specified security realm. The return value should be a tuple, ``(user,
1524-
password)``, which can be used for basic authentication.
1525-
1526-
The implementation prompts for this information on the terminal; an application
1527-
should override this method to use an appropriate interaction model in the local
1528-
environment.
1529-
15301414

15311415
:mod:`urllib.request` Restrictions
15321416
----------------------------------
@@ -1578,8 +1462,7 @@ some point in the future.
15781462
you try to fetch a file whose read permissions make it inaccessible; the FTP
15791463
code will try to read it, fail with a 550 error, and then perform a directory
15801464
listing for the unreadable file. If fine-grained control is needed, consider
1581-
using the :mod:`ftplib` module, subclassing :class:`FancyURLopener`, or changing
1582-
*_urlopener* to meet your needs.
1465+
using the :mod:`ftplib` module.
15831466

15841467

15851468

Doc/whatsnew/3.14.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,10 @@ urllib
769769
* Remove deprecated :class:`!Quoter` class from :mod:`urllib.parse`.
770770
It had previously raised a :exc:`DeprecationWarning` since Python 3.11.
771771
(Contributed by Nikita Sobolev in :gh:`118827`.)
772+
* Remove deprecated :class:`!URLopener` and :class:`!FancyURLopener` classes
773+
from :mod:`urllib.request`. They had previously raised a
774+
:exc:`DeprecationWarning` since Python 3.3.
775+
(Contributed by Barney Gale in :gh:`84850`.)
772776

773777
Others
774778
------

Include/cpython/pystats.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ typedef struct _gc_stats {
9999
uint64_t collections;
100100
uint64_t object_visits;
101101
uint64_t objects_collected;
102-
uint64_t objects_transitively_reachable;
103-
uint64_t objects_not_transitively_reachable;
104102
} GCStats;
105103

106104
typedef struct _uop_stats {

Include/internal/pycore_dict.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ extern int _PyDict_Next(
4343

4444
extern int _PyDict_HasOnlyStringKeys(PyObject *mp);
4545

46+
extern void _PyDict_MaybeUntrack(PyObject *mp);
47+
4648
// Export for '_ctypes' shared extension
4749
PyAPI_FUNC(Py_ssize_t) _PyDict_SizeOf(PyDictObject *);
4850

Include/internal/pycore_frame.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ typedef struct _PyInterpreterFrame {
7575
_PyStackRef *stackpointer;
7676
uint16_t return_offset; /* Only relevant during a function call */
7777
char owner;
78-
char visited;
7978
/* Locals and stack */
8079
_PyStackRef localsplus[1];
8180
} _PyInterpreterFrame;
@@ -208,7 +207,6 @@ _PyFrame_Initialize(
208207
#endif
209208
frame->return_offset = 0;
210209
frame->owner = FRAME_OWNED_BY_THREAD;
211-
frame->visited = 0;
212210

213211
for (int i = null_locals_from; i < code->co_nlocalsplus; i++) {
214212
frame->localsplus[i] = PyStackRef_NULL;
@@ -391,7 +389,6 @@ _PyFrame_PushTrampolineUnchecked(PyThreadState *tstate, PyCodeObject *code, int
391389
frame->instr_ptr = _PyCode_CODE(code);
392390
#endif
393391
frame->owner = FRAME_OWNED_BY_THREAD;
394-
frame->visited = 0;
395392
frame->return_offset = 0;
396393

397394
#ifdef Py_GIL_DISABLED

Include/internal/pycore_gc.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ extern "C" {
1010

1111
/* GC information is stored BEFORE the object structure. */
1212
typedef struct {
13-
// Tagged pointer to next object in the list.
13+
// Pointer to next object in the list.
1414
// 0 means the object is not tracked
1515
uintptr_t _gc_next;
1616

17-
// Tagged pointer to previous object in the list.
17+
// Pointer to previous object in the list.
1818
// Lowest two bits are used for flags documented later.
1919
uintptr_t _gc_prev;
2020
} PyGC_Head;
@@ -302,11 +302,6 @@ struct gc_generation_stats {
302302
Py_ssize_t uncollectable;
303303
};
304304

305-
enum _GCPhase {
306-
GC_PHASE_MARK = 0,
307-
GC_PHASE_COLLECT = 1
308-
};
309-
310305
struct _gc_runtime_state {
311306
/* List of objects that still need to be cleaned up, singly linked
312307
* via their gc headers' gc_prev pointers. */
@@ -330,12 +325,10 @@ struct _gc_runtime_state {
330325
/* a list of callbacks to be invoked when collection is performed */
331326
PyObject *callbacks;
332327

333-
Py_ssize_t prior_heap_size;
334328
Py_ssize_t heap_size;
335329
Py_ssize_t work_to_do;
336330
/* Which of the old spaces is the visited space */
337331
int visited_space;
338-
int phase;
339332

340333
#ifdef Py_GIL_DISABLED
341334
/* This is the number of objects that survived the last full

Include/internal/pycore_object.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalRefcountErrorFunc(
9494
#define _Py_FatalRefcountError(message) \
9595
_Py_FatalRefcountErrorFunc(__func__, (message))
9696

97+
#define _PyReftracerTrack(obj, operation) \
98+
do { \
99+
struct _reftracer_runtime_state *tracer = &_PyRuntime.ref_tracer; \
100+
if (tracer->tracer_func != NULL) { \
101+
void *data = tracer->tracer_data; \
102+
tracer->tracer_func((obj), (operation), data); \
103+
} \
104+
} while(0)
97105

98106
#ifdef Py_REF_DEBUG
99107
/* The symbol is only exposed in the API for the sake of extensions
@@ -208,11 +216,7 @@ _Py_DECREF_SPECIALIZED(PyObject *op, const destructor destruct)
208216
#ifdef Py_TRACE_REFS
209217
_Py_ForgetReference(op);
210218
#endif
211-
struct _reftracer_runtime_state *tracer = &_PyRuntime.ref_tracer;
212-
if (tracer->tracer_func != NULL) {
213-
void* data = tracer->tracer_data;
214-
tracer->tracer_func(op, PyRefTracer_DESTROY, data);
215-
}
219+
_PyReftracerTrack(op, PyRefTracer_DESTROY);
216220
destruct(op);
217221
}
218222
}
@@ -466,8 +470,8 @@ static inline void _PyObject_GC_TRACK(
466470
PyGC_Head *last = (PyGC_Head*)(generation0->_gc_prev);
467471
_PyGCHead_SET_NEXT(last, gc);
468472
_PyGCHead_SET_PREV(gc, last);
469-
uintptr_t not_visited = 1 ^ interp->gc.visited_space;
470-
gc->_gc_next = ((uintptr_t)generation0) | not_visited;
473+
/* Young objects will be moved into the visited space during GC, so set the bit here */
474+
gc->_gc_next = ((uintptr_t)generation0) | (uintptr_t)interp->gc.visited_space;
471475
generation0->_gc_prev = (uintptr_t)gc;
472476
#endif
473477
}

0 commit comments

Comments
 (0)