Skip to content

Parser fails when dice_notation.parser.common_DiceParser_parsetab cannot be created. #17

@Aarowaim

Description

@Aarowaim

This statement can fail when scripts do not have administrative rights to create files in the python script folder.

yacc.yacc(module=self,
debug=self.debug,
debugfile=self.debugfile,
tabmodule=self.tabmodule)

When it fails, the library emits this warning:

WARNING: Couldn't create 'dice_notation.parser.common_DiceParser_parsetab'. [Errno 13] Permission denied: 'C:\\Program Files (x86)\\Python37-32\\lib\\site-packages\\dice_notation\\parser\\common_DiceParser_parsetab.py'

The program continues running, but DiceParser().parse('d4 + 4').roll() always returns 8, which happens to be the highest value possible. The following is printed, but not raised:

Syntax error at 'd'
Illegal character ' '
Illegal character ' '

Perhaps a fail-fast approach would better suit this situation? After failing to write the parsetab, .roll() is invalidated so exceptions probably should be raised.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions