Skip to content

Commit

Permalink
Merge branch 'main' into nitpick_ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka committed Jul 22, 2023
2 parents 60cfe62 + 26e08df commit 381205f
Show file tree
Hide file tree
Showing 47 changed files with 243 additions and 138 deletions.
20 changes: 19 additions & 1 deletion Doc/library/curses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,8 @@ The module :mod:`curses` defines the following functions:

.. function:: update_lines_cols()

Update :envvar:`LINES` and :envvar:`COLS`. Useful for detecting manual screen resize.
Update the :const:`LINES` and :const:`COLS` module variables.
Useful for detecting manual screen resize.

.. versionadded:: 3.5

Expand Down Expand Up @@ -1342,10 +1343,27 @@ The :mod:`curses` module defines the following data members:
.. data:: COLORS

The maximum number of colors the terminal can support.
It is defined only after the call to :func:`start_color`.

.. data:: COLOR_PAIRS

The maximum number of color pairs the terminal can support.
It is defined only after the call to :func:`start_color`.

.. data:: COLS

The width of the screen, i.e., the number of columns.
It is defined only after the call to :func:`initscr`.
Updated by :func:`update_lines_cols`, :func:`resizeterm` and
:func:`resize_term`.

.. data:: LINES

The height of the screen, i.e., the number of lines.
It is defined only after the call to :func:`initscr`.
Updated by :func:`update_lines_cols`, :func:`resizeterm` and
:func:`resize_term`.


Some constants are available to specify character cell attributes.
The exact constants available are system dependent.
Expand Down
23 changes: 18 additions & 5 deletions Doc/library/re.rst
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ The special characters are:
in the ASCII range (``b'\x00'``-``b'\x7f'``).


.. _re-special-sequences:

The special sequences consist of ``'\'`` and a character from the list below.
If the ordinary character is not an ASCII digit or an ASCII letter, then the
resulting RE will match the second character. For example, ``\$`` matches the
Expand Down Expand Up @@ -779,6 +781,17 @@ Flags
Corresponds to the inline flag ``(?s)``.


.. data:: U
UNICODE

In Python 2, this flag made :ref:`special sequences <re-special-sequences>`
include Unicode characters in matches. Since Python 3, Unicode characters
are matched by default.

See :const:`A` for restricting matching on ASCII characters instead.

This flag is only kept for backward compatibility.

.. data:: X
VERBOSE

Expand Down Expand Up @@ -1520,14 +1533,14 @@ Simulating scanf()

.. index:: single: scanf()

Python does not currently have an equivalent to :c:func:`scanf`. Regular
Python does not currently have an equivalent to :c:func:`!scanf`. Regular
expressions are generally more powerful, though also more verbose, than
:c:func:`scanf` format strings. The table below offers some more-or-less
equivalent mappings between :c:func:`scanf` format tokens and regular
:c:func:`!scanf` format strings. The table below offers some more-or-less
equivalent mappings between :c:func:`!scanf` format tokens and regular
expressions.

+--------------------------------+---------------------------------------------+
| :c:func:`scanf` Token | Regular Expression |
| :c:func:`!scanf` Token | Regular Expression |
+================================+=============================================+
| ``%c`` | ``.`` |
+--------------------------------+---------------------------------------------+
Expand All @@ -1552,7 +1565,7 @@ To extract the filename and numbers from a string like ::

/usr/sbin/sendmail - 0 errors, 4 warnings

you would use a :c:func:`scanf` format like ::
you would use a :c:func:`!scanf` format like ::

%s - %d errors, %d warnings

Expand Down
6 changes: 6 additions & 0 deletions Doc/library/shutil.rst
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,12 @@ Directory and files operations
total, used and free space, in bytes. *path* may be a file or a
directory.

.. note::

On Unix filesystems, *path* must point to a path within a **mounted**
filesystem partition. On those platforms, CPython doesn't attempt to
retrieve disk usage information from non-mounted filesystems.

.. versionadded:: 3.3

.. versionchanged:: 3.8
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/ssl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2592,7 +2592,7 @@ disabled by default.
>>> client_context.maximum_version = ssl.TLSVersion.TLSv1_3


