-
Notifications
You must be signed in to change notification settings - Fork 658
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
NamedStream cleanup #657
NamedStream cleanup #657
Conversation
(see discussion at #652)
a278e07
to
ec2ceac
Compare
This should fix the last problem def __radd__(self, other):
return other + self.name It overrides the radd of NamedStream, so when |
Oh wait, I've just seen you've added radd, which is weird because I got:
|
I am just doing an amend... incoming. |
…and radd This enables full string addition, both string + NamedStream and NamedStream + string. Many of the os.path functions will now work with NamedStream. (Thanks to @richardjgowers for __radd__!)
- test expanduser: works but behaves unexpectedly (but consistently) in that it returns the expanded string if a tilde was in the name but does nothing (as described in the docs) when it does not do a substitution, which means that it now returns the original NamedString. Kind of messy but probably tolerable. - test expandvars: does not work - note: some of the tests related to expandvars and expandusers generated Segmentation fault on my Mac OS X 10.6 with Python 2.7.11 and I disabled the tests.
ec2ceac
to
92464cd
Compare
Most of the
Unfortunately, my tests segmentation faulted for expandvars and non-expanding expanduser so I skip them at the moment... |
Another py3 enemy bites the dust, awesome |
As discussed in #649 and PR #652,
NamedStream
is a bit of a hack... not necessarily in the best sense of the word. This PR builds on #652 (towards Py3 compatibility) and tries to makeNamedStream
work as seamlessly as advertised or at least document its failures.I added tests that explore the limitations of using a
NamedStream
instance as a filename under the new scheme where the class is not derived from eitherbasestring
orstr
. I apply most of the filename-related tests inos.path
.The tests partially fail on those that have to do a string concatenation with
NamedString
as the argument, i.e.which is
That seems to be a problem that can only be resolved by properly inheriting from something that
str.__add__
is willing to consume.UPDATE: Below @richardjgowers rightly points out that
NamedStream.__radd__
will solve the problem.