Skip to content

Commit 1dcfc4f

Browse files
Pull in main
2 parents 93df440 + dce2d38 commit 1dcfc4f

4 files changed

Lines changed: 37 additions & 32 deletions

File tree

Doc/library/sched.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ scheduler:
3636
Example::
3737

3838
>>> import sched, time
39-
>>> s = sched.scheduler(time.time, time.sleep)
39+
>>> s = sched.scheduler(time.monotonic, time.sleep)
4040
>>> def print_time(a='default'):
4141
... print("From print_time", time.time(), a)
4242
...

Doc/using/cmdline.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -495,16 +495,18 @@ Miscellaneous options
495495
Reserved for various implementation-specific options. CPython currently
496496
defines the following possible values:
497497

498-
* ``-X faulthandler`` to enable :mod:`faulthandler`;
498+
* ``-X faulthandler`` to enable :mod:`faulthandler`.
499+
See also :envvar:`PYTHONFAULTHANDLER`.
499500
* ``-X showrefcount`` to output the total reference count and number of used
500501
memory blocks when the program finishes or after each statement in the
501502
interactive interpreter. This only works on :ref:`debug builds
502503
<debug-build>`.
503504
* ``-X tracemalloc`` to start tracing Python memory allocations using the
504505
:mod:`tracemalloc` module. By default, only the most recent frame is
505506
stored in a traceback of a trace. Use ``-X tracemalloc=NFRAME`` to start
506-
tracing with a traceback limit of *NFRAME* frames. See the
507-
:func:`tracemalloc.start` for more information.
507+
tracing with a traceback limit of *NFRAME* frames.
508+
See :func:`tracemalloc.start` and :envvar:`PYTHONTRACEMALLOC`
509+
for more information.
508510
* ``-X int_max_str_digits`` configures the :ref:`integer string conversion
509511
length limitation <int_max_str_digits>`. See also
510512
:envvar:`PYTHONINTMAXSTRDIGITS`.
@@ -519,6 +521,7 @@ Miscellaneous options
519521
* ``-X utf8`` enables the :ref:`Python UTF-8 Mode <utf8-mode>`.
520522
``-X utf8=0`` explicitly disables :ref:`Python UTF-8 Mode <utf8-mode>`
521523
(even when it would otherwise activate automatically).
524+
See also :envvar:`PYTHONUTF8`.
522525
* ``-X pycache_prefix=PATH`` enables writing ``.pyc`` files to a parallel
523526
tree rooted at the given directory instead of to the code tree. See also
524527
:envvar:`PYTHONPYCACHEPREFIX`.
@@ -861,16 +864,18 @@ conflict.
861864
Python memory allocations using the :mod:`tracemalloc` module. The value of
862865
the variable is the maximum number of frames stored in a traceback of a
863866
trace. For example, ``PYTHONTRACEMALLOC=1`` stores only the most recent
864-
frame. See the :func:`tracemalloc.start` for more information.
867+
frame.
868+
See the :func:`tracemalloc.start` function for more information.
869+
This is equivalent to setting the :option:`-X` ``tracemalloc`` option.
865870

866871
.. versionadded:: 3.4
867872

868873

869874
.. envvar:: PYTHONPROFILEIMPORTTIME
870875

871876
If this environment variable is set to a non-empty string, Python will
872-
show how long each import takes. This is exactly equivalent to setting
873-
``-X importtime`` on the command line.
877+
show how long each import takes.
878+
This is equivalent to setting the :option:`-X` ``importtime`` option.
874879

875880
.. versionadded:: 3.7
876881

@@ -1012,6 +1017,7 @@ conflict.
10121017
If this environment variable is set to a non-empty string, enable
10131018
:ref:`Python Development Mode <devmode>`, introducing additional runtime
10141019
checks that are too expensive to be enabled by default.
1020+
This is equivalent to setting the :option:`-X` ``dev`` option.
10151021

10161022
.. versionadded:: 3.7
10171023

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Adapt the :mod:`msvcrt` extension module to :pep:`687`.

PC/msvcrtmodule.c

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -564,19 +564,6 @@ static struct PyMethodDef msvcrt_functions[] = {
564564
{NULL, NULL}
565565
};
566566

567-
568-
static struct PyModuleDef msvcrtmodule = {
569-
PyModuleDef_HEAD_INIT,
570-
"msvcrt",
571-
NULL,
572-
-1,
573-
msvcrt_functions,
574-
NULL,
575-
NULL,
576-
NULL,
577-
NULL
578-
};
579-
580567
static int
581568
insertptr(PyObject *mod, char *name, void *value)
582569
{
@@ -607,13 +594,10 @@ insertptr(PyObject *mod, char *name, void *value)
607594
} \
608595
} while (0)
609596

610-
PyMODINIT_FUNC
611-
PyInit_msvcrt(void)
597+
static int
598+
exec_module(PyObject* m)
612599
{
613-
PyObject *m = PyModule_Create(&msvcrtmodule);
614-
if (m == NULL) {
615-
return NULL;
616-
}
600+
int st;
617601

618602
/* constants for the locking() function's mode argument */
619603
INSERTINT(m, "LK_LOCK", _LK_LOCK);
@@ -665,18 +649,32 @@ PyInit_msvcrt(void)
665649
_VC_CRT_BUILD_VERSION,
666650
_VC_CRT_RBUILD_VERSION);
667651
if (version == NULL) {
668-
goto error;
652+
return -1;
669653
}
670654
int st = PyModule_AddObjectRef(m, "CRT_ASSEMBLY_VERSION", version);
671655
Py_DECREF(version);
672656
if (st < 0) {
673-
goto error;
657+
return -1;
674658
}
675659
#endif
676660

677-
return m;
661+
return 0;
662+
}
663+
664+
static PyModuleDef_Slot msvcrt_slots[] = {
665+
{Py_mod_exec, exec_module},
666+
{0, NULL}
667+
};
668+
669+
static struct PyModuleDef msvcrtmodule = {
670+
.m_base = PyModuleDef_HEAD_INIT,
671+
.m_name = "msvcrt",
672+
.m_methods = msvcrt_functions,
673+
.m_slots = msvcrt_slots,
674+
};
678675

679-
error:
680-
Py_DECREF(m);
681-
return NULL;
676+
PyMODINIT_FUNC
677+
PyInit_msvcrt(void)
678+
{
679+
return PyModuleDef_Init(&msvcrtmodule);
682680
}

0 commit comments

Comments
 (0)