Skip to content

Commit b376a2a

Browse files
author
Charles PIGNEROL
committed
Version 6.4.6. If the last instruction to be executed and executed is in a loop we point to the start of the loop (just after the test of the condition). Therefor any subsequent execution will start with this line - which is wrong - which is also indented => python indentation error.
1 parent 370a5c3 commit b376a2a

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

cmake/version.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
# Pour la bibliothèque QtPython :
66
set (QT_PYTHON_MAJOR_VERSION "6")
77
set (QT_PYTHON_MINOR_VERSION "4")
8-
set (QT_PYTHON_RELEASE_VERSION "5")
8+
set (QT_PYTHON_RELEASE_VERSION "6")
99
set (QT_PYTHON_VERSION ${QT_PYTHON_MAJOR_VERSION}.${QT_PYTHON_MINOR_VERSION}.${QT_PYTHON_RELEASE_VERSION})
1010

1111
# Pour la bibliothèque QtPython3 :
1212
set (QT_PYTHON_3_MAJOR_VERSION "6")
1313
set (QT_PYTHON_3_MINOR_VERSION "4")
14-
set (QT_PYTHON_3_RELEASE_VERSION "5")
14+
set (QT_PYTHON_3_RELEASE_VERSION "6")
1515
set (QT_PYTHON_3_VERSION ${QT_PYTHON_3_MAJOR_VERSION}.${QT_PYTHON_3_MINOR_VERSION}.${QT_PYTHON_3_RELEASE_VERSION})
1616

src/QtPython3/QtPythonConsole.cpp

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ void QtPythonConsole::drawLinesNumbers (const QRect& rect)
943943
if ((true == block.isVisible ( )) && (bottom >= rect.top ( )))
944944
{
945945
// Rem : sous Qt 4.7.4 la surimpression (breakpoint, et par dessus ligne actuelle) ne fonctionne pas ... (pixmap ? autre ?)
946-
// => on n'affiche pas le BP si ligne courrante.
946+
// => on n'affiche pas le BP si ligne courante.
947947
if ((_breakpoints.end ( ) != _breakpoints.find (number)) && (currentInstruction ( ) != number))
948948
{
949949
_breakPointIcon.paint (&painter, 3, top, width, height);
@@ -1232,6 +1232,7 @@ void QtPythonConsole::validateCursorPosition ( )
12321232
// Attention : si on est en fin de document le numéro de ligne n'existe pas forcément.
12331233
QTextBlock block;
12341234
QTextCursor cursor = textCursor ( );
1235+
12351236
if (_currentExecLine > document ( )->blockCount ( ))
12361237
{ // 2 possibilités : la dernière ligne est blanche et convient, sinon on en rajoute une.
12371238
block = document ( )->findBlockByNumber (_currentExecLine - 2);
@@ -1516,9 +1517,9 @@ string QtPythonConsole::getPythonScript ( ) const
15161517

15171518

15181519
void QtPythonConsole::lineProcessedCallback (const string& fileName, size_t line, bool ok, const string& error)
1519-
{ // 0 == _currentScript.get ( ) : exécution d'une commande, à la ligne courrante
1520+
{ // 0 == _currentScript.get ( ) : exécution d'une commande, à la ligne courante
15201521
const size_t consoleLine = (0 == _currentScript.get ( )) ? (_currentExecLine <= 1 ? 1 : _currentExecLine) : _currentScript->getConsoleLineNum (line); // CP v 5.0.5
1521-
1522+
15221523
try
15231524
{
15241525
if (true == ok) // ATTENTION : Retour éventuel en ligne de début de boucle pour évaluation de la condition d'arrêt => _currentExecLine se minorée et donc erronnée si fin de boucle atteinte
@@ -2425,7 +2426,7 @@ void QtPythonConsole::execInstructions ( )
24252426
_halted = true;
24262427
updateActions ( );
24272428

2428-
// On mémorise le point courrant, pour actualisation finale IHM en une passe
2429+
// On mémorise le point courant, pour actualisation finale IHM en une passe
24292430
const size_t startAt = _currentExecLine;
24302431

24312432
vector<string> instructions = getRunnableInstructions (_currentExecLine);
@@ -2440,6 +2441,7 @@ void QtPythonConsole::execInstructions ( )
24402441
flags.cf_flags = 0;
24412442
PyErr_Clear ( );
24422443
registerConsole (*this);
2444+
24432445
if (1 == instructions.size ( ))
24442446
{ // CP on pourrait évaluer la qualité de l'instruction (générée en python) à l'aide par exemple de
24452447
// Py_CompileString (cf.QPyConsole::interpretCommand). En cas d'absence d'instruction (commentaire, ligne finissant
@@ -2470,6 +2472,31 @@ void QtPythonConsole::execInstructions ( )
24702472
{
24712473
}
24722474
} // else if (1 == instructions.size ( ))
2475+
2476+
// v 6.4.6 : si la dernière instruction à exécuter et exécutée est dans une boucle on pointe au début la boucle (juste après le test sur la condition)
2477+
// => toute exécution ultérieure débutera par cette ligne - ce qui est faux - qui est de surcroit indentée => erreur d'indentation python.
2478+
// On rectifie cette erreur de pointage :
2479+
if (_currentExecLine <= _maxExecLine)
2480+
{ // v 6.4.6
2481+
try
2482+
{ // Par acquis de conscience ont vérifie que la ligne est effectivement indentée :
2483+
const string currentLine = _currentScript->getConsoleLine (_currentExecLine);
2484+
if ((currentLine [0] != ' ') && (currentLine [0] != '\t'))
2485+
{
2486+
UTF8String mess (charset);
2487+
mess << "Erreur possible dans QtPythonConsole::execInstructions : la ligne pointée est supposée indentée (dans une boucle) mais elle ne l'est pas :\n"
2488+
<< "Ligne visée (" << _currentExecLine << ") : " << currentLine;
2489+
ConsoleOutput::cerr ( ) << mess << co_endl;
2490+
} // if ((currentLine [0] != '1') && (currentLine [0] != '\t'))
2491+
}
2492+
catch (...)
2493+
{
2494+
}
2495+
2496+
_currentExecLine = _maxExecLine + 1;
2497+
_previousExecLine = _maxExecLine;
2498+
} // if (_currentExecLine <= _maxExecLine)
2499+
24732500
unregisterConsole (*this);
24742501

24752502
if (NULL != result)

versions.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Version 6.4.6 : 29/11/24
2+
===============
3+
4+
Correctif de bogue : si la derni�re instruction � ex�cuter et ex�cut�e est dans une boucle on pointe au d�but la boucle (juste apr�s le test sur la condition)
5+
=> toute ex�cution ult�rieure d�butera par cette ligne - ce qui est faux - qui est de surcroit indent�e => erreur d'indentation python.
6+
7+
18
Version 6.4.5 : 26/11/24
29
===============
310

0 commit comments

Comments
 (0)