Skip to content

Commit 9db16c3

Browse files
author
Erlend E. Aasland
committed
Merge branch 'main' into sqlite-optimise-executemany
2 parents b92ca72 + e34bb40 commit 9db16c3

File tree

94 files changed

+2798
-388
lines changed

Some content is hidden

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

94 files changed

+2798
-388
lines changed

.azure-pipelines/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
variables:
22
coverage: false
33

4-
trigger: ['main', '3.9', '3.8', '3.7']
4+
trigger: ['main', '3.10', '3.9', '3.8', '3.7']
55

66
jobs:
77
- job: Prebuild
88
displayName: Pre-build checks
99

1010
pool:
11-
vmImage: ubuntu-18.04
11+
vmImage: ubuntu-20.04
1212

1313
steps:
1414
- template: ./prebuild-checks.yml
@@ -20,7 +20,7 @@ jobs:
2020
condition: and(succeeded(), eq(dependencies.Prebuild.outputs['docs.run'], 'true'))
2121

2222
pool:
23-
vmImage: ubuntu-18.04
23+
vmImage: ubuntu-20.04
2424

2525
steps:
2626
- template: ./docs-steps.yml
@@ -40,7 +40,7 @@ jobs:
4040
testRunPlatform: macos
4141

4242
pool:
43-
vmImage: macos-10.14
43+
vmImage: macos-10.15
4444

4545
steps:
4646
- template: ./macos-steps.yml
@@ -52,12 +52,12 @@ jobs:
5252
condition: and(succeeded(), eq(dependencies.Prebuild.outputs['tests.run'], 'true'))
5353

5454
pool:
55-
vmImage: ubuntu-18.04
55+
vmImage: ubuntu-20.04
5656

5757
variables:
5858
testRunTitle: '$(build.sourceBranchName)-linux'
5959
testRunPlatform: linux
60-
openssl_version: 1.1.1k
60+
openssl_version: 1.1.1l
6161

6262
steps:
6363
- template: ./posix-steps.yml
@@ -78,12 +78,12 @@ jobs:
7878
)
7979
8080
pool:
81-
vmImage: ubuntu-18.04
81+
vmImage: ubuntu-20.04
8282

8383
variables:
8484
testRunTitle: '$(Build.SourceBranchName)-linux-coverage'
8585
testRunPlatform: linux-coverage
86-
openssl_version: 1.1.1k
86+
openssl_version: 1.1.1l
8787

8888
steps:
8989
- template: ./posix-steps.yml

.azure-pipelines/pr.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
variables:
22
coverage: false
33

4-
pr: ['main', '3.9', '3.8', '3.7']
4+
pr: ['main', '3.10', '3.9', '3.8', '3.7']
55

66
jobs:
77
- job: Prebuild
88
displayName: Pre-build checks
99

1010
pool:
11-
vmImage: ubuntu-18.04
11+
vmImage: ubuntu-20.04
1212

1313
steps:
1414
- template: ./prebuild-checks.yml
@@ -20,7 +20,7 @@ jobs:
2020
condition: and(succeeded(), eq(dependencies.Prebuild.outputs['docs.run'], 'true'))
2121

2222
pool:
23-
vmImage: ubuntu-18.04
23+
vmImage: ubuntu-20.04
2424

2525
steps:
2626
- template: ./docs-steps.yml
@@ -38,7 +38,7 @@ jobs:
3838
testRunPlatform: macos
3939

4040
pool:
41-
vmImage: macos-10.14
41+
vmImage: macos-10.15
4242

4343
steps:
4444
- template: ./macos-steps.yml
@@ -52,12 +52,12 @@ jobs:
5252
condition: and(succeeded(), eq(dependencies.Prebuild.outputs['tests.run'], 'true'))
5353

5454
pool:
55-
vmImage: ubuntu-18.04
55+
vmImage: ubuntu-20.04
5656

5757
variables:
5858
testRunTitle: '$(system.pullRequest.TargetBranch)-linux'
5959
testRunPlatform: linux
60-
openssl_version: 1.1.1k
60+
openssl_version: 1.1.1l
6161

