cs50 / check50

This is check50, a command-line program with which you can check the correctness of your programs.
GNU General Public License v3.0
399 stars 267 forks source link

CS50P: Shirtificate fails working code if student uses hex colors #341

Open Makaze opened 3 months ago

Makaze commented 3 months ago

If a student submits a working code that uses hex color codes, e.g.

pdf.set_text_color("#FFF")

check50 will fail it, claiming the output file was not created. The source of this error is not easily traced. It seems to be internal to check50 and cannot be pinned to the contents of the problem files here.

Makaze commented 3 months ago

The documentation regarding the hex support was added last month. The fpdf2 version installed by check50 is out of date. If I manually install the same version as check50, fpdf2==2.7.6, I get this error:

Traceback (most recent call last):
  File "/home/makaze/Documents/Harvard/CS50P/shirtificate/shirtificate.py", line 37, in <module>
    pdf.output("shirtificate.pdf")
  File "/home/makaze/.local/lib/python3.10/site-packages/fpdf/fpdf.py", line 4916, in output
    self.footer()
  File "/home/makaze/Documents/Harvard/CS50P/shirtificate/shirtificate.py", line 27, in footer
    self.set_text_color("#FFF")
  File "/home/makaze/.local/lib/python3.10/site-packages/fpdf/fpdf.py", line 1037, in set_text_color
    self.text_color = _convert_to_drawing_color(r, g, b)
  File "/home/makaze/.local/lib/python3.10/site-packages/fpdf/fpdf.py", line 4943, in _convert_to_drawing_color
    r, g, b = r
ValueError: too many values to unpack (expected 3)

Solution: Update fpdf2 on the check50 server.