Skip to content

Commit 4389d66

Browse files
authored
Merge pull request #188 from nohtyprm/py311unfix
python 3.11+ (un)fix -- temporarily on master branch
2 parents 382067b + 06d84c2 commit 4389d66

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

mrpython/Application.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self):
2727

2828
language = None
2929
try: # Work around a possible Python3.7 bug on MacOS
30-
loc = locale.getdefaultlocale()
30+
loc = locale.getlocale()
3131
if loc:
3232
for el in loc:
3333
if str(el).upper().startswith("FR"):
@@ -60,6 +60,18 @@ def __init__(self):
6060
self.expert_mode_warning_shown = False
6161

6262
def run(self, filename=None):
63+
64+
import sys
65+
if sys.version_info.major == 3 and sys.version_info.minor >= 11:
66+
# XXX: temporary message for incomplete support of python >= 3.11
67+
68+
confirm = messagebox.askquestion(tr('Python 3.11+ warning'), tr("MrPython is not yet fully supported by Python 3.11+\n A version between Python 3.8.x and Python 3.10.y is recommended\n Are you sure to run in degraded mode?\n Some condition checking will be turned off!"))
69+
70+
if confirm != "yes":
71+
print(tr("==> use a python 3.8 >= 3.11 interpreter instead"))
72+
print(tr("bye bye !"))
73+
sys.exit(1)
74+
6375
""" Run the application """
6476
if filename:
6577
import sys
@@ -175,7 +187,7 @@ def change_mode(self, event=None):
175187
""" Swap the python mode : full python or student """
176188
if self.mode == "student":
177189
if not self.expert_mode_warning_shown:
178-
confirm = messagebox.askquestion(tr('Switch to export mode?'), tr("Are you sure to switch to 'expert' mode ?\n All code verifications will be turned off!"))
190+
confirm = messagebox.askquestion(tr('Switch to expert mode?'), tr("Are you sure to switch to 'expert' mode ?\n All code verifications will be turned off!"))
179191
if confirm == 'yes':
180192
self.mode = "full"
181193
self.expert_mode_warning_shown = True

mrpython/StudentRunner.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,13 @@ def check_types(self):
303303
return not fatal_error
304304

305305
def add_FunctionPreconditions(self):
306-
self.AST = FunctionDefVisitor().visit(self.AST)
307-
ast.fix_missing_locations(self.AST)
306+
# TODO : because of changes in python 3.11+ dynamic compilation
307+
# we cannot add precondition checking code in this
308+
# way (hiding line numbers)
309+
# a new scheme will be introduced
310+
if sys.version_info.minor < 11:
311+
self.AST = FunctionDefVisitor().visit(self.AST)
312+
self.AST = ast.fix_missing_locations(self.AST)
308313

309314
class FunCallsVisitor(ast.NodeVisitor):
310315
def __init__(self):

mrpython/translate.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@ def set_translator_locale(locale_key):
5353
, "Conventions:\n" : {'fr' : "Conventions :\n"}
5454
, "Execution Errors:\n" : {'fr' : "Erreurs d'exécution :\n"}
5555
, "<<<Output>>>\n" : {'fr' : "<<<Sorties>>>\n"}
56-
, 'Switch to export mode?' : {'fr' : "Passer en mode expert ?"}
56+
, 'Switch to expert mode?' : {'fr' : "Passer en mode expert ?"}
5757
, "Are you sure to switch to 'expert' mode ?\n All code verifications will be turned off!"
5858
: {'fr' : "Êtes-vous sûr de passer en mode 'expert' ?\nToutes les vérifications seront désactivées !"}
5959

60-
60+
, 'Python 3.11+ warning' : { 'fr' : "Avertissement Python 3.11+"}
61+
, "MrPython is not yet fully supported by Python 3.11+\n A version between Python 3.8.x and Python 3.10.y is recommended\n Are you sure to run in degraded mode?\n Some condition checking will be turned off!" : { 'fr' : "MrPython n'est pas encore 100% compatible avec Python 3.11+\n Les version 3.8.x à 3.10.y sont recommandées\nCertaines vérifications de code seront désactivées !\nÊtes-vous surs de vouloir lancer le mode dégradé ?" }
62+
, "==> use a python 3.8 >= 3.11 interpreter instead" : { 'fr' : "==> utilisez une version de python entre 3.8 et 3.11" }
6163
}
6264

6365
def tr(msg):

0 commit comments

Comments
 (0)