Commit c8a8b28d authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge commit '7e5867' into refcounting

parents 3ba67db1 7e586778
......@@ -222,8 +222,15 @@ SearchResult findModule(const std::string& name, BoxedString* full_name, BoxedLi
llvm::SmallString<128> joined_path;
for (int i = 0; i < path_list->size; i++) {
Box* _p = path_list->elts->elts[i];
if (_p->cls != str_cls)
if (isSubclass(_p->cls, unicode_cls)) {
_p = PyUnicode_AsEncodedString(_p, Py_FileSystemDefaultEncoding, NULL);
if (_p == NULL) {
continue;
}
}
if (!isSubclass(_p->cls, str_cls)) {
continue;
}
BoxedString* p = static_cast<BoxedString*>(_p);
joined_path.clear();
......@@ -697,7 +704,7 @@ static int isdir(const char* path) {
Box* nullImporterInit(Box* self, Box* _path) {
RELEASE_ASSERT(self->cls == null_importer_cls, "");
if (_path->cls != str_cls)
if (!isSubclass(_path->cls, str_cls))
raiseExcHelper(TypeError, "must be string, not %s", getTypeName(_path));
BoxedString* path = (BoxedString*)_path;
......
......@@ -4152,6 +4152,7 @@ void setupRuntime() {
slice_cls->giveAttr("step", new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedSlice, step)));
slice_cls->freeze();
slice_cls->tp_compare = (cmpfunc)slice_compare;
slice_cls->tp_flags &= ~Py_TPFLAGS_BASETYPE;
static PyMappingMethods attrwrapper_as_mapping;
attrwrapper_cls->tp_as_mapping = &attrwrapper_as_mapping;
......
# should_error
class foo(slice):
pass
import sys
sys.path.append("test_package")
import import_target
import sys
class TestClass(str):
pass
t = TestClass("test_package")
sys.path.append(t)
import import_target
import sys
sys.path.append(u"test_package")
import import_target
import sys
class TestClass(unicode):
pass
t = TestClass("test_package")
sys.path.append(t)
import import_target
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment