Commit c015fd8
committed
Fix sqlite3 Connection initialization check
Add proper __init__ validation for sqlite3.Connection to ensure base class
__init__ is called before using connection methods. This fixes the
test_connection_constructor_call_check test case.
Changes:
- Modified Connection.py_new to detect subclassing
- For base Connection class, initialization happens immediately in py_new
- For subclassed Connection, db is initialized as None
- Added __init__ method that performs actual database initialization
- Updated _db_lock error message to match CPython: 'Base Connection.__init__ not called.'
This ensures CPython compatibility where attempting to use a Connection
subclass instance without calling the base __init__ raises ProgrammingError.1 parent 3b48dcc commit c015fd8
File tree
2 files changed
+43
-15
lines changed- Lib/test/test_sqlite3
- stdlib/src
2 files changed
+43
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
225 | | - | |
226 | 224 | | |
227 | 225 | | |
228 | 226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
851 | 851 | | |
852 | 852 | | |
853 | 853 | | |
854 | | - | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
855 | 886 | | |
856 | 887 | | |
857 | 888 | | |
| |||
873 | 904 | | |
874 | 905 | | |
875 | 906 | | |
876 | | - | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
877 | 915 | | |
878 | 916 | | |
879 | 917 | | |
880 | 918 | | |
881 | 919 | | |
882 | 920 | | |
883 | 921 | | |
884 | | - | |
885 | 922 | | |
886 | | - | |
887 | | - | |
888 | | - | |
889 | | - | |
890 | | - | |
891 | | - | |
892 | | - | |
893 | | - | |
894 | | - | |
| 923 | + | |
| 924 | + | |
895 | 925 | | |
896 | 926 | | |
897 | 927 | | |
| |||
908 | 938 | | |
909 | 939 | | |
910 | 940 | | |
911 | | - | |
| 941 | + | |
912 | 942 | | |
913 | 943 | | |
914 | 944 | | |
| |||
0 commit comments