|
34 | 34 |
|
35 | 35 | tipwindow = None |
36 | 36 |
|
| 37 | +# starting Python-3.13, PEP 667 forces us to us a specific dictionnary pydef_locals instead of locals() |
| 38 | +pydef_locals ={} |
37 | 39 |
|
38 | 40 | class App: |
39 | 41 | """the GUI graphic application""" |
40 | 42 |
|
41 | 43 | def __init__(self, use_gui=True): |
42 | 44 | """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 !'" |
45 | 47 | self.conn = None # Baresql database object |
46 | 48 | self.database_file = "" |
47 | 49 | self.initialdir = "." |
@@ -1942,19 +1944,20 @@ def createpydef(self, sql): |
1942 | 1944 |
|
1943 | 1945 | instruction = sql.strip("; \t\n\r") |
1944 | 1946 | # create Python function in Python |
1945 | | - exec(instruction[2:], globals(), locals()) |
| 1947 | + exec(instruction[2:], globals(), pydef_locals) |
1946 | 1948 | # add Python function in SQLite |
1947 | 1949 | instr_header = re.findall(r"\w+", instruction[: (instruction + ")").find(")")]) |
1948 | 1950 | instr_name = instr_header[1] |
1949 | 1951 | 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) |
1950 | 1954 | instr_add = "self.conn.create_function('%s', %s, %s)" % ( |
1951 | 1955 | instr_name, |
1952 | 1956 | instr_parms, |
1953 | 1957 | instr_name, |
1954 | 1958 | ) |
1955 | | - exec(instr_add, globals(), locals()) |
1956 | 1959 | # housekeeping definition of pydef in a dictionnary |
1957 | | - the_help = dict(globals(), **locals())[instr_name].__doc__ |
| 1960 | + the_help = pydef_locals[instr_name].__doc__ |
1958 | 1961 | self.conn_def[instr_name] = { |
1959 | 1962 | "parameters": instr_parms, |
1960 | 1963 | "inst": instr_add, |
|
0 commit comments