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

Fix n3 parser exponent syntax of floats with leading dot. #1012

Merged
merged 8 commits into from Apr 17, 2020

Conversation

white-gecko
Copy link
Member

Fix #999 .

@white-gecko white-gecko added this to the rdflib 5.0.0 milestone Apr 17, 2020
@coveralls
Copy link

coveralls commented Apr 17, 2020

Coverage Status

Coverage remained the same at 75.949% when pulling 5b1a9d0 on white-gecko:feature/fixN3Exponent into 39d07c4 on RDFLib:master.

@effigies
Copy link
Contributor

Hopefully I'm not being annoying, but as I was looking at this I wanted to add some tests that should have caught this problem earlier. Made a proposal at white-gecko#1.

@white-gecko
Copy link
Member Author

@effigies everything fine. We are happy about all good contributions.

Copy link
Contributor

@effigies effigies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, assumed Python 2.7 and Python 3 would have done something sensible like use the same method names. Instead we got assertRegex (3) and assertRegexMatches (2.7).

These fixes should work across versions.

test/test_n3.py Outdated
exps = ("1", "12", "+1", "-1", "+12", "-12")
for parts in itertools.product(signs, mantissas, es, exps):
expstring = "".join(parts)
self.assertRegex(expstring, exponent_syntax)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.assertRegex(expstring, exponent_syntax)
self.assertIsNotNone(exponent_syntax.match(expstring))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used assetTrue and assertFalse which are effectively doing the same.

test/test_n3.py Outdated
# Add test cases as needed
invalid = (".e1",)
for expstring in invalid:
self.assertNotRegex(expstring, exponent_syntax)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.assertNotRegex(expstring, exponent_syntax)
self.assertIsNone(exponent_syntax(expstring))

Copy link
Member

@nicholascar nicholascar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @effigies and @white-gecko for the quick fix! (come on @edmondchuc, you found this, should have fixed it!)

@nicholascar nicholascar merged commit 60f5c7e into RDFLib:master Apr 17, 2020
@gweis
Copy link
Member

gweis commented Apr 20, 2020

@effigies nice find with the regex. Thanks.

@white-gecko white-gecko deleted the feature/fixN3Exponent branch April 20, 2020 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Turtle parser fails with leading dot in decimal value
5 participants