From 64a9eacf0317967e21134988ee7c2d33dcf3c242 Mon Sep 17 00:00:00 2001 From: baugetfa Date: Thu, 4 Dec 2025 10:30:06 +0100 Subject: [PATCH 1/2] rU to r In Python 3, universal newline handling is always on by default, so rU is no longer valid --- src/openalea/lpy/gui/simulation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openalea/lpy/gui/simulation.py b/src/openalea/lpy/gui/simulation.py index 2734535..594b52d 100644 --- a/src/openalea/lpy/gui/simulation.py +++ b/src/openalea/lpy/gui/simulation.py @@ -355,7 +355,7 @@ def open(self,fname): elif answer == QMessageBox.Discard: os.remove(bckupname) os.chdir(os.path.dirname(self.fname)) - code = open(readname,'rU').read() + code = open(readname,'r').read() self.readonly = (not os.access(fname, os.W_OK)) self.textedition = recovery self.setEdited(recovery) @@ -367,7 +367,7 @@ def importtmpfile(self,fname): self.textedition = True self.setEdited(True) try: - lpycode = open(fname,'rU').read() + lpycode = open(fname,'r').read() self.opencode(lpycode) self._tmpfname = fname except: From 0d1dbada59c38c4f82a07b0639f32d71c8ba7bb7 Mon Sep 17 00:00:00 2001 From: baugetfa Date: Thu, 4 Dec 2025 11:00:09 +0100 Subject: [PATCH 2/2] minor changes in in doc subtelities.rst --- doc/user/subtelties.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/user/subtelties.rst b/doc/user/subtelties.rst index 1f4a184..213b937 100644 --- a/doc/user/subtelties.rst +++ b/doc/user/subtelties.rst @@ -18,6 +18,7 @@ It can then be instantiated in the axiom and modified during the simulation:: Axiom: Apex(ApexParameters(age=0)) dt = 1 derivation length: 2 + production: Apex(p) : p.age += dt produce Node() Apex(p) @@ -26,12 +27,12 @@ Creating the lsystem and running it the first time will produce the expected res >>> l = Lsystem('mycode.lpy') >>> lstring = l.derive() - >>> print lstring + >>> print(lstring) Node()Node()Apex(ApexParameters(age=2)) However, a strange behavior occurs when asking for the axiom.:: - >>> print l.axiom + >>> print(l.axiom) Apex(ApexParameters(age=2)) In fact, this behavior is due to the way python manage object. By default, complex objects @@ -40,7 +41,7 @@ are not copied but simply shared between variables.:: >>> a = ApexParameters(age=0) >>> b = a >>> b.age = 2 - >>> print a.age + >>> print(a.age) 2 The variables ``b`` and ``a`` point toward the same object in memory. This one will be destroyed only when no variable