Commit 38e9fc5
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 38e9fc5
File tree
2 files changed
+40
-15
lines changed- Lib/test/test_sqlite3
- stdlib/src
2 files changed
+40
-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 | + | |
855 | 879 | | |
856 | 880 | | |
857 | 881 | | |
| |||
873 | 897 | | |
874 | 898 | | |
875 | 899 | | |
876 | | - | |
| 900 | + | |
877 | 901 | | |
878 | 902 | | |
879 | 903 | | |
880 | 904 | | |
881 | 905 | | |
882 | 906 | | |
883 | 907 | | |
884 | | - | |
| 908 | + | |
| 909 | + | |
885 | 910 | | |
886 | | - | |
887 | | - | |
888 | | - | |
889 | | - | |
890 | | - | |
891 | | - | |
892 | | - | |
893 | | - | |
894 | | - | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
895 | 922 | | |
896 | 923 | | |
897 | 924 | | |
| |||
908 | 935 | | |
909 | 936 | | |
910 | 937 | | |
911 | | - | |
| 938 | + | |
912 | 939 | | |
913 | 940 | | |
914 | 941 | | |
| |||
0 commit comments