Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctypes pickling error #342

Closed
JulianOrteil opened this issue Oct 1, 2020 · 11 comments
Closed

ctypes pickling error #342

JulianOrteil opened this issue Oct 1, 2020 · 11 comments
Labels
enhancement Improvement to an already existing feature

Comments

@JulianOrteil
Copy link

JulianOrteil commented Oct 1, 2020

Good day, Delgan.

I have an error I am encountering in the handlers of loguru. This error is being raised when I use "logger.exception(msg)" in the except block of a try statement.

Some context:
I'm developing an application to interface with NVIDIA's AI Triton server. The server's client-side python bindings are written in both C/C++ and Python. I'm mentioning this because I am developing on Windows, and replicating this issue is fairly hard due to specifics in the environment for the Triton server. I can give you the files and procedures to set up an environment like mine for this if you'd like, but I'll leave that up to you.

The error:
Stacktrace:

Traceback (most recent call last):
  File "C:\Users\jules\.conda\envs\app\lib\site-packages\loguru\_handler.py", line 175, in emit
    self._queue.put(str_record)
  File "C:\Users\jules\.conda\envs\app\lib\multiprocessing\queues.py", line 362, in put
    obj = _ForkingPickler.dumps(obj)
  File "C:\Users\jules\.conda\envs\app\lib\multiprocessing\reduction.py", line 51, in dumps
    cls(buf, protocol).dump(obj)
ValueError: ctypes objects containing pointers cannot be pickled

Code throwing the issue:

try:
    # <Code here raises 'InferenceServerException'>
except InferenceServerException: # The specific exception being raised (Triton server-specific)
    logger.exception("An issue occurred while contacting the inference server:\n")

The exception being raised does have calls to dll's in it, so that could possibly be the root cause? Again, it is difficult to reproduce this error because of the environment.

Exception data as returned by 'sys.exc_info()':

type: <class 'tensorrtserver.api.InferenceServerException'>
value: InferenceServerException(c_void_p(2735452554832)) # This is what I think is causing the issue
traceback: <normal traceback>

Logger setup code:

import os
import sys

import stackprinter
from loguru import logger


class FilterLevel(object):
    """Used to filter logs based dynamic logging level by using the
    :prop:`level` property which can be either an :obj:`int` or
    :obj:`str`.
    """

    _level: Union[str, int]

    def __init__(self) -> None:
        super().__init__()

        self.level = "INFO"

    def __call__(self, record: dict) -> bool:
        levelno = logger.level(self.level).no
        return record["level"].no >= levelno

    @property
    def level(self) -> Union[str, int]:
        return self._level

    @level.setter
    def level(self, value: Union[str, int]) -> None:

        if not isinstance(value, (str, int)):
            raise TypeError("property 'level' must be of type 'str' or 'int': "
                            f"'{type(value).__name__}'")

        self._level = value

LOGFILE = "some_log_somewhere.log"
LOGGER_FILTER = FilterLevel()
LOGGER_FORMAT = "<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | <level>{level: <8}</level> | <cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>"


def _format_stacktrace(record: dict):
    format_ = LOGGER_FORMAT # The default format found in loguru's '_defaults.py'

    if record["exception"] is not None:
        record["extra"]["stack"] = stackprinter.format(record["exception"])
        format_ += "<red><bold>{extra[stack]}</bold></red>\n"

    return format_ + "\n"

# Remove all current handlers
logger.remove()

# Add the needed handlers
logger.add(sys.stderr, format=_format_stacktrace, enqueue=True)
logger.add(LOGFILE, format=_format_stacktrace, filter=LOGGER_FILTER, enqueue=True)

# Create loguru attributes to be accessible from the logger anywhere
# the logger is found object
setattr(logger, "app_logfile", LOGFILE)
setattr(logger, "app_logfilter", LOGGER_FILTER)

Please let me know if there is anything more I can provide.
Jules

@JulianOrteil
Copy link
Author

This app is multithreaded and multiprocessed using the stdlib threading and multiprocessing modules and PyQt5's QThread class. So, using 'enqueue' is kind of forced here 😕

@Delgan
Copy link
Owner

Delgan commented Oct 1, 2020

Hello @JulianOrteil. Thanks for the extensive bug report!