6262
steps:
6363
- template: ./posix-steps.yml
@@ -78,12 +78,12 @@ jobs:
7878
)
7979
8080
pool:
81-
vmImage: ubuntu-18.04
81+
vmImage: ubuntu-20.04
8282

8383
variables:
8484
testRunTitle: '$(Build.SourceBranchName)-linux-coverage'
8585
testRunPlatform: linux-coverage
86-
openssl_version: 1.1.1k
86+
openssl_version: 1.1.1l
8787

8888
steps:
8989
- template: ./posix-steps.yml

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ jobs:
138138
needs: check_source
139139
if: needs.check_source.outputs.run_tests == 'true'
140140
env:
141-
OPENSSL_VER: 1.1.1k
141+
OPENSSL_VER: 1.1.1l
142142
PYTHONSTRICTEXTENSIONBUILD: 1
143143
steps:
144144
- uses: actions/checkout@v2
@@ -182,7 +182,7 @@ jobs:
182182
strategy:
183183
fail-fast: false
184184
matrix:
185-
openssl_ver: [1.1.1k, 3.0.0-beta1]
185+
openssl_ver: [1.1.1l, 3.0.0-beta1]
186186
env:
187187
OPENSSL_VER: ${{ matrix.openssl_ver }}
188188
MULTISSL_DIR: ${{ github.workspace }}/multissl
@@ -229,7 +229,7 @@ jobs:
229229
needs: check_source
230230
if: needs.check_source.outputs.run_tests == 'true'
231231
env:
232-
OPENSSL_VER: 1.1.1k
232+
OPENSSL_VER: 1.1.1l
233233
PYTHONSTRICTEXTENSIONBUILD: 1
234234
ASAN_OPTIONS: detect_leaks=0:allocator_may_return_null=1:handle_segv=0
235235
steps:

Doc/includes/sqlite3/complete_statement.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
if buffer.lstrip().upper().startswith("SELECT"):
2525
print(cur.fetchall())
2626
except sqlite3.Error as e:
27-
print("An error occurred:", e.args[0])
27+
err_msg = str(e)
28+
err_code = e.sqlite_errorcode
29+
err_name = e.sqlite_errorname
30+
print(f"{err_name} ({err_code}): {err_msg}")
2831
buffer = ""
2932

3033
con.close()

Doc/library/sqlite3.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,20 @@ Exceptions
836836
The base class of the other exceptions in this module. It is a subclass
837837
of :exc:`Exception`.
838838

839+
.. attribute:: sqlite_errorcode
840+
841+
The numeric error code from the
842+
`SQLite API <https://sqlite.org/rescode.html>`_
843+
844+
.. versionadded:: 3.11
845+
846+
.. attribute:: sqlite_errorname
847+
848+
The symbolic name of the numeric error code
849+
from the `SQLite API <https://sqlite.org/rescode.html>`_
850+
851+
.. versionadded:: 3.11
852+
839853
.. exception:: DatabaseError
840854

841855
Exception raised for errors that are related to the database.

Doc/library/xml.rst

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,26 @@ circumvent firewalls.
6060
The following table gives an overview of the known attacks and whether
6161
the various modules are vulnerable to them.
6262

