Commit graph

369 commits

Author SHA1 Message Date
Miss Islington (bot)
3b4cd48d29
[3.11] gh-90535: Fix support of interval>1 in logging.TimedRotatingFileHandler (GH-116220) (GH-116893)
Fix support of interval values > 1 in logging.TimedRotatingFileHandler
for when='MIDNIGHT' and when='Wx'.
(cherry picked from commit 269051d20e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-03-18 19:47:53 +02:00
Miss Islington (bot)
707ce1f0a7
[3.11] gh-88352: Make TimedRotatingFileHandler tests more stable (GH-116409) (GH-116586)
The tests failed (with less than 1% probability) if for example the file
was created at 11:46:03.999, but the record was emitted at 11:46:04.001,
with atTime=11:46:04, which caused an unexpected rollover. Ensure that the
tests are always run within the range of the same whole second.

Also share code between test_rollover_at_midnight and test_rollover_at_weekday.
(cherry picked from commit d8712fa0c7)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-03-11 12:49:48 +02:00
Miss Islington (bot)
d3756edbc4
[3.11] gh-115809: Improve TimedRotatingFileHandler.getFilesToDelete() (GH-115812) (GH-116262)
Improve algorithm for computing which rolled-over log files to delete
in logging.TimedRotatingFileHandler. It is now reliable for handlers
without namer and with arbitrary deterministic namer that leaves
the datetime part in the file name unmodified.
(cherry picked from commit 87faec28c7)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-03-03 08:01:52 +00:00
Miss Islington (bot)
c36393690f
[3.11] gh-88352: Fix logging.TimedRotatingFileHandler (GH-116191) (GH-116209)
* Do not overwrite already rolled over files. It happened at midnight or
  during the DST change and caused the loss of data.
* computeRollover() now always return the timestamp larger than the
  specified time.
* Fix computation of the rollover time during the DST change.
(cherry picked from commit fee86fd9a4)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-03-01 18:41:58 +02:00
Miss Islington (bot)
301f166310
[3.11] gh-93205: When rotating logs with no namer specified, match whole extension (GH-93224) (GH-115785)
(cherry picked from commit 113687a838)

Co-authored-by: Gabriele Catania <gabriele.ctn@gmail.com>
2024-02-21 21:44:06 +00:00
Miss Islington (bot)
21edde17b3
[3.11] gh-115233: Fix an example in the Logging Cookbook (GH-115325) (GH-115355) (GH-115357)
Also add more tests for LoggerAdapter.

Also support stacklevel in LoggerAdapter._log().
(cherry picked from commit 225856ef3e)
(cherry picked from commit 91822018ee)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-02-12 23:25:47 +02:00
Vinay Sajip
078cdccc2a
[3.11] gh-110875: Handle '.' properties in logging formatter configuration correctly. (GH-110943) (GH-111914)
Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
2023-11-09 19:51:43 +00:00
Miss Islington (bot)
7984dc28b3
[3.11] gh-110656: Fix logging test_post_fork_child_no_deadlock() if ASAN (GH-110657) (#110665)
gh-110656: Fix logging test_post_fork_child_no_deadlock() if ASAN (GH-110657)

Skip test_post_fork_child_no_deadlock() if Python is built with ASAN.

Add support.HAVE_ASAN_FORK_BUG.
(cherry picked from commit f901f56313)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-11 01:22:51 +00:00
Miss Islington (bot)
28c6cc1928
[3.11] [3.12] gh-108303: Move all certificates to Lib/test/certdata/ (GH-109489) (GH-109682) (#110646)
[3.12] gh-108303: Move all certificates to `Lib/test/certdata/` (GH-109489) (GH-109682)

* gh-108303: Move all certificates to `Lib/test/certdata/` (GH-109489)
(cherry picked from commit e57ecf6bbc)

Python 3.12 backport: update also `test_nntplib`.

(cherry picked from commit c2d542b42c)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: T. Wouters <thomas@python.org>
2023-10-10 21:02:21 +00:00
Serhiy Storchaka
cf19e8ea3a
[3.11] gh-108416: Mark slow but not CPU bound test methods with requires_resource('walltime') (GH-108480) (GH-108924)
(cherry picked from commit 1e0d62793a)
2023-09-05 15:27:55 +00:00
Victor Stinner
db03cb953a
[3.11] gh-107237: Fix test_udp_reconnection() of test_logging (#107238) (#107245)
gh-107237: Fix test_udp_reconnection() of test_logging (#107238)

test_logging: Fix test_udp_reconnection() by increasing the timeout
from 100 ms to 5 minutes (LONG_TIMEOUT).

Replace also blocking wait() with wait(LONG_TIMEOUT) in
test_output() to prevent the test to hang.

(cherry picked from commit ed08238327)
2023-07-25 14:49:32 +00:00
Prince Roshan
2ade563abc
[3.11] gh-103606: Improve error message from logging.config.FileConfig (GH-103628) (#104687)
* gh-103606: Improve error message from logging.config.FileConfig (GH-103628)

(cherry picked from commit 152227b569)

plus backport the followup exception change fix to that in #104701
2023-05-21 12:17:18 -07:00
Vinay Sajip
f255820626
[3.11] gh-90195: Unset logger disabled flag when configuring it. (GH-96530) (GH-96532) 2022-09-03 15:10:50 +01:00
Miss Islington (bot)
103f26f282
[3.11] gh-89047: Fix msecs computation so you never end up with 1000 msecs. (GH-96340) (GH-96341) 2022-08-27 15:09:54 +01:00
Miss Islington (bot)
d49159bd9f
[3.11] bpo-46755: Don't log stack info twice in QueueHandler (GH-31355) (GH-94564)
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2022-07-05 15:49:05 +01:00
Miss Islington (bot)
123e3be33b
test_logging: Fix BytesWarning in SysLogHandlerTest (GH-93920)
(cherry picked from commit 538f28921f)

Co-authored-by: Victor Stinner <vstinner@python.org>
2022-06-17 02:53:35 -07:00
Miss Islington (bot)
7afccd34a6
gh-90473: Decrease recursion limit and skip tests on WASI (GH-92803)
(cherry picked from commit 137fd3d88a)

Co-authored-by: Christian Heimes <christian@python.org>
2022-05-19 08:05:52 -07:00
Miss Islington (bot)
c63c8ac238
bpo-45046: Support context managers in unittest (GH-28045)
Add methods enterContext() and enterClassContext() in TestCase.
Add method enterAsyncContext() in IsolatedAsyncioTestCase.
Add function enterModuleContext().
(cherry picked from commit 086c6b1b0f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-05-08 08:12:19 -07:00
Hugo van Kemenade
9b027d4cea
gh-92169: Use warnings_helper.import_deprecated() to import deprecated modules uniformly in tests (GH-92170) 2022-05-03 10:17:54 +03:00
Christian Heimes
2b16a08bc7
bpo-40280: Detect missing threading on WASM platforms (GH-32352)
Co-authored-by: Brett Cannon <brett@python.org>
2022-04-07 09:22:47 +02:00
Jouke Witteveen
c12ba6b2ff
bpo-45171: Remove tests of deprecated logger.warn(). (GH-32139) 2022-03-27 19:22:05 +01:00
Jouke Witteveen
5ca6d7469b
bpo-45171: Fix stacklevel handling in logging. (GH-28287) 2022-03-27 14:49:28 +01:00
Christian Heimes
deeaac49e2
bpo-40280: Skip socket, fork, subprocess tests on Emscripten (GH-31986)
- Add requires_fork and requires_subprocess to more tests
- Skip extension import tests if dlopen is not available
- Don't assume that _testcapi is a shared extension
- Skip a lot of socket tests that don't work on Emscripten
- Skip mmap tests, mmap emulation is incomplete
- venv does not work yet
- Cannot get libc from executable

The "entire" test suite is now passing on Emscripten with EMSDK from git head (91 suites are skipped).
2022-03-22 03:04:36 -07:00
Christian Heimes
ef1327e3b6
bpo-40280: Skip more tests on Emscripten (GH-31947)
- lchmod, lchown are not fully implemented
- skip umask tests
- cannot fstat unlinked or renamed files yet
- ignore musl libc issues that affect Emscripten
2022-03-17 12:09:57 +01:00
Mario Corchero
d7c6863979
bpo-41906: Accept built filters in dictConfig (GH-30756)
When configuring the logging stack, accept already built filters (or
just callables) in the filters array of loggers and handlers.
This facilitates passing quick callables as filters.

Automerge-Triggered-By: GH:vsajip
2022-01-24 04:39:50 -08:00
Irit Katriel
a287b31bcb
bpo-46411: Remove unnecessary calls to sys.exc_info() in tests (GH-30638) 2022-01-18 07:05:16 +00:00
Vinay Sajip
850aefc2c6
bpo-46063: Add 'delay=True' to file handler initialization. (GH-30103) 2021-12-14 16:46:07 +00:00
Vinay Sajip
cb589d1b6b
bpo-46063: Improve algorithm for computing which rolled-over log file… (GH-30093) 2021-12-14 00:53:37 +00:00
Victor Stinner
cf7eaa4617
Revert "bpo-28533: Remove asyncore, asynchat, smtpd modules (GH-29521)" (GH-29951)
This reverts commit 9bf2cbc4c4.
2021-12-07 12:31:04 +01:00
Victor Stinner
9bf2cbc4c4
bpo-28533: Remove asyncore, asynchat, smtpd modules (GH-29521)
Remove the asyncore and asynchat modules, deprecated in Python
3.6: use the asyncio module instead.

Remove the smtpd module, deprecated in Python 3.6: the aiosmtpd
module can be used instead, it is based on asyncio.

* Remove asyncore, asynchat and smtpd documentation
* Remove test_asyncore, test_asynchat and test_smtpd
* Rename Lib/asynchat.py to Lib/test/support/_asynchat.py
* Rename Lib/asyncore.py to Lib/test/support/_asyncore.py
* Rename Lib/smtpd.py to Lib/test/support/_smtpd.py
* Remove DeprecationWarning from private _asyncore, _asynchat and
  _smtpd modules
* _smtpd: remove deprecated properties
2021-11-16 00:29:17 +01:00
Serhiy Storchaka
15188b115a
bpo-45401: Fix a resource warning in test_logging (GH-28864) 2021-10-11 11:54:44 +03:00
Vinay Sajip
62a667784b
bpo-45401: Change shouldRollover() methods to only rollover regular f… (GH-28822)
…iles.

Also changed some historical return values from 1 -> True and 0 -> False.
2021-10-10 08:15:24 -07:00
Nikita Sobolev
1d42408495
bpo-45128: fixes test_multiprocessing_fork mysterious crash (GH-28387) 2021-09-19 23:50:04 +01:00
Serhiy Storchaka
40348acc18
bpo-45229: Remove test_main in many tests (GH-28405)
Instead of explicitly enumerate test classes for run_unittest()
use the unittest ability to discover tests. This also makes these
tests discoverable and runnable with unittest.

load_tests() can be used for dynamic generating tests and adding
doctests. setUpModule(), tearDownModule() and addModuleCleanup()
can be used for running code before and after all module tests.
2021-09-19 15:27:33 +03:00
Kirill Pinchuk
3d315c3116
bpo-44291: Fix reconnection in logging.handlers.SysLogHandler (GH-26490) 2021-08-05 14:58:16 +01:00
Mariusz Felisiak
11749e2dc2
bpo-44740: Lowercase "internet" and "web" where appropriate. (#27378)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-07-27 00:11:55 +02:00
andrei kulakov
96cf5a63d2
bpo-42378: fixed log truncation on logging shutdown (GH-27310)
Automerge-Triggered-By: GH:vsajip
2021-07-25 13:17:47 -07:00
Irit Katriel
22e7effad5
bpo-44498: suppress DeprecationWarnings for asynchat, asyncore and smtpd in tests (GH-26905) 2021-06-25 00:20:40 +01:00
andrei kulakov
8b93f0e696
bpo-43858: Add logging.getLevelNamesMapping() (GH-26459)
Added a function that returns a copy of a dict of logging levels.
2021-06-03 01:12:59 -07:00
Inada Naoki
53dd6c99b3
bpo-43651: Fix test_logging (GH-25715) 2021-04-29 20:37:32 +09:00
Inada Naoki
fa51c0c448
bpo-43651: Fix EncodingWarning in tests. (GH-25655)
* test_httplib
* test_httpservers
* test_logging
2021-04-29 11:34:56 +09:00
Victor Stinner
fe52eb6219
bpo-43961: Fix test_logging.test_namer_rotator_inheritance() (GH-25684)
Fix test_logging.test_namer_rotator_inheritance() on Windows: use
os.replace() rather than os.rename().
2021-04-28 15:47:10 +02:00
Victor Stinner
75ec103b3a
bpo-43842: Fix race condition in test_logging SMTP test (GH-25436)
Fix a race condition in the SMTP test of test_logging. Don't close a
file descriptor (socket) from a different thread while
asyncore.loop() is polling the file descriptor.
2021-04-16 14:32:01 +02:00
Christian Heimes
95bbb331ec
bpo-43723: Fix deprecation error caused by thread.setDaemon() (GH-25361) 2021-04-12 13:12:36 +02:00
Inada Naoki
fb78692f2a
bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25189)
* Fix _sitebuiltins
* Fix test_inspect
* Fix test_interpreters
* Fix test_io
* Fix test_iter
* Fix test_json
* Fix test_linecache
* Fix test_lltrace
* Fix test_logging
* Fix logging
2021-04-06 11:18:41 +09:00
Matthias Bussonnier
b32d8b4f9b
bpo-42644: Validate values in logging.disable() (#23786)
* bpo-42644: Validate values in logging.disable()

Technically make the value of manager a property that checks and convert
values assigned to it properly. This has the side effect of making
`logging.disable` also accept strings representing the various level of
warnings.

We want to validate the type of the disable attribute at assignment
time, as it is later compared to other levels when emitting warnings and
would generate a `TypeError: '>=' not supported between ....` in a
different part of the code base, which can make it difficult to track
down.

When assigned an incorrect value; it will raise a TypeError when the
wrong type, or ValueError if an invalid str.

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2020-12-16 11:43:39 +02:00
Victor Stinner
45df61fd2d
bpo-26789: Fix logging.FileHandler._open() at exit (GH-23053)
The logging.FileHandler class now keeps a reference to the builtin
open() function to be able to open or reopen the file during Python
finalization.

Fix errors like:

    Exception ignored in: (...)
    Traceback (most recent call last):
      (...)
      File ".../logging/__init__.py", line 1463, in error
      File ".../logging/__init__.py", line 1577, in _log
      File ".../logging/__init__.py", line 1587, in handle
      File ".../logging/__init__.py", line 1649, in callHandlers
      File ".../logging/__init__.py", line 948, in handle
      File ".../logging/__init__.py", line 1182, in emit
      File ".../logging/__init__.py", line 1171, in _open
    NameError: name 'open' is not defined
2020-11-02 23:17:46 +01:00
Victor Stinner
13ff396c01
bpo-41739: Fix test_logging.test_race_between_set_target_and_flush() (GH-22655)
The test now waits until all threads complete to avoid leaking
running threads.

Also, use regular threads rather than daemon threads.
2020-10-12 00:37:20 +02:00
Eric Larson
9fdb76c34c
Fix logging error message (GH-22410)
Same changes as #22276 squashed to a single commit. Just hoping to get Travis to cooperate by opening a new PR...

Automerge-Triggered-By: @vsajip
2020-09-25 11:08:50 -07:00
Irit Katriel
3fd69991f4
bpo-38762: Extend logging.test_multiprocessing to cover missing cases. (GH-22142) 2020-09-08 20:40:04 +01:00