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

Intermittent TypeError in get_sql_value: isinstance() arg 2 must be a type, a tuple of types, or a union #887

Open
sarvesh-deserve opened this issue Oct 3, 2023 · 2 comments

Comments

@sarvesh-deserve
Copy link

Issue Description:

I've encountered an intermittent issue in the get_sql_value function where a TypeError occurs. The error message indicates that the problem is related to the isinstance() function, specifically at the line isinstance(value, datetime.datetime). The error message is as follows:

TypeError: isinstance() arg 2 must be a type, a tuple of types, or a union

Steps to Reproduce:
Unfortunately, I am unable to consistently reproduce this issue, which makes it challenging to pinpoint the exact cause. However, the error seems to occur intermittently during the execution of the get_sql_value function.

Expected Behavior:
The isinstance() function should accept datetime.datetime as a valid type for the value argument.

Actual Behavior:
Intermittently, the TypeError mentioned above occurs, preventing the code from executing as expected.

@dantownsend
Copy link
Member

Interesting - I had a look at the code for get_sql_value and I can't see any obvious issues.

elif isinstance(value, datetime.datetime):

Which Python version are you running?

I Googled around, and found this discussion, but it's pretty old.

I wonder if there's anything in Piccolo or your application code which does something like:

datetime.datetime = 'foo'

i.e. overrides datetime.datetime, which then causes isinstance to fail.

@sarvesh-deserve
Copy link
Author

I am using 3.11.2, and it is happening for integer column with default value as 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants