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

backslash in side brackets of format string causes an issue. #3

Open
JervenBolleman opened this issue Feb 2, 2024 · 3 comments
Open

Comments

@JervenBolleman
Copy link

On line 237 of serializer.py there is a blackslash inside the {} which is a problem on my python3.11.6 as shipped with Ubuntu 23.10.

Traceback (most recent call last):
  File "/home/jbollema/git/sparql-examples/formatQuery.py", line 2, in <module>
    from sparql.parser import sparql_parser
  File "/home/jbollema/git/sparql-examples/venv/lib/python3.11/site-packages/sparql/__init__.py", line 5, in <module>
    from sparql.serializer import SparqlSerializer
  File "/home/jbollema/git/sparql-examples/venv/lib/python3.11/site-packages/sparql/serializer.py", line 237
    self._result += f"\n{'\t' * self._indent}}}"
                                             ^
@edmondchuc
Copy link
Contributor

Hi @JervenBolleman, thanks for your issue.

Do you mind providing an example query containing a backslash that is causing the issue?

I tried with the following query and it worked fine for me. It contains a backslash inside the curly braces of the QuadsNotTriples production.

WITH <g>
INSERT {
    GRAPH <g> {
        <s> <p> "f\" .
    }
}
WHERE {}

The output is not perfect with the indentations, but I get without any errors:

WITH <g> INSERT {
GRAPH <g> {
		<s> <p> "f\" . 
	}
}WHERE {

}

@edmondchuc
Copy link
Contributor

Hi @JervenBolleman, I just tested and it looks like there's an issue in Python 3.11. Using this package on Python 3.12 works fine.

We don't have any immediate plans to allow for support with 3.11. If you can pinpoint what the exact issue is, we'll be happy to fix it.

@JervenBolleman
Copy link
Author

Hi @edmondchuc the logic in line 237 of serializer.py

elif child.value == "}":
     self._result += f"\n{'\t' * self._indent}}}"

should maybe be something like

elif child.value == "}":
     tabs= '\t' * self._indent
     self._result += "\n"
     self._result += tabs

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

No branches or pull requests

2 participants