The SSL context created above will only allow TLSv1.2 and later (if
The SSL context created above will only allow TLSv1.3 and later (if
supported by your system) connections to a server. :const:`PROTOCOL_TLS_CLIENT`
implies certificate validation and hostname checks by default. You have to
load certificates into the context.
Expand Down
1 change: 0 additions & 1 deletion Doc/tools/.nitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ Doc/library/pyclbr.rst
Doc/library/pydoc.rst
Doc/library/pyexpat.rst
Doc/library/random.rst
Doc/library/re.rst
Doc/library/readline.rst
Doc/library/reprlib.rst
Doc/library/resource.rst
Expand Down
3 changes: 1 addition & 2 deletions Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
What's New In Python 3.12
****************************

:Release: |release|
:Date: |today|
:Editor: TBD

.. Rules for maintenance:
Expand Down
3 changes: 1 addition & 2 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
What's New In Python 3.13
****************************

:Release: |release|
:Date: |today|
:Editor: TBD

.. Rules for maintenance:
Expand Down
4 changes: 2 additions & 2 deletions Doc/whatsnew/3.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1045,8 +1045,8 @@ not just sequences. (Contributed by Serhiy Storchaka in :issue:`23171`.)
curses
------

The new :func:`~curses.update_lines_cols` function updates the :envvar:`LINES`
and :envvar:`COLS` environment variables. This is useful for detecting
The new :func:`~curses.update_lines_cols` function updates the :data:`LINES`
and :data:`COLS` module variables. This is useful for detecting
manual screen resizing. (Contributed by Arnon Yaari in :issue:`4254`.)


Expand Down
6 changes: 0 additions & 6 deletions Include/cpython/genobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ PyAPI_DATA(PyTypeObject) PyGen_Type;
PyAPI_FUNC(PyObject *) PyGen_New(PyFrameObject *);
PyAPI_FUNC(PyObject *) PyGen_NewWithQualName(PyFrameObject *,
PyObject *name, PyObject *qualname);
PyAPI_FUNC(int) _PyGen_SetStopIterationValue(PyObject *);
PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);
PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self);
PyAPI_FUNC(PyCodeObject *) PyGen_GetCode(PyGenObject *gen);


Expand All @@ -54,7 +51,6 @@ typedef struct {
} PyCoroObject;

PyAPI_DATA(PyTypeObject) PyCoro_Type;
PyAPI_DATA(PyTypeObject) _PyCoroWrapper_Type;

#define PyCoro_CheckExact(op) Py_IS_TYPE((op), &PyCoro_Type)
PyAPI_FUNC(PyObject *) PyCoro_New(PyFrameObject *,
Expand All @@ -69,8 +65,6 @@ typedef struct {

PyAPI_DATA(PyTypeObject) PyAsyncGen_Type;
PyAPI_DATA(PyTypeObject) _PyAsyncGenASend_Type;
PyAPI_DATA(PyTypeObject) _PyAsyncGenWrappedValue_Type;
PyAPI_DATA(PyTypeObject) _PyAsyncGenAThrow_Type;

PyAPI_FUNC(PyObject *) PyAsyncGen_New(PyFrameObject *,
PyObject *name, PyObject *qualname);
Expand Down
8 changes: 0 additions & 8 deletions Include/cpython/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,6 @@ PyAPI_FUNC(PyObject *) _PyObject_FunctionStr(PyObject *);
#endif


PyAPI_DATA(PyTypeObject) _PyNone_Type;
PyAPI_DATA(PyTypeObject) _PyNotImplemented_Type;

/* Maps Py_LT to Py_GT, ..., Py_GE to Py_LE.
* Defined in object.c.
*/
PyAPI_DATA(int) _Py_SwappedOp[];

PyAPI_FUNC(void)
_PyDebugAllocatorStats(FILE *out, const char *block_name, int num_blocks,
size_t sizeof_block);
Expand Down
1 change: 0 additions & 1 deletion Include/cpython/pythonrun.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,4 @@ PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject

/* Stuff with no proper home (yet) */
PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *);
5 changes: 0 additions & 5 deletions Include/cpython/setobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,3 @@ static inline Py_ssize_t PySet_GET_SIZE(PyObject *so) {
return _PySet_CAST(so)->used;
}
#define PySet_GET_SIZE(so) PySet_GET_SIZE(_PyObject_CAST(so))

PyAPI_DATA(PyObject *) _PySet_Dummy;

PyAPI_FUNC(int) _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, Py_hash_t *hash);
PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable);
11 changes: 11 additions & 0 deletions Include/internal/pycore_genobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,20 @@ extern "C" {
#endif

extern PyObject *_PyGen_yf(PyGenObject *);
extern void _PyGen_Finalize(PyObject *self);

// _asyncio shared extensions uses _PyGen_SetStopIterationValue() and
// _PyGen_FetchStopIterationValue()
PyAPI_FUNC(int) _PyGen_SetStopIterationValue(PyObject *);
PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);

extern PyObject *_PyCoro_GetAwaitableIter(PyObject *o);
extern PyObject *_PyAsyncGenValueWrapperNew(PyThreadState *state, PyObject *);

extern PyTypeObject _PyCoroWrapper_Type;
extern PyTypeObject _PyAsyncGenWrappedValue_Type;
extern PyTypeObject _PyAsyncGenAThrow_Type;

/* runtime lifecycle */

extern void _PyAsyncGen_Fini(PyInterpreterState *);
Expand Down
7 changes: 7 additions & 0 deletions Include/internal/pycore_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,13 @@ extern PyObject* _PyCFunctionWithKeywords_TrampolineCall(
(meth)((self), (args), (kw))
#endif // __EMSCRIPTEN__ && PY_CALL_TRAMPOLINE

// _pickle shared extension uses _PyNone_Type and _PyNotImplemented_Type
PyAPI_DATA(PyTypeObject) _PyNone_Type;
PyAPI_DATA(PyTypeObject) _PyNotImplemented_Type;

/* Maps Py_LT to Py_GT, ..., Py_GE to Py_LE. Defined in Objects/object.c. */
PyAPI_DATA(int) _Py_SwappedOp[];

#ifdef __cplusplus
}
#endif
Expand Down
85 changes: 80 additions & 5 deletions Include/internal/pycore_pyhash.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,86 @@
#ifndef Py_INTERNAL_HASH_H
#define Py_INTERNAL_HASH_H
#ifndef Py_INTERNAL_PYHASH_H
#define Py_INTERNAL_PYHASH_H

