Bug 452702

Summary: Curly brackets disappear on python import
Product: [Applications] umbrello Reporter: rolf Schmidt <rattenkopf2>
Component: importerAssignee: Umbrello Development Group <umbrello-devel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 2.33.2 (KDE releases 20.12.2)   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 2.34.70 (KDE releases 22.07.70)
Sentry Crash Report:

Description rolf Schmidt 2022-04-17 15:32:53 UTC
SUMMARY
***
If python code is imported all curly brackets disappear in the attribute text.
***

STEPS TO REPRODUCE
1. 
# python code
#!/usr/bin/python3

class test(object):
   def abc():
     xyz={'aaa':1, 'bbb':'John'}
2. 
import sourcecode
3. 
OBSERVED RESULT
xyz=:
  'aaa':1,'bbb':'John'

EXPECTED RESULT
xyz={ 'aaa':1,'bbb':'John'}

SOFTWARE/OS VERSIONS
Devuan Chimera (i.e. debian bullseys)
GUI: Trinity
Comment 1 Oliver Kellogg 2022-04-17 22:18:48 UTC
Git commit 129462a49a0943ec6925f35d93ec55a80114b159 by Oliver Kellogg.
Committed on 17/04/2022 at 22:18.
Pushed by okellogg into branch 'master'.

Fix "Curly brackets disappear on python import"

umbrello/codeimport/pythonimport.cpp function skipBody
- Add bool dictInitializer initialized to false.
- In while-loop :
  - If token is "}" then
    - if dictInitializer is true then append '}' to body and set
      dictInitializer false;
    - move braceNesting related code to else-part of this if-statement.
  - If token is "{" then
    - if previous token is "=" then append '{' to body and set
      dictInitializer true;
    - move braceNesting related code to else-part of this if-statement.
FIXED-IN: 2.34.70 (KDE releases 22.07.70)

M  +17   -5    umbrello/codeimport/pythonimport.cpp

https://invent.kde.org/sdk/umbrello/commit/129462a49a0943ec6925f35d93ec55a80114b159