Closed trim21 closed 1 year ago
can you make a rnew release?
Will try to tomorrow.
Now published.
I had to remove repr formatting for path as it resulted in Windows paths being normalised, e.g. C:\first\next\hosts being returned as C:\first\next\hosts, that returns an error if you attempt to use the repr output.
Now published. I had to remove repr formatting for path as it resulted in Windows paths being normalised, e.g. C:\first\next\hosts being returned as C:\first\next\hosts, that returns an error if you attempt to use the repr output.
What's the difference between two path in your example...
Didn't get your point, it looks fine for string repr with backward slash
Seems GitHub has removed the double backslashes, just like the repr format did.
Now I'm more confused, looks like my pr doesn't change repr with any path?
On Windows only.
Your PR is merged. I simply had to remove repr formatting for path.
Didn't get your point, it looks fine for string repr with backward slash
Sorry, I didn't see the image as it doesn't show on the GitHub app on iOS.
When Hosts had a path that didn't use string literals, and so included double backslashes, the repr (in the formatting) would show with single backslashes. As the repr needs to be something you can execute to reproduce the object, having single backslashes means it couldn't be evaluated. I thought about having the repr return Host(path=r'{0!r}'...
but it looked messy in contrast. I also looked at Path but that isn't in 2.7 and I'm trying to retain that compatibilty.
Sorry, I didn't see the image as it doesn't show on the GitHub app on iOS.
When Hosts had a path that didn't use string literals, and so included double backslashes, the repr (in the formatting) would show with single backslashes. As the repr needs to be something you can execute to reproduce the object, having single backslashes means it couldn't be evaluated. I thought about having the repr return
Host(path=r'{0!r}'...
but it looked messy in contrast. I also looked at Path but that isn't in 2.7 and I'm trying to retain that compatibilty.
Current repr of path in Hosts
is still not valid...
from python_hosts import Hosts
print(repr(Hosts()))
Hosts(path='c:\windows\system32\drivers\etc\hosts', entries=[...])
it's expected to be Hosts(path='c:\\windows\\system32\\drivers\\etc\\hosts', entries=[...]
, repr of single backslash should be double backslashes, otherwise it should have a r
prefix.
So current manually quoted is not valid, it should be return 'Hosts(path={0!r}, entries={1!r})'.format(self.path, self.entries)
Thanks @trim21. Will fix up the broken tests and check asap.