Skip to content

Commit b9a5a77

Browse files
author
Erlend E. Aasland
committed
Merge branch 'main' into sqlite-expose-error-code
2 parents 7a69798 + 3df0fc8 commit b9a5a77

File tree

200 files changed

+6298
-2554
lines changed

Some content is hidden

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

200 files changed

+6298
-2554
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*.{py,c,cpp,h,rst,md,yml}]
4+
trim_trailing_whitespace = true
5+
insert_final_newline = true
6+
indent_style = space
7+
8+
[*.{py,c,cpp,h}]
9+
indent_size = 4
10+
11+
[*.yml]
12+
indent_size = 2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ gmon.out
3535
.coverage
3636
.mypy_cache/
3737
.pytest_cache/
38+
.DS_Store
3839

3940
*.exe
4041
!Lib/distutils/command/*.exe

Doc/bugs.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ taken on the bug.
8080
Article which goes into some detail about how to create a useful bug report.
8181
This describes what kind of information is useful and why it is useful.
8282

83+
`Bug Writing Guidelines <https://bugzilla.mozilla.org/page.cgi?id=bug-writing.html>`_
84+
Information about writing a good bug report. Some of this is specific to the
85+
Mozilla project, but describes general good practices.
86+
8387
.. _contributing-to-python:
8488

8589
Getting started contributing to Python yourself

Doc/c-api/exceptions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ For convenience, some of these functions will always return a
100100
This is the most common way to set the error indicator. The first argument
101101
specifies the exception type; it is normally one of the standard exceptions,
102102
e.g. :c:data:`PyExc_RuntimeError`. You need not increment its reference count.
103-
The second argument is an error message; it is decoded from ``'utf-8``'.
103+
The second argument is an error message; it is decoded from ``'utf-8'``.
104104
105105
106106
.. c:function:: void PyErr_SetObject(PyObject *type, PyObject *value)

Doc/c-api/type.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ Type Objects
112112
113113
.. versionadded:: 3.11
114114
115+
.. c:function:: PyObject* PyType_GetQualName(PyTypeObject *type)
116+
117+
Return the type's qualified name. Equivalent to getting the
118+
type's ``__qualname__`` attribute.
119+
120+
.. versionadded:: 3.11
121+
115122
.. c:function:: void* PyType_GetSlot(PyTypeObject *type, int slot)
116123
117124
Return the function pointer stored in the given slot. If the

Doc/data/refcounts.dat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,6 +2310,9 @@ PyType_GetFlags:PyTypeObject*:type:0:
23102310
PyType_GetName:PyObject*::+1:
23112311
PyType_GetName:PyTypeObject*:type:0:
23122312

2313+
PyType_GetQualName:PyObject*::+1:
2314+
PyType_GetQualName:PyTypeObject*:type:0:
2315+
23132316
PyType_GetSlot:void*:::
23142317
PyType_GetSlot:PyTypeObject*:type:0:
23152318
PyType_GetSlot:int:slot::

Doc/data/stable_abi.dat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ function,PyType_GetFlags,3.2,
644644
function,PyType_GetModule,3.10,
645645
function,PyType_GetModuleState,3.10,
646646
function,PyType_GetName,3.11,
647+
function,PyType_GetQualName,3.11,
647648
function,PyType_GetSlot,3.4,
648649
function,PyType_IsSubtype,3.2,
649650
function,PyType_Modified,3.2,

Doc/faq/gui.rst

Lines changed: 8 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,8 @@ Graphic User Interface FAQ
1414
General GUI Questions
1515
=====================
1616

17-
What platform-independent GUI toolkits exist for Python?
18-
========================================================
19-
20-
Depending on what platform(s) you are aiming at, there are several. Some
21-
of them haven't been ported to Python 3 yet. At least `Tkinter`_ and `Qt`_
22-
are known to be Python 3-compatible.
23-
24-
.. XXX check links
25-
26-
Tkinter
27-
-------
17+
What GUI toolkits exist for Python?
18+
===================================
2819

2920
Standard builds of Python include an object-oriented interface to the Tcl/Tk
3021
widget set, called :ref:`tkinter <Tkinter>`. This is probably the easiest to
@@ -34,83 +25,12 @@ For more info about Tk, including pointers to the source, see the
3425
`Tcl/Tk home page <https://www.tcl.tk>`_. Tcl/Tk is fully portable to the
3526
Mac OS X, Windows, and Unix platforms.
3627

37-
wxWidgets
38-
---------
39-
40-
wxWidgets (https://www.wxwidgets.org) is a free, portable GUI class
41-
library written in C++ that provides a native look and feel on a
42-
number of platforms, with Windows, Mac OS X, GTK, X11, all listed as
43-
current stable targets. Language bindings are available for a number
44-
of languages including Python, Perl, Ruby, etc.
45-
46-
`wxPython <https://www.wxpython.org>`_ is the Python binding for
47-
wxwidgets. While it often lags slightly behind the official wxWidgets
48-
releases, it also offers a number of features via pure Python
49-
extensions that are not available in other language bindings. There
50-
is an active wxPython user and developer community.
51-
52-
Both wxWidgets and wxPython are free, open source, software with
53-
permissive licences that allow their use in commercial products as
54-
well as in freeware or shareware.
55-
56-
57-
Qt
58-
---
59-
60-
There are bindings available for the Qt toolkit (using either `PyQt
61-
<https://riverbankcomputing.com/software/pyqt/intro>`_ or `PySide
62-
<https://wiki.qt.io/PySide>`_) and for KDE (`PyKDE4 <https://techbase.kde.org/Languages/Python/Using_PyKDE_4>`__).
63-
PyQt is currently more mature than PySide, but you must buy a PyQt license from
64-
`Riverbank Computing <https://www.riverbankcomputing.com/commercial/license-faq>`_
65-
if you want to write proprietary applications. PySide is free for all applications.
66-
67-
Qt 4.5 upwards is licensed under the LGPL license; also, commercial licenses
68-
are available from `The Qt Company <https://www.qt.io/licensing/>`_.
69-
70-
Gtk+
71-
----
72-
73-
The `GObject introspection bindings <https://wiki.gnome.org/Projects/PyGObject>`_
74-
for Python allow you to write GTK+ 3 applications. There is also a
75-
`Python GTK+ 3 Tutorial <https://python-gtk-3-tutorial.readthedocs.io>`_.
76-
77-
The older PyGtk bindings for the `Gtk+ 2 toolkit <https://www.gtk.org>`_ have
78-
been implemented by James Henstridge; see <http://www.pygtk.org>.
79-
80-
Kivy
81-
----
82-
83-
`Kivy <https://kivy.org/>`_ is a cross-platform GUI library supporting both
84-
desktop operating systems (Windows, macOS, Linux) and mobile devices (Android,
85-
iOS). It is written in Python and Cython, and can use a range of windowing
86-
backends.
87-
88-
Kivy is free and open source software distributed under the MIT license.
89-
90-
FLTK
91-
----
92-
93-
Python bindings for `the FLTK toolkit <http://www.fltk.org>`_, a simple yet
94-
powerful and mature cross-platform windowing system, are available from `the
95-
PyFLTK project <https://pyfltk.sourceforge.io/>`_.
96-
97-
OpenGL
98-
------
99-
100-
For OpenGL bindings, see `PyOpenGL <http://pyopengl.sourceforge.net>`_.
101-
102-
103-
What platform-specific GUI toolkits exist for Python?
104-
========================================================
105-
106-
By installing the `PyObjc Objective-C bridge
107-
<https://pypi.org/project/pyobjc/>`_, Python programs can use Mac OS X's
108-
Cocoa libraries.
109-
110-
:ref:`Pythonwin <windows-faq>` by Mark Hammond includes an interface to the
111-
Microsoft Foundation Classes and a Python programming environment
112-
that's written mostly in Python using the MFC classes.
113-
28+
Depending on what platform(s) you are aiming at, there are also several
29+
alternatives. A `list of cross-platform
30+
<https://wiki.python.org/moin/GuiProgramming#Cross-Platform_Frameworks>`_ and
31+
`platform-specific
32+
<https://wiki.python.org/moin/GuiProgramming#Platform-specific_Frameworks>`_ GUI
33+
frameworks can be found on the python wiki.
11434

11535
Tkinter questions
11636
=================

Doc/faq/programming.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,55 @@ For example, here is the implementation of
18261826
return True
18271827
return False
18281828

1829+
1830+
How can a subclass control what data is stored in an immutable instance?
1831+
------------------------------------------------------------------------
1832+
1833+
When subclassing an immutable type, override the :meth:`__new__` method
1834+
instead of the :meth:`__init__` method. The latter only runs *after* an
1835+
instance is created, which is too late to alter data in an immutable
1836+
instance.
1837+
1838+
All of these immutable classes have a different signature than their
1839+
parent class:
1840+
1841+
.. testcode::
1842+
1843+
from datetime import date
1844+
1845+
class FirstOfMonthDate(date):
1846+
"Always choose the first day of the month"
1847+
def __new__(cls, year, month, day):
1848+
return super().__new__(cls, year, month, 1)
1849+
1850+
class NamedInt(int):
1851+
"Allow text names for some numbers"
1852+
xlat = {'zero': 0, 'one': 1, 'ten': 10}
1853+
def __new__(cls, value):
1854+
value = cls.xlat.get(value, value)
1855+
return super().__new__(cls, value)
1856+
1857+
class TitleStr(str):
1858+
"Convert str to name suitable for a URL path"
1859+
def __new__(cls, s):
1860+
s = s.lower().replace(' ', '-')
1861+
s = ''.join([c for c in s if c.isalnum() or c == '-'])
1862+
return super().__new__(cls, s)
1863+
1864+
The classes can be used like this:
1865+
1866+
.. doctest::
1867+
1868+
>>> FirstOfMonthDate(2012, 2, 14)
1869+
FirstOfMonthDate(2012, 2, 1)
1870+
>>> NamedInt('ten')
1871+
10
1872+
>>> NamedInt(20)
1873+
20
1874+
>>> TitleStr('Blog: Why Python Rocks')
1875+
'blog-why-python-rocks'
1876+
1877+
18291878
How do I cache method calls?
18301879
----------------------------
18311880

0 commit comments

Comments
 (0)