Bug 27848

Summary: Python 2.6 Fehlermeldung
Product: UCS Reporter: Stefan Gohmann <gohmann>
Component: univention-libAssignee: Florian Best <best>
Status: CLOSED FIXED QA Contact: Lukas Walter <walter>
Severity: normal    
Priority: P5 CC: klaeser, walkenhorst, walter
Version: UCS 3.0Keywords: interim-3
Target Milestone: UCS 3.0-2   
Hardware: Other   
OS: Linux   
What kind of report is it?: --- What type of bug is this?: ---
Who will be affected by this bug?: --- How will those affected feel about the bug?: ---
User Pain: Enterprise Customer affected?:
School Customer affected?: ISV affected?:
Waiting Support: Flags outvoted (downgraded) after PO Review:
Ticket number: Bug group (optional):
Max CVSS v3 score:

Description Stefan Gohmann univentionstaff 2012-07-06 15:47:31 CEST
Trigger für python-support werden verarbeitet ...
Compiling /usr/lib/pymodules/python2.4/univention/lib/share_restrictions.py ...
  File "/usr/lib/pymodules/python2.4/univention/lib/share_restrictions.py", line 187
    with file("/etc/cups/printers.conf") as fd:
            ^
SyntaxError: invalid syntax

/usr/lib/pymodules/python2.5/univention/lib/share_restrictions.py:187: Warning: 'with' will become a reserved keyword in Python 2.6
Compiling /usr/lib/pymodules/python2.5/univention/lib/share_restrictions.py ...
  File "/usr/lib/pymodules/python2.5/univention/lib/share_restrictions.py", line 187
    with file("/etc/cups/printers.conf") as fd:
            ^
SyntaxError: invalid syntax


Der Python2.6 spezifische Code sollte entfernt werden.
Comment 1 Alexander Kläser univentionstaff 2012-07-06 16:15:45 CEST
Das betrifft nur einzelne Pakete (univention-lib, python-univention), die ggf. schon vorab über das preup-Skript bei einem Update installiert werden.
Comment 2 Janek Walkenhorst univentionstaff 2012-07-09 12:55:28 CEST
Auch im UDM durch errata48:

/usr/lib/pymodules/python2.5/univention/admin/uldap.py:257: Warning: 'as' will become a reserved keyword in Python 2.6
Compiling /usr/lib/pymodules/python2.5/univention/admin/uldap.py ...
  File "/usr/lib/pymodules/python2.5/univention/admin/uldap.py", line 257
    except TypeError as e:
                      ^
SyntaxError: invalid syntax
Comment 3 Alexander Kläser univentionstaff 2012-07-09 15:24:50 CEST
(In reply to comment #2)
> Auch im UDM durch errata48:
> 
> /usr/lib/pymodules/python2.5/univention/admin/uldap.py:257: Warning: 'as' will
> become a reserved keyword in Python 2.6
> Compiling /usr/lib/pymodules/python2.5/univention/admin/uldap.py ...
>   File "/usr/lib/pymodules/python2.5/univention/admin/uldap.py", line 257
>     except TypeError as e:
>                       ^
> SyntaxError: invalid syntax
Comment 4 Alexander Kläser univentionstaff 2012-07-11 12:03:37 CEST
(In reply to comment #2)
> Auch im UDM durch errata48:
> 
> /usr/lib/pymodules/python2.5/univention/admin/uldap.py:257: Warning: 'as' will
> become a reserved keyword in Python 2.6
> Compiling /usr/lib/pymodules/python2.5/univention/admin/uldap.py ...
>   File "/usr/lib/pymodules/python2.5/univention/admin/uldap.py", line 257
>     except TypeError as e:
>                       ^
> SyntaxError: invalid syntax

→ Das wurde bereits in revision 33575 angepasst.
Comment 5 Florian Best univentionstaff 2012-07-11 15:11:29 CEST
Der python2.6 spezifische code wurde durch 2.4 validen code ersetzt.

Macht es in diesem Fall nicht Sinn, dieses script aus dem univention-lib Ordner rauszuwerfen und in univention-samba einzufügen?
Momentan wird das Script nur in univention-lib reinkopiert ist aber kein Bestandteil von univention-lib.

 univention-samba (6.0.41-2) unstable; urgency=low
 .
   * backport to python2.4 valid code in share_restrictions.py (Bug #27848)
Comment 6 Alexander Kläser univentionstaff 2012-07-12 14:42:54 CEST
Bitte noch einmal überprüfen:

try:
    fd = file(...)
    ...
finally:
    fd.close()

Wenn während open() schon eine Excpetion auftritt, kann close() nicht aufgerufen werden, daher ist es besser folgendes zu verwenden:

fd = file(...)
try:
    ...
finally:
    fd.close()

Damit wird die Datei geschlossen, wenn Exception in dem Try-Block auftreten.
Comment 7 Florian Best univentionstaff 2012-07-12 14:51:28 CEST
Änderungen gemacht.
univention-samba (6.0.44-1) unstable; urgency=low
  * try/finally fixes (Bug #27848)
Comment 8 Lukas Walter univentionstaff 2012-07-13 11:08:36 CEST
Code sieht jetzt gut aus.

Changelog passt,
Verified.
Comment 9 Stefan Gohmann univentionstaff 2012-07-20 15:24:13 CEST
UCS 3.0-2 has been released: 
  http://forum.univention.de/viewtopic.php?f=54&t=1905

If this error occurs again, please use "Clone This Bug".