Basically, when enqueue=True the log records need to be serialized using pickle.dumps(). This also applies to the logged exception, if any. The resulting string is sent to a multiprocessing queue and later processed by a background thread.

As you noticed, it seems the raised InferenceServerException() contains a non-picklable value: c_void_p(2735452554832).

Actually, Loguru tries to catch possible errors during the serialization procedure of exceptions:

def __reduce__(self):
try:
pickled_value = pickle.dumps(self.value)
except pickle.PickleError:
return (RecordException, (self.type, None, None))
else:
return (RecordException._from_pickled_value, (self.type, pickled_value, None))

However, what I didn't know is that pickle.dumps() could raise exception of type ValueError. The ValueError does not inherit from PickleError so obviously it's not caught by the try / except implemented in __reduce__.

import ctypes
import pickle

pickle.dumps(lambda: None)
# _pickle.PicklingError: Can't pickle <function <lambda> at 0x7f33528ec0d0>: attribute lookup <lambda> on __main__ failed

pickle.dumps(ctypes.c_void_p(2735452554832)) 
# ValueError: ctypes objects containing pointers cannot be pickled

I will probably change the implementation so it catch exception more generally instead of restricting it to PickleError.

In the meantime, I see two possible workarounds.

If you know for sure where the InferenceServerException is emitted, you can simply replace it's value during logging:

try:
    tensorrt.do_something()
except InferenceServerException:
    type, _, tb = sys.exc_info()
    logger.opt(exception=(type, None, tb)).error("An error occurred")

Otherwise, you can do this from within your _format_stacktrace() function:

if record["exception"] is not None:
    record["extra"]["stack"] = stackprinter.format(record["exception"])
    format_ += "<red><bold>{extra[stack]}</bold></red>\n"
    if record["exception"].type is InferenceServerException:
        record["exception"] = record["exception"]._replace(value=None)

@JulianOrteil
Copy link
Author

Excellent. Thank you for the prompt response.

I'll implement your suggestion and leave this bug report open if you wish to link a pull request to it.

Jules

@JulianOrteil
Copy link
Author

@Delgan

Update:
I'm unable to use the workarounds you proposed. Both produce errors, one in stackprinter and the other in loguru.

Proposed solution 1:

try:
    tensorrt.do_something()
except InferenceServerException:
    type, _, tb = sys.exc_info()
    logger.opt(exception=(type, None, tb)).error("An error occurred")

This produces a ValueError in stackprinter as it is expecting an exception for the value (where None is above). As I do not have control over the standards used in this application (it is for a client), not using stackprinter is unfortunately out of my control.

Proposed solution 2:

  if record["exception"] is not None:
       record["extra"]["stack"] = stackprinter.format(record["exception"])
       format_ += "<red><bold>{extra[stack]}</bold></red>\n"
       if record["exception"].type is InferenceServerException:
           record["exception"].value = None

This produces an AttributeError in loguru. The stacktrace is below:

Traceback (most recent call last):
  File "C:\Users\jules\.conda\envs\app\lib\site-packages\loguru\_handler.py", line 107, in emit
    dynamic_format = self._formatter(record)
  File "C:\Users\jules\Documents\app\app\utils\logging.py", line 88, in _format_stacktrace
    record["exception"].value = None
AttributeError: can't set attribute

I was able to get a work around going, but I just wanted to alert you and anyone else looking at this issue to errors encountered in the proposed solutions.

My solution:
This is the solution I used to work around this problem.
Note: I did not modify the _format_stacktrace() function proposed by @Delgan.

# Defined in the same file causing the error
class TRTISException(Exception):
    """
    Temporary exception used to bypass C pointers in the
    :obj:`tensorrtserver` library. It causes pickling errors in
    :obj:`loguru`.
    """

...

# The new try/except statement
try:
    # <Code here raises 'InferenceServerException'>
except InferenceServerException as e:
    type_, _, tb = sys.exc_info()
    # logger.exception("An issue occurred while contacting the inference server:\n")
    logger.opt(exception=(type_, TRTISException(str(e._msg)), tb)).error("An issue occurred while contacting the inference server:\n")

@Delgan
Copy link
Owner

Delgan commented Oct 2, 2020

