Skip to content

[BUG]: patch_all breaks issubclass #14075

@ppsmilesi

Description

@ppsmilesi

Tracer Version(s)

2.18.1

Python Version(s)

Python 3.11.1

Pip Version(s)

pip 25.1.1

Bug Report

Hello !

I got a issubclass TypeError when using Datadog APM with ddtrace.patch_all.

The stacktrace of the below reproduction code:

Traceback (most recent call last):
  File "/Users/paulmilesi/Repos/api/ddtrace_issue.py", line 17, in <module>
    issubclass(psycopg.AsyncCursor, SomeClass)
  File "<frozen abc>", line 123, in __subclasscheck__
TypeError: issubclass() arg 1 must be a class

In my app, patch_all patches psycopg.AsyncCursor and my app then crashes when running issubclass on psycopg.AsyncCursor against a class subclassing abc.ABC. patch_all uses wrapt.FunctionWrapper to patch psycopg.AsyncCursor and there a wrapt/stdlib issue when checking against ABC classes.
I am not sure you can do anything about it...

Please find the related issues in wrapt and python stdlib too:

Reproduction Code

import abc

from ddtrace import patch_all

patch_all()

import psycopg


class SomeClass(abc.ABC):
    @abc.abstractmethod
    def some_method(self):
        pass


issubclass(psycopg.AsyncCursor, SomeClass)

Error Logs

No response

Libraries in Use

psycopg==3.2.9

Operating System

Darwin Mac.lan 24.1.0 Darwin Kernel Version 24.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions