Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

Contest: write bad code, win a prize #141

Closed
aroberge opened this issue Jan 16, 2021 · 4 comments
Closed

Contest: write bad code, win a prize #141

aroberge opened this issue Jan 16, 2021 · 4 comments

Comments

@aroberge
Copy link
Owner

aroberge commented Jan 16, 2021

Edit: The contest is now over. The winner is @Dominik1123.

Summary

Write code with ONE error that Friendly-traceback cannot properly analyze, in one of three categories:

  • SyntaxError: invalid syntax
  • SyntaxError: some message, where some message is not recognized.
  • Any case of NameError, AttributeError, ModuleNotFoundError, UnboundLocalError, ImportError, IndexError, KeyError that is not recognized or is given an incorrect explanation by Friendly-traceback.

Submitted issues about bugs for Friendly-traceback itself are also considered for this contest.

The prize

There will be one prize given drawn randomly from all eligible submissions. The prize consists of one ebook/pbook of your choice with a maximum value of 50 USD (including delivery for pbook) as long as I can order it and have it delivered to you. Alternatively, a donation for that amount to the open source project of your choice if it can be made using Paypal.

The details

Each valid issue will get one entry for the contest. Valid issues contain code that might be expected to be written by a beginner or advanced beginner. It excludes code that uses type annotations as well as the use of async and await keywords.
The code is expected to contain ONE mistake only and not generate secondary exceptions.

The code can be run either using the friendly-console, or running in a Jupyter environment or from an editor as described in the documentation.

The code should not be run from exec() or eval(), etc.

For a given valid submission, a bonus entry will be given if a link can be provided to an actual example from a site (such as StackOverflow, /r/python or /r/learnpython, etc.) where a question had been asked prior to this contest.

Exceptions that are not recognized by Friendly-traceback or for which the explanation (in English or French) is wrong or misleading are considered to be valid issues. Friendly-traceback does not second-guess Python's messages: they are taken at face value even if they sometimes might initially lead to a wrong conclusion. However, in some cases, such as issue #144, it is possible to obtain more information "afer the fact" than that provided by Python, which is why this particular example is considered to be a valid entry for this contest.

Submissions that are considered to be duplicate of previously submitted cases (because they basically have the same cause) will not be considered.

Honor code

I would ask that you do not read the source of Friendly-traceback with the sole intent of finding ways to write code that is designed to lead it to provide incorrect explanation.

End of contest

The contest will end on Monday January 25, at 8 AM Atlantic Standard Time.

@tomerv
Copy link

tomerv commented Jan 22, 2021

Edit: I now noticed that ZeroDivisionError is not in the scope.

┌───────────────────────────────────────────────── Python exception ──────────────────────────────────────────────────┐
│ Traceback (most recent call last):                                                                                  │
│   File "test.py", line 1, in <module>                                                                               │
│     0**-1                                                                                                           │
│ ZeroDivisionError: 0.0 cannot be raised to a negative power                                                         │
│                                                                                                                     │
│ A ZeroDivisionError occurs when you are attempting to divide a value by zero: result = my_variable / 0. It can also │
│ happen if you calculate the remainder of a division using the modulo operator %: result = my_variable % 0           │
│                                                                                                                     │
│ Exception raised on line 1 of file 'test.py'.                                                                       │
│                                                                                                                     │
│     -->1: 0**-1                                                                                                     │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Actual example: https://stackoverflow.com/questions/10198753/zero-division-error-in-python-uncertainties-package

I did not check whether this issue was previously reported.

@aroberge
Copy link
Owner Author

I did not include ZeroDivisionError as I thought I had covered all cases, and never thought that someone would find another case. So, I consider this a valid entry, worth 2 points given the reference to StackOverflow.

@aroberge
Copy link
Owner Author

@tomerv I summarize all cases in #145. I don't know if you got an email or not given that I referenced your username when I edited #145.

@tomerv
Copy link

tomerv commented Jan 22, 2021

Kudos for already handling A from __future__ import statement changes the way Python interprets the code in a file. It must appear at the beginning of the file! I was expecting it to be missed, since it's a rare case of a SyntaxError after the parsing stage.

@aroberge aroberge pinned this issue Jan 22, 2021
aroberge added a commit that referenced this issue Jan 26, 2021
aroberge added a commit that referenced this issue Jan 26, 2021
@aroberge aroberge closed this as completed Feb 6, 2021
@aroberge aroberge unpinned this issue Feb 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants