Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

Notice Board

Per partecipare al corso di Fondamenti di programmazione 2023-24 loggatevi e attivatelo nella vostra pagina dei corsi preferiti. A quel punto il corso appare nel menù personale cliccando sul proprio avatar. Per i materiali degli anni precedenti seguite lo stesso metodo.

To join the Programming/Lab 2023-24 course, log-on and select it on the my courses page. It will appear on the personal menu of your avatar. For earlier years use the same method.

[HW4] controlli aggiunti sulla VM

andrea.sterbini (208020 points)
756 1270 2377
in Avvisi by (208k points)
edited by

Mi ero dimenticato di assicurarmi che i test:

  • potessero aprire solo i file giusti (così se vi sbagliate di path lo scoprite, ed inoltre non potete fare danni)
  • non potessero muoversi a giro con chdir (che se vi viene un timeout i test seguenti falliscono)

Ho quindi aggiunto questi due controlli alla VM:

  • errore se si usa os.chdir
  • errore se si apre un file sbagliato (in lettura i sorgenti, in scrittura le destinazioni)

Sto rieseguendo i test, correggete i vostri programmi se necessario

EDIT: ho fixato i path dei file e sto ri-rieseguendo i test

649 views

4 Answers

leonardo.b (2150 points)
0 0 14
by (2.2k points)
Ora non è più possibile passare dei bytes ad open è voluto questo comportamento?
andrea.sterbini (208020 points)
756 1270 2377
by (208k points)
Perchè bytes? sono file di testo
leonardo.b (2150 points)
0 0 14
by (2.2k points)
Vorrei evitare di scrivere troppi dettagli qui, potrebbe guardare la soluzione che ho caricato?

Leggere con un encoding rallenta
andrea.sterbini (208020 points)
756 1270 2377
by (208k points)

ottimizzatore estremo!
voglio vedere la volta che ti metto dei file con le faccine che ti tocca fare laugh

leonardo.b (2150 points)
0 0 14
by (2.2k points)
Grazie ahah,
Comunque quindi che faccio, passo alle stringhe per i percorsi? O attendo un fix dei test?
andrea.sterbini (208020 points)
756 1270 2377
by (208k points)
usa stringhe e file di testo
mirko1010 (5560 points)
13 33 60
by (5.6k points)
edited by
Potresti utilizzare os.open  .... se non è escluso , finora anche il piu veloce che ho visto Nell I/O ,  non passi percorsi in  bytes (vuole stringhe)  ma leggi bytes sul testo che possono essere decodificati o codificati , non si puo usare con readlines :)
mirko1010 (5560 points)
13 33 60
by (5.6k points)
Quindi ad esempio  per capire ,  si puo leggere solo il percorso corretto fornito dal source root ,  ma si puo quindi anche scrivere sui file  sempre del source root , quindi testXY/path  ad esempio  per fare traduzioni parziale su tutto il testo   ?
andrea.sterbini (208020 points)
756 1270 2377
by (208k points)
puoi aprire solo i file corretti, file estranei no
mirko1010 (5560 points)
13 33 60
by (5.6k points)
perfetto grazie
m
marco_rodi (900 points)
2 4 10
by (900 points)

Salve professore,

scrivo nuovamente perché riscontro lo stesso problema. 

PASSED test_01.py==Test==test01_example
PASSED test_01.py==Test==test06_example
PASSED test_01.py==Test==test_intricacy
PASSED test_01.py==Test==test_no_globals_or_mutable_args
PASSED test_01.py==Test==test_untampered_types
PASSED test_01.py==Test==test_zz_top_types
FAILED test_01.py==Test==test02_example - testlib.ForbiddenError= Opening fil...
FAILED test_01.py==Test==test03_example - testlib.ForbiddenError= Opening fil...
FAILED test_01.py==Test==test04_example - testlib.ForbiddenError= Opening fil...
FAILED test_01.py==Test==test05_example - testlib.ForbiddenError= Opening fil...
FAILED test_01.py==Test==test07_example - testlib.ForbiddenError= Opening fil...
FAILED test_01.py==Test==test08_example - testlib.ForbiddenError= Opening fil...
FAILED test_01.py==Test==test09_example - testlib.ForbiddenError= Opening fil...
FAILED test_01.py==Test==test10_example - testlib.ForbiddenError= Opening fil...
============ 8 failed, 6 passed, 10 deselected, 1 warning in 2.35s =============
MAX TEST TIME (174s) REACHED
andrea.sterbini (208020 points)
756 1270 2377
by (208k points)

Correggi l'uso degli slash

'test02.out/1//The fair legislature smites restroom..txt'
ci sono 2 slash invece che 1
mirko1010 (5560 points)
13 33 60
by (5.6k points)
È previsto  che non sia permesso modalità di apertura r+ ?
andrea.sterbini (208020 points)
756 1270 2377
by (208k points)
Perché r+?

.
mirko1010 (5560 points)
13 33 60
by (5.6k points)
edited by
Perché volevo leggere e scrivere nella stessa apertura ...

++: in effetti  non ce nè bisogno ho risolto in modo piu efficace