@JulianOrteil Yeah, sorry. I realized there will be an error with the second snippet I provided because record["exception"] is an immutable namedtuple() but I forgot to update the comment. >.<

I was thinking the stackprinter would work, though. I created a PR on the stackprinter repository, hopefully it will soon support None value inside exception tuple.

Thanks for updating this ticket with an usable workaround! 😄

@JulianOrteil
Copy link
Author

@Delgan Anytime!
Thank you for creating a PR in the stackprinter repo for me.

I also thought I would bring another workaround to this issue as well. Per the docs, namedtuple() has a _replace() function that creates a new instance of the tuple and just refills it with the updated value. Knowing this, we just replace the entire record["exception"] portion of the record.

Code:

# Updated version of proposed solution 2
# Inside the _format_stacktrace() function
if record["exception"] is not None:
    if type(record["exception"].value) is InferenceServerException:
        record["exception"] = record["exception"]._replace(value=Exception(record["exception"].value._msg))
    record["extra"]["stack"] = stackprinter.format(record["exception"])
    format_ += "<red><bold>{extra[stack]}</bold></red>\n"

@Delgan
Copy link
Owner

Delgan commented Oct 2, 2020

Wow, I never noticed these methods existed nor that they were part of the documentation. O.o

Again, that a great workaround. Thanks for sharing it!

@holyachon
Copy link

Hello. Is this error fixed at latest version 0.6.0?

@Delgan
Copy link
Owner

Delgan commented May 20, 2022

@holyachon @JulianOrteil This issue is not yet fixed but I'll handle it soon.

@Delgan Delgan reopened this May 20, 2022
@pbednarz1
Copy link

Any progress on that?

@Delgan
Copy link
Owner

Delgan commented Aug 31, 2023

I'm closing this ticket because this has been fixed by #905 and should no longer be a problem with the next release. 👍