63-
========================= ============== =============== ============== ============== ==============
64-
kind sax etree minidom pulldom xmlrpc
65-
========================= ============== =============== ============== ============== ==============
66-
billion laughs **Vulnerable** **Vulnerable** **Vulnerable** **Vulnerable** **Vulnerable**
67-
quadratic blowup **Vulnerable** **Vulnerable** **Vulnerable** **Vulnerable** **Vulnerable**
68-
external entity expansion Safe (4) Safe (1) Safe (2) Safe (4) Safe (3)
69-
`DTD`_ retrieval Safe (4) Safe Safe Safe (4) Safe
70-
decompression bomb Safe Safe Safe Safe **Vulnerable**
71-
========================= ============== =============== ============== ============== ==============
72-
73-
1. :mod:`xml.etree.ElementTree` doesn't expand external entities and raises a
63+
========================= ================== ================== ================== ================== ==================
64+
kind sax etree minidom pulldom xmlrpc
65+
========================= ================== ================== ================== ================== ==================
66+
billion laughs **Vulnerable** (1) **Vulnerable** (1) **Vulnerable** (1) **Vulnerable** (1) **Vulnerable** (1)
67+
quadratic blowup **Vulnerable** (1) **Vulnerable** (1) **Vulnerable** (1) **Vulnerable** (1) **Vulnerable** (1)
68+
external entity expansion Safe (5) Safe (2) Safe (3) Safe (5) Safe (4)
69+
`DTD`_ retrieval Safe (5) Safe Safe Safe (5) Safe
70+
decompression bomb Safe Safe Safe Safe **Vulnerable**
71+
========================= ================== ================== ================== ================== ==================
72+
73+
1. Expat 2.4.1 and newer is not vulnerable to the "billion laughs" and
74+
"quadratic blowup" vulnerabilities. Items still listed as vulnerable due to
75+
potential reliance on system-provided libraries. Check
76+
:data:`pyexpat.EXPAT_VERSION`.
77+
2. :mod:`xml.etree.ElementTree` doesn't expand external entities and raises a
7478
:exc:`ParserError` when an entity occurs.
75-
2. :mod:`xml.dom.minidom` doesn't expand external entities and simply returns
79+
3. :mod:`xml.dom.minidom` doesn't expand external entities and simply returns
7680
the unexpanded entity verbatim.
77-
3. :mod:`xmlrpclib` doesn't expand external entities and omits them.
78-
4. Since Python 3.7.1, external general entities are no longer processed by
81+
4. :mod:`xmlrpclib` doesn't expand external entities and omits them.
82+
5. Since Python 3.7.1, external general entities are no longer processed by
7983
default.
8084

8185

Doc/whatsnew/3.11.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ sqlite3
226226
now raise :exc:`UnicodeEncodeError` instead of :exc:`sqlite3.ProgrammingError`.
227227
(Contributed by Erlend E. Aasland in :issue:`44688`.)
228228

229+
* :mod:`sqlite3` exceptions now include the SQLite error code as
230+
:attr:`~sqlite3.Error.sqlite_errorcode` and the SQLite error name as
231+
:attr:`~sqlite3.Error.sqlite_errorname`.
232+
(Contributed by Aviv Palivoda, Daniel Shahaf, and Erlend E. Aasland in
233+
:issue:`16379`.)
234+
229235

230236
Removed
231237
=======

Lib/pydoc.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,13 +1618,14 @@ def pipepager(text, cmd):
16181618
def tempfilepager(text, cmd):
16191619
"""Page through text by invoking a program on a temporary file."""
16201620
import tempfile
1621-
filename = tempfile.mktemp()
1622-
with open(filename, 'w', errors='backslashreplace') as file:
1623-
file.write(text)
1624-
try:
1621+
with tempfile.TemporaryDirectory() as tempdir:
1622+
filename = os.path.join(tempdir, 'pydoc.out')
1623+
with open(filename, 'w', errors='backslashreplace',
1624+
encoding=os.device_encoding(0) if
1625+
sys.platform == 'win32' else None
1626+
) as file:
1627+
file.write(text)
16251628
os.system(cmd + ' "' + filename + '"')
1626-
finally:
1627-
os.unlink(filename)
16281629

16291630
def _escape_stdout(text):
16301631
# Escape non-encodable characters to avoid encoding errors later

Lib/smtplib.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,15 @@ def send(self, s):
367367
def putcmd(self, cmd, args=""):
368368
"""Send a command to the server."""
369369
if args == "":
370-
str = '%s%s' % (cmd, CRLF)
370+
s = cmd
371371
else:
372-
str = '%s %s%s' % (cmd, args, CRLF)
373-
self.send(str)
372+
s = f'{cmd} {args}'
373+
if '\r' in s or '\n' in s:
374+
s = s.replace('\n', '\\n').replace('\r', '\\r')
375+
raise ValueError(
376+
f'command and arguments contain prohibited newline characters: {s}'
377+
)
378+
self.send(f'{s}{CRLF}')
374379

375380
def getreply(self):
376381
"""Get a reply from the server.

0 commit comments

Comments
 (0)