Skip to content

Fix sw_psycopg2 register_type() #211

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

Merged
merged 5 commits into from
Jun 3, 2022
Merged

Conversation

tom-pytel
Copy link
Contributor

psycopg2._psycopg.register_type() can be called with a connection or cursor, but since these are wrapped proxy objects when instrumented the binary module _psycopg does not recognize them causing calls like psycopg2.extras.register_json() to fail:

...
   File "/usr/local/lib/python3.10/site-packages/psycopg2/_json.py", line 120, in register_json
     register_type(JSON, not globally and conn_or_curs or None)
 TypeError: argument 2 must be a connection, cursor or None

The fix is simply to pass unwrapped connection or cursor.

@tom-pytel tom-pytel added the bug Something isn't working label Jun 3, 2022
@tom-pytel tom-pytel added this to the 1.0.0 milestone Jun 3, 2022
@Superskyyy
Copy link
Member

This addresses this apache/skywalking#8556 problem, right? Thanks for looking into this.

@tom-pytel
Copy link
Contributor Author

This addresses this apache/skywalking#8556 problem, right? Thanks for looking into this.

Should, yes.

@Superskyyy
Copy link
Member

This addresses this apache/skywalking#8556 problem, right? Thanks for looking into this.

Should, yes.

If you have verified it works for Django version above 3.10 then LGTM. :)

@tom-pytel
Copy link
Contributor Author

This addresses this apache/skywalking#8556 problem, right? Thanks for looking into this.

Should, yes.

If you have verified it works for Django version above 3.10 then LGTM. :)

There is a Django 3.10? I did do a quick test of our fork of this with Django 4.0.5 and it works, waiting on more thorough tests from the test monkeys though.

@Superskyyy
Copy link
Member

Superskyyy commented Jun 3, 2022

This addresses this apache/skywalking#8556 problem, right? Thanks for looking into this.

Should, yes.

If you have verified it works for Django version above 3.10 then LGTM. :)

There is a Django 3.10? I did do a quick test of our fork of this with Django 4.0.5 and it works, waiting on more thorough tests from the test monkeys though.

LOL I forgot Django is already at 4.x. Btw we should bump up the checked versions in Django plugin supported matrix.

support_matrix = {
    'django': {
        '>=3.6': ['3.2'],
        # ">=3.8": ["4.0a1"]  # expected Dec 2021
    }
}

change to something like

support_matrix = {
    'django': {
        '>=3.6': ['3.2'],
        ">=3.8': ['4.0'] # 4.2 will support py3.11 
    }
}

BTW, do you think we should remove the support for 3.6? It has been sunsetted since 6 months ago. We will introduce some advanced features requiring 3.7 up, like the automatic post-fork hook.

@tom-pytel
Copy link
Contributor Author

LOL I forgot Django is already at 4.x. Btw we should bump up the checked versions in Django plugin supported matrix.

That is for a different PR, this one is about psycopg2.

BTW, do you think we should remove the support for 3.6? It has been sunsetted since 6 months ago. We will introduce some advanced features requiring 3.7 up, like the automatic post-fork hook.

If you are asking my opinion then don't remove support for something until and unless you need to. There's nothing worse than having your project stop working for no good reason other than an arbitrary date.

@Superskyyy
Copy link
Member

That is for a different PR, this one is about psycopg2.

If you are asking my opinion then don't remove support for something until and unless you need to. There's nothing worse than having your project stop working for no good reason other than an arbitrary date.

Yes, thanks for the explanation. LGTM

@Superskyyy Superskyyy changed the title fix sw_psycopg2 register_type() Fix sw_psycopg2 register_type() Jun 3, 2022
@Superskyyy Superskyyy merged commit bf0db59 into apache:master Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants