Skip to content

Commit 8154150

Browse files
committed
compatibility with PEP 667 in Python-3.13
1 parent 5297d25 commit 8154150

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

sqlite_bro/sqlite_bro.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@
3434

3535
tipwindow = None
3636

37+
# starting Python-3.13, PEP 667 forces us to us a specific dictionnary pydef_locals instead of locals()
38+
pydef_locals ={}
3739

3840
class App:
3941
"""the GUI graphic application"""
4042

4143
def __init__(self, use_gui=True):
4244
"""create a tkk graphic interface with a main window tk_win"""
43-
self.__version__ = "0.12.2"
44-
self._title = "of 2022-02-04a : 'Filling the blanks !'"
45+
self.__version__ = "0.13.0"
46+
self._title = "of 2024-05-11a : 'PEP 667 me up !'"
4547
self.conn = None # Baresql database object
4648
self.database_file = ""
4749
self.initialdir = "."
@@ -1942,19 +1944,20 @@ def createpydef(self, sql):
19421944

19431945
instruction = sql.strip("; \t\n\r")
19441946
# create Python function in Python
1945-
exec(instruction[2:], globals(), locals())
1947+
exec(instruction[2:], globals(), pydef_locals)
19461948
# add Python function in SQLite
19471949
instr_header = re.findall(r"\w+", instruction[: (instruction + ")").find(")")])
19481950
instr_name = instr_header[1]
19491951
instr_parms = len(instr_header) - 2
1952+
instr_pointer=eval(instr_name, globals(), pydef_locals)
1953+
self.conn.create_function(instr_name, instr_parms, instr_pointer)
19501954
instr_add = "self.conn.create_function('%s', %s, %s)" % (
19511955
instr_name,
19521956
instr_parms,
19531957
instr_name,
19541958
)
1955-
exec(instr_add, globals(), locals())
19561959
# housekeeping definition of pydef in a dictionnary
1957-
the_help = dict(globals(), **locals())[instr_name].__doc__
1960+
the_help = pydef_locals[instr_name].__doc__
19581961
self.conn_def[instr_name] = {
19591962
"parameters": instr_parms,
19601963
"inst": instr_add,

0 commit comments

Comments
 (0)