#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif

/* Helpers for hash functions */
extern Py_hash_t _Py_HashDouble(PyObject *, double);
// _decimal shared extensions uses _Py_HashPointer()
PyAPI_FUNC(Py_hash_t) _Py_HashPointer(const void*);
// Similar to _Py_HashPointer(), but don't replace -1 with -2
extern Py_hash_t _Py_HashPointerRaw(const void*);
// _datetime shared extension uses _Py_HashBytes()
PyAPI_FUNC(Py_hash_t) _Py_HashBytes(const void*, Py_ssize_t);

/* Prime multiplier used in string and various other hashes. */
#define _PyHASH_MULTIPLIER 1000003UL /* 0xf4243 */

/* Parameters used for the numeric hash implementation. See notes for
_Py_HashDouble in Python/pyhash.c. Numeric hashes are based on
reduction modulo the prime 2**_PyHASH_BITS - 1. */

#if SIZEOF_VOID_P >= 8
# define _PyHASH_BITS 61
#else
# define _PyHASH_BITS 31
#endif

#define _PyHASH_MODULUS (((size_t)1 << _PyHASH_BITS) - 1)
#define _PyHASH_INF 314159
#define _PyHASH_IMAG _PyHASH_MULTIPLIER

/* Hash secret
*
* memory layout on 64 bit systems
* cccccccc cccccccc cccccccc uc -- unsigned char[24]
* pppppppp ssssssss ........ fnv -- two Py_hash_t
* k0k0k0k0 k1k1k1k1 ........ siphash -- two uint64_t
* ........ ........ ssssssss djbx33a -- 16 bytes padding + one Py_hash_t
* ........ ........ eeeeeeee pyexpat XML hash salt
*
* memory layout on 32 bit systems
* cccccccc cccccccc cccccccc uc
* ppppssss ........ ........ fnv -- two Py_hash_t
* k0k0k0k0 k1k1k1k1 ........ siphash -- two uint64_t (*)
* ........ ........ ssss.... djbx33a -- 16 bytes padding + one Py_hash_t
* ........ ........ eeee.... pyexpat XML hash salt
*
* (*) The siphash member may not be available on 32 bit platforms without
* an unsigned int64 data type.
*/
typedef union {
/* ensure 24 bytes */
unsigned char uc[24];
/* two Py_hash_t for FNV */
struct {
Py_hash_t prefix;
Py_hash_t suffix;
} fnv;
/* two uint64 for SipHash24 */
struct {
uint64_t k0;
uint64_t k1;
} siphash;
/* a different (!) Py_hash_t for small string optimization */
struct {
unsigned char padding[16];
Py_hash_t suffix;
} djbx33a;
struct {
unsigned char padding[16];
Py_hash_t hashsalt;
} expat;
} _Py_HashSecret_t;

// _elementtree shared extension uses _Py_HashSecret.expat
PyAPI_DATA(_Py_HashSecret_t) _Py_HashSecret;

#ifdef Py_DEBUG
extern int _Py_HashSecret_Initialized;
#endif


struct pyhash_runtime_state {
struct {
Expand Down Expand Up @@ -34,7 +110,6 @@ struct pyhash_runtime_state {
}


uint64_t _Py_KeyedHash(uint64_t, const char *, Py_ssize_t);

extern uint64_t _Py_KeyedHash(uint64_t key, const void *src, Py_ssize_t src_sz);

#endif // Py_INTERNAL_HASH_H
#endif // !Py_INTERNAL_PYHASH_H
2 changes: 1 addition & 1 deletion Include/internal/pycore_pymem.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ PyAPI_FUNC(int) _PyMem_SetupAllocators(PyMemAllocatorName allocator);
#ifdef __cplusplus
}
#endif
#endif /* !Py_INTERNAL_PYMEM_H */
#endif // !Py_INTERNAL_PYMEM_H
25 changes: 25 additions & 0 deletions Include/internal/pycore_setobject.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef Py_INTERNAL_SETOBJECT_H
#define Py_INTERNAL_SETOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif

#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif

// _pickle shared extension uses _PySet_NextEntry() and _PySet_Update()
PyAPI_FUNC(int) _PySet_NextEntry(
PyObject *set,
Py_ssize_t *pos,
PyObject **key,
Py_hash_t *hash);
PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable);

// Export _PySet_Dummy for the gdb plugin's benefit
PyAPI_DATA(PyObject *) _PySet_Dummy;

#ifdef __cplusplus
}
#endif
#endif // !Py_INTERNAL_SETOBJECT_H
Loading

0 comments on commit 381205f

Please sign in to comment.