@Delgan Delgan closed this as completed Aug 31, 2023
jmctune referenced this issue in dqx-translation-project/dqxclarity Oct 9, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [loguru](https://github.com/Delgan/loguru)
([changelog](https://github.com/Delgan/loguru/blob/master/CHANGELOG.rst))
| `==0.7.0` -> `==0.7.2` |
[![age](https://developer.mend.io/api/mc/badges/age/pypi/loguru/0.7.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/loguru/0.7.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/loguru/0.7.0/0.7.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/loguru/0.7.0/0.7.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>Delgan/loguru (loguru)</summary>

###
[`v0.7.2`](https://github.com/Delgan/loguru/blob/HEAD/CHANGELOG.rst#072-2023-09-11)

[Compare
Source](https://github.com/Delgan/loguru/compare/0.7.1...0.7.2)

\=====================

- Add support for formatting of `ExceptionGroup` errors (`#&#8203;805
<https://github.com/Delgan/loguru/issues/805>`\_).
- Fix possible `RuntimeError` when using
`multiprocessing.set_start_method()` after importing the `logger`
(`#&#8203;974 <https://github.com/Delgan/loguru/issues/974>`\_)
- Fix formatting of possible `__notes__` attached to an `Exception`
(`#&#8203;980 <https://github.com/Delgan/loguru/issues/980>`\_).

###
[`v0.7.1`](https://github.com/Delgan/loguru/blob/HEAD/CHANGELOG.rst#071-2023-09-04)

[Compare
Source](https://github.com/Delgan/loguru/compare/0.7.0...0.7.1)

\=====================

- Add a new `context` optional argument to `logger.add()` specifying
`multiprocessing` context (like `"spawn"` or `"fork"`) to be used
internally instead of the default one (`#&#8203;851
<https://github.com/Delgan/loguru/issues/851>`\_).
- Add support for true colors on Windows using ANSI/VT console when
available (`#&#8203;934 <https://github.com/Delgan/loguru/issues/934>`*,
thanks `@tunaflsh <https://github.com/tunaflsh>`*).
- Fix possible deadlock when calling `logger.complete()` with concurrent
logging of an asynchronous sink (`#&#8203;906
<https://github.com/Delgan/loguru/issues/906>`\_).
- Fix file possibly rotating too early or too late when re-starting an
application around midnight (`#&#8203;894
<https://github.com/Delgan/loguru/issues/894>`\_).
- Fix inverted `"<hide>"` and `"<strike>"` color tags (`#&#8203;943
<https://github.com/Delgan/loguru/pull/943>`*, thanks `@tunaflsh
<https://github.com/tunaflsh>`*).
- Fix possible untraceable errors raised when logging non-unpicklable
`Exception` instances while using `enqueue=True` (`#&#8203;329
<https://github.com/Delgan/loguru/issues/329>`\_).
- Fix possible errors raised when logging non-picklable `Exception`
instances while using `enqueue=True` (`#&#8203;342
<https://github.com/Delgan/loguru/issues/342>`*, thanks `@ncoudene
<https://github.com/ncoudene>`*).
- Fix missing seconds and microseconds when formatting timezone offset
that requires such accuracy (`#&#8203;961
<https://github.com/Delgan/loguru/issues/961>`\_).
- Raise `ValueError` if an attempt to use nanosecond precision for time
formatting is detected (`#&#8203;855
<https://github.com/Delgan/loguru/issues/855>`\_).

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/dqx-translation-project/dqxclarity).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjMiLCJ1cGRhdGVkSW5WZXIiOiIzNy44LjEiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
github-actions bot pushed a commit to afonasev/deta_todo_service that referenced this issue Jan 1, 2025
[//]: # (dependabot-start)
⚠️  **Dependabot is rebasing this PR** ⚠️ 

Rebasing might not happen immediately, so don't worry if this takes some
time.

Note: if you make any changes to this PR yourself, they will take
precedence over the rebase.

---

[//]: # (dependabot-end)

Bumps [loguru](https://github.com/Delgan/loguru) from 0.6.0 to 0.7.3.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/Delgan/loguru/releases">loguru's
releases</a>.</em></p>
<blockquote>
<h2>0.7.3</h2>
<ul>
<li>Fix Cython incompatibility caused by the absence of underlying stack
frames, which resulted in a <code>ValueError</code> during logging (<a
href="https://github.com/Delgan/loguru/issues/88">#88</a>).</li>
<li>Fix possible <code>RuntimeError</code> when removing all handlers
with <code>logger.remove()</code> due to thread-safety issue (<a
href="https://github.com/Delgan/loguru/issues/1183">#1183</a>,
thanks <a
href="https://github.com/jeremyk"><code>@​jeremyk</code></a>).</li>
<li>Fix <code>diagnose=True</code> option of exception formatting not
working as expected with Python 3.13 (<a
href="https://github.com/Delgan/loguru/issues/1235">#1235</a>,
thanks <a
href="https://github.com/etianen"><code>@​etianen</code></a>).</li>
<li>Fix non-standard level names not fully compatible with
<code>logging.Formatter()</code> (<a
href="https://github.com/Delgan/loguru/issues/1231">#1231</a>,
thanks <a
href="https://github.com/yechielb2000"><code>@​yechielb2000</code></a>).</li>
<li>Fix inability to display a literal <code>&quot;\&quot;</code>
immediately before color markups (<a
href="https://github.com/Delgan/loguru/issues/988">#988</a>).</li>
<li>Fix possible infinite recursion when an exception is raised from a
<code>__repr__</code> method decorated with <code>logger.catch()</code>
(<a
href="https://github.com/Delgan/loguru/issues/1044">#1044</a>).</li>
<li>Improve performance of <code>datetime</code> formatting while
logging messages (<a
href="https://github.com/Delgan/loguru/issues/1201">#1201</a>,
thanks <a
href="https://github.com/trim21"><code>@​trim21</code></a>).</li>
<li>Reduce startup time in the presence of installed but unused
<code>IPython</code> third-party library (<a
href="https://github.com/Delgan/loguru/issues/1001">#1001</a>,
thanks <a
href="https://github.com/zakstucke"><code>@​zakstucke</code></a>).</li>
</ul>
<h2>0.7.2</h2>
<ul>
<li>Add support for formatting of <code>ExceptionGroup</code> errors (<a
href="https://github.com/Delgan/loguru/issues/805">#805</a>).</li>
<li>Fix possible <code>RuntimeError</code> when using
<code>multiprocessing.set_start_method()</code> after importing the
<code>logger</code> (<a
href="https://github.com/Delgan/loguru/issues/974">#974</a>).</li>
<li>Fix formatting of possible <code>__notes__</code> attached to an
<code>Exception</code> (<a
href="https://github.com/Delgan/loguru/issues/980">#980</a>).</li>
</ul>
<h2>0.7.1</h2>
<ul>
<li>Add a new <code>context</code> optional argument to
<code>logger.add()</code> specifying <code>multiprocessing</code>
context (like <code>&quot;spawn&quot;</code> or
<code>&quot;fork&quot;</code>) to be used internally instead of the
default one (<a
href="https://github.com/Delgan/loguru/issues/851">#851</a>).</li>
<li>Add support for true colors on Windows using ANSI/VT console when
available (<a
href="https://github.com/Delgan/loguru/issues/934">#934</a>,
thanks <a
href="https://github.com/tunaflsh"><code>@​tunaflsh</code></a>).</li>
<li>Fix possible deadlock when calling <code>logger.complete()</code>
with concurrent logging of an asynchronous sink (<a
href="https://github.com/Delgan/loguru/issues/906">#906</a>).</li>
<li>Fix file possibly rotating too early or too late when re-starting an
application around midnight (<a
href="https://github.com/Delgan/loguru/issues/894">#894</a>).</li>
<li>Fix inverted <code>&quot;&lt;hide&gt;&quot;</code> and
<code>&quot;&lt;strike&gt;&quot;</code> color tags (<a
href="https://github.com/Delgan/loguru/issues/943">#943</a>,
thanks <a
href="https://github.com/tunaflsh"><code>@​tunaflsh</code></a>).</li>
<li>Fix possible untraceable errors raised when logging non-unpicklable
<code>Exception</code> instances while using <code>enqueue=True</code>
(<a
href="https://github.com/Delgan/loguru/issues/329">#329</a>).</li>
<li>Fix possible errors raised when logging non-picklable
<code>Exception</code> instances while using <code>enqueue=True</code>
(<a
href="https://github.com/Delgan/loguru/issues/342">#342</a>,
thanks <a
href="https://github.com/ncoudene"><code>@​ncoudene</code></a>).</li>
<li>Fix missing seconds and microseconds when formatting timezone offset
that requires such accuracy (<a
href="https://github.com/Delgan/loguru/issues/961">#961</a>).</li>
<li>Raise <code>ValueError</code> if an attempt to use nanosecond
precision for time formatting is detected (<a
href="https://github.com/Delgan/loguru/issues/855">#855</a>).</li>
</ul>
<h2>0.7.0</h2>
<ul>
<li>Update <code>InterceptHandler</code> recipe to make it compatible
with Python 3.11 (<a
href="https://github.com/Delgan/loguru/issues/654">#654</a>).</li>
<li>Add a new <code>watch</code> optional argument to file sinks in
order to automatically re-create possibly deleted or changed file (<a
href="https://github.com/Delgan/loguru/issues/471">#471</a>).</li>
<li>Make <code>patch()</code> calls cumulative instead of overriding the
possibly existing patching function (<a
href="https://github.com/Delgan/loguru/issues/462">#462</a>).</li>
<li>Make sinks added with <code>enqueue=True</code> and
<code>catch=False</code> still process logged messages in case of
internal exception (<a
href="https://github.com/Delgan/loguru/issues/833">#833</a>).</li>
<li>Avoid possible deadlocks caused by re-using the logger inside a
sink, a signal handler or a <code>__del__</code> method. Since the
logger is not re-entrant, such misuse will be detected and will now
generate a <code>RuntimeError</code> (<a
href="https://github.com/Delgan/loguru/issues/712">#712</a>,
thanks <a
href="https://github.com/jacksmith15"><code>@​jacksmith15</code></a>).</li>
<li>Fix file sink rotation using an aware <code>datetime.time</code> for
which the timezone was ignored (<a
href="https://github.com/Delgan/loguru/issues/697">#697</a>).</li>
<li>Fix logs colorization not automatically enabled for Jupyter Notebook
and Google Colab (<a
href="https://github.com/Delgan/loguru/issues/494">#494</a>).</li>
<li>Fix logs colorization not automatically enabled for Github Actions
and others CI platforms (<a
href="https://github.com/Delgan/loguru/issues/604">#604</a>).</li>
<li>Fix <code>logger.complete()</code> possibly hanging forever when
<code>enqueue=True</code> and <code>catch=False</code> if internal
thread killed due to <code>Exception</code> raised by sink (<a
href="https://github.com/Delgan/loguru/issues/647">#647</a>).</li>
<li>Fix incompatibility with <code>freezegun</code> library used to
simulate time (<a
href="https://github.com/Delgan/loguru/issues/600">#600</a>).</li>
<li>Raise exception if <code>logger.catch()</code> is used to wrap a
class instead of a function to avoid unexpected behavior (<a
href="https://github.com/Delgan/loguru/issues/623">#623</a>).</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/Delgan/loguru/blob/master/CHANGELOG.rst">loguru's
changelog</a>.</em></p>
<blockquote>
<h1><code>0.7.3</code>_ (2024-12-06)</h1>
<ul>
<li>Fix Cython incompatibility caused by the absence of underlying stack
frames, which resulted in a <code>ValueError</code> during logging
(<code>[#88](Delgan/loguru#88)
&lt;https://github.com/Delgan/loguru/issues/88&gt;</code>_).</li>
<li>Fix possible <code>RuntimeError</code> when removing all handlers
with <code>logger.remove()</code> due to thread-safety issue
(<code>[#1183](Delgan/loguru#1183)
&lt;https://github.com/Delgan/loguru/issues/1183&gt;</code><em>, thanks
<code>@jeremyk &lt;https://github.com/jeremyk&gt;</code></em>).</li>
<li>Fix <code>diagnose=True</code> option of exception formatting not
working as expected with Python 3.13
(<code>[#1235](Delgan/loguru#1235)
&lt;https://github.com/Delgan/loguru/issues/1235&gt;</code><em>, thanks
<code>@etianen &lt;https://github.com/etianen&gt;</code></em>).</li>
<li>Fix non-standard level names not fully compatible with
<code>logging.Formatter()</code>
(<code>[#1231](Delgan/loguru#1231)
&lt;https://github.com/Delgan/loguru/issues/1231&gt;</code><em>, thanks
<code>@yechielb2000
&lt;https://github.com/yechielb2000&gt;</code></em>).</li>
<li>Fix inability to display a literal <code>&quot;\&quot;</code>
immediately before color markups
(<code>[#988](Delgan/loguru#988)
&lt;https://github.com/Delgan/loguru/issues/988&gt;</code>_).</li>
<li>Fix possible infinite recursion when an exception is raised from a
<code>__repr__</code> method decorated with <code>logger.catch()</code>
(<code>[#1044](Delgan/loguru#1044)
&lt;https://github.com/Delgan/loguru/issues/1044&gt;</code>_).</li>
<li>Improve performance of <code>datetime</code> formatting while
logging messages
(<code>[#1201](Delgan/loguru#1201)
&lt;https://github.com/Delgan/loguru/issues/1201&gt;</code><em>, thanks
<code>@trim21 &lt;https://github.com/trim21&gt;</code></em>).</li>
<li>Reduce startup time in the presence of installed but unused
<code>IPython</code> third-party library
(<code>[#1001](Delgan/loguru#1001)
&lt;https://github.com/Delgan/loguru/issues/1001&gt;</code><em>, thanks
<code>@zakstucke &lt;https://github.com/zakstucke&gt;</code></em>).</li>
</ul>
<h1><code>0.7.2</code>_ (2023-09-11)</h1>
<ul>
<li>Add support for formatting of <code>ExceptionGroup</code> errors
(<code>[#805](Delgan/loguru#805)
&lt;https://github.com/Delgan/loguru/issues/805&gt;</code>_).</li>
<li>Fix possible <code>RuntimeError</code> when using
<code>multiprocessing.set_start_method()</code> after importing the
<code>logger</code>
(<code>[#974](Delgan/loguru#974)
&lt;https://github.com/Delgan/loguru/issues/974&gt;</code>_).</li>
<li>Fix formatting of possible <code>__notes__</code> attached to an
<code>Exception</code>
(<code>[#980](Delgan/loguru#980)
&lt;https://github.com/Delgan/loguru/issues/980&gt;</code>_).</li>
</ul>
<h1><code>0.7.1</code>_ (2023-09-04)</h1>
<ul>
<li>Add a new <code>context</code> optional argument to
<code>logger.add()</code> specifying <code>multiprocessing</code>
context (like <code>&quot;spawn&quot;</code> or
<code>&quot;fork&quot;</code>) to be used internally instead of the
default one (<code>[#851](Delgan/loguru#851)
&lt;https://github.com/Delgan/loguru/issues/851&gt;</code>_).</li>
<li>Add support for true colors on Windows using ANSI/VT console when
available (<code>[#934](Delgan/loguru#934)
&lt;https://github.com/Delgan/loguru/issues/934&gt;</code><em>, thanks
<code>@tunaflsh &lt;https://github.com/tunaflsh&gt;</code></em>).</li>
<li>Fix possible deadlock when calling <code>logger.complete()</code>
with concurrent logging of an asynchronous sink
(<code>[#906](Delgan/loguru#906)
&lt;https://github.com/Delgan/loguru/issues/906&gt;</code>_).</li>
<li>Fix file possibly rotating too early or too late when re-starting an
application around midnight
(<code>[#894](Delgan/loguru#894)
&lt;https://github.com/Delgan/loguru/issues/894&gt;</code>_).</li>
<li>Fix inverted <code>&quot;&lt;hide&gt;&quot;</code> and
<code>&quot;&lt;strike&gt;&quot;</code> color tags
(<code>[#943](Delgan/loguru#943)
&lt;https://github.com/Delgan/loguru/pull/943&gt;</code><em>, thanks
<code>@tunaflsh &lt;https://github.com/tunaflsh&gt;</code></em>).</li>
<li>Fix possible untraceable errors raised when logging non-unpicklable
<code>Exception</code> instances while using <code>enqueue=True</code>
(<code>[#329](Delgan/loguru#329)
&lt;https://github.com/Delgan/loguru/issues/329&gt;</code>_).</li>
<li>Fix possible errors raised when logging non-picklable
<code>Exception</code> instances while using <code>enqueue=True</code>
(<code>[#342](Delgan/loguru#342)
&lt;https://github.com/Delgan/loguru/issues/342&gt;</code><em>, thanks
<code>@ncoudene &lt;https://github.com/ncoudene&gt;</code></em>).</li>
<li>Fix missing seconds and microseconds when formatting timezone offset
that requires such accuracy
(<code>[#961](Delgan/loguru#961)
&lt;https://github.com/Delgan/loguru/issues/961&gt;</code>_).</li>
<li>Raise <code>ValueError</code> if an attempt to use nanosecond
precision for time formatting is detected
(<code>[#855](Delgan/loguru#855)
&lt;https://github.com/Delgan/loguru/issues/855&gt;</code>_).</li>
</ul>
<h1><code>0.7.0</code>_ (2023-04-10)</h1>
<ul>
<li>Update <code>InterceptHandler</code> recipe to make it compatible
with Python 3.11
(<code>[#654](Delgan/loguru#654)
&lt;https://github.com/Delgan/loguru/issues/654&gt;</code>_).</li>
<li>Add a new <code>watch</code> optional argument to file sinks in
order to automatically re-create possibly deleted or changed file
(<code>[#471](Delgan/loguru#471)
&lt;https://github.com/Delgan/loguru/issues/471&gt;</code>_).</li>
<li>Make <code>patch()</code> calls cumulative instead of overriding the
possibly existing patching function
(<code>[#462](Delgan/loguru#462)
&lt;https://github.com/Delgan/loguru/issues/462&gt;</code>_).</li>
<li>Make sinks added with <code>enqueue=True</code> and
<code>catch=False</code> still process logged messages in case of
internal exception
(<code>[#833](Delgan/loguru#833)
&lt;https://github.com/Delgan/loguru/issues/833&gt;</code>_).</li>
<li>Avoid possible deadlocks caused by re-using the logger inside a
sink, a signal handler or a <code>__del__</code> method. Since the
logger is not re-entrant, such misuse will be detected and will now
generate a <code>RuntimeError</code>
(<code>[#712](Delgan/loguru#712)
&lt;https://github.com/Delgan/loguru/issues/712&gt;</code><em>, thanks
<code>@jacksmith15
&lt;https://github.com/jacksmith15&gt;</code></em>).</li>
<li>Fix file sink rotation using an aware <code>datetime.time</code> for
which the timezone was ignored
(<code>[#697](Delgan/loguru#697)
&lt;https://github.com/Delgan/loguru/issues/697&gt;</code>_).</li>
<li>Fix logs colorization not automatically enabled for Jupyter Notebook
and Google Colab
(<code>[#494](Delgan/loguru#494)
&lt;https://github.com/Delgan/loguru/issues/494&gt;</code>_).</li>
<li>Fix logs colorization not automatically enabled for Github Actions
and others CI platforms
(<code>[#604](Delgan/loguru#604)
&lt;https://github.com/Delgan/loguru/issues/604&gt;</code>_).</li>
<li>Fix <code>logger.complete()</code> possibly hanging forever when
<code>enqueue=True</code> and <code>catch=False</code> if internal
thread killed due to <code>Exception</code> raised by sink
(<code>[#647](Delgan/loguru#647)
&lt;https://github.com/Delgan/loguru/issues/647&gt;</code>_).</li>
<li>Fix incompatibility with <code>freezegun</code> library used to
simulate time (<code>[#600](Delgan/loguru#600)
&lt;https://github.com/Delgan/loguru/issues/600&gt;</code>_).</li>
<li>Raise exception if <code>logger.catch()</code> is used to wrap a
class instead of a function to avoid unexpected behavior
(<code>[#623](Delgan/loguru#623)
&lt;https://github.com/Delgan/loguru/issues/623&gt;</code>_).</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/Delgan/loguru/commit/ae3bfd1b85b6b4a3db535f69b975687c79498be4"><code>ae3bfd1</code></a>
Bump version to 0.7.3</li>
<li><a
href="https://github.com/Delgan/loguru/commit/ccca3566cc00c22eed8659705e45386fa2101b5d"><code>ccca356</code></a>
Replace &quot;notifiers&quot; (seems unmaintained) with
&quot;apprise&quot; in docs (<a
href="https://github.com/Delgan/loguru/issues/1251">#1251</a>)</li>
<li><a
href="https://github.com/Delgan/loguru/commit/a372814bf79d47628e66ca9a91072f53fba032f8"><code>a372814</code></a>
Configure &quot;trusted publishing&quot; in Github workflow</li>
<li><a
href="https://github.com/Delgan/loguru/commit/633016db07e5dff63bc05dd3c4d5aa81b6190700"><code>633016d</code></a>
Use tox to define the &quot;release&quot; command</li>
<li><a
href="https://github.com/Delgan/loguru/commit/ef12cbbaf54fb2e64ca66b0a90675cdf9e8a522f"><code>ef12cbb</code></a>
Convert README from RST to MD (fix PyPI packaging)</li>
<li><a
href="https://github.com/Delgan/loguru/commit/cb3314a5af107ad175a9bafa11b1b79670e3067a"><code>cb3314a</code></a>
Add Github action to verify packaging</li>
<li><a
href="https://github.com/Delgan/loguru/commit/6161a13b79e1a3a29e922926b44f26edbcc3c06a"><code>6161a13</code></a>
Complete the &quot;Troubleshooting&quot; docs with more examples</li>
<li><a
href="https://github.com/Delgan/loguru/commit/7f5001fe46393627ced287bba2c4064442c3fd25"><code>7f5001f</code></a>
Simplify the example of dynamic handler level</li>
<li><a
href="https://github.com/Delgan/loguru/commit/2e0cd7bb5105461057c56aefb225da569882ad29"><code>2e0cd7b</code></a>
Move &quot;Introduction to logging&quot; docs to a new section</li>
<li><a
href="https://github.com/Delgan/loguru/commit/72b93d1a24d1491ce7ba752fe36c14f9570a5d63"><code>72b93d1</code></a>
Correct outdated instructions for reporting a vulnerability</li>
<li>Additional commits viewable in <a
href="https://github.com/Delgan/loguru/compare/0.6.0...0.7.3">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=loguru&package-manager=pip&previous-version=0.6.0&new-version=0.7.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to an already existing feature
Projects
None yet
Development

No branches or pull requests

4 participants