Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Makaze opened this issue Jul 17, 2024 · 1 comment
Open

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

Makaze opened this issue Jul 17, 2024 · 1 comment
Assignees

Comments

@Makaze
Copy link

Makaze commented Jul 17, 2024

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
Copy link
Author

Makaze commented Jul 17, 2024

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.

@rongxin-liu rongxin-liu transferred this issue from cs50/problems Jul 17, 2024
@rongxin-liu rongxin-liu self-assigned this Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants