1. python_mirrors
  2. features/pep-3151

Commits

Victor Stinner  committed eb2821c

Fix my_basename(): make the string ready

  • Participants
  • Parent commits 7defc1e
  • Branches default

Comments (0)

Files changed (1)

File Objects/exceptions.c

View file
  • Ignore whitespace
 my_basename(PyObject *name)
 {
     Py_ssize_t i, size, offset;
-    int kind = PyUnicode_KIND(name);
-    void *data = PyUnicode_DATA(name);
+    int kind;
+    void *data;
+
+    if (PyUnicode_READY(name))
+        return NULL;
+    kind = PyUnicode_KIND(name);
+    data = PyUnicode_DATA(name);
     size = PyUnicode_GET_LENGTH(name);
     offset = 0;
     for(i=0; i < size; i++) {