-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix PyArg_ParseTupleAndKeywords calls that accept optional strings.
A lot of the keywords in Cursor methods are optional, but I incorrectly used 's' in the format string. This meant you could call the function without passing them, but would fail if you passed None for them, which is not what I intended. It has not been noticed in normal usage because it is easier to call `f('t1')` than `f('t1', schema=None, catalog=None)`. However, when you use a wrapper, like aioodbc does, it will fail: def wrapper(table, schema=None, catalog=None): call(cursor.columns, table, schema=schema, catalog=catalog) def call(func, *args, **kwargs): func(*args, **kwargs) At this point, kwargs is {schema:None, catalog:None} and now we're passing None explicitly. The solution, of course, is to use 'z' instead. Note that I have only corrected Cursor methods. I only wrote a test for Cursor.columns in SQL Server Python 3 and PostgreSQL Python 3. This bug is in pyodbc before any database calls are made so it is database-independent.
- Loading branch information
1 parent
a60c6d5
commit 383fa6c
Showing
3 changed files
with
73 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters