summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorAlexander Taylor <alex@vector35.com>2025-11-11 12:34:00 -0500
committerAlexander Taylor <alex@vector35.com>2026-01-20 09:44:17 -0500
commitca894f202609c8d27ba14ea1f200523e1ba7ba74 (patch)
treeb74d56327c4d23b94f66d19bbba818675a5758b2 /python
parente7bbb5129fd032310b2e2f710ce83945c03f5b13 (diff)
Other changes related to handling null strings.
This fixes the incorrect type hint and the other instance of the function. It also looks like type parsing could have the same issue, so I've updated that as well.
Diffstat (limited to 'python')
-rw-r--r--python/compatibility.py2
-rw-r--r--python/generator.cpp2
-rw-r--r--python/typeparser.py2
3 files changed, 3 insertions, 3 deletions
diff --git a/python/compatibility.py b/python/compatibility.py
index 95afcbad..76a62d3f 100644
--- a/python/compatibility.py
+++ b/python/compatibility.py
@@ -22,7 +22,7 @@ import sys
def pyNativeStr(arg):
- if isinstance(arg, str):
+ if arg is None or isinstance(arg, str):
return arg
else:
try:
diff --git a/python/generator.cpp b/python/generator.cpp
index a3d252c3..82eed91b 100644
--- a/python/generator.cpp
+++ b/python/generator.cpp
@@ -313,7 +313,7 @@ int main(int argc, char* argv[])
fprintf(out, " return var\n");
fprintf(out, " return var.encode(\"utf-8\")\n\n\n");
- fprintf(out, "def pyNativeStr(arg: AnyStr) -> str:\n");
+ fprintf(out, "def pyNativeStr(arg: Optional[AnyStr]) -> Optional[str]:\n");
fprintf(out, " if arg is None or isinstance(arg, str):\n");
fprintf(out, " return arg\n");
fprintf(out, " else:\n");
diff --git a/python/typeparser.py b/python/typeparser.py
index 0d811b50..ab068d78 100644
--- a/python/typeparser.py
+++ b/python/typeparser.py
@@ -341,7 +341,7 @@ class TypeParser(metaclass=_TypeParserMetaclass):
for i in range(includeDirCount):
include_dirs_py.append(core.pyNativeStr(includeDirs[i]))
- auto_type_source = core.pyNativeStr(autoTypeSource)
+ auto_type_source = core.pyNativeStr(autoTypeSource) or ""
(result_py, errors_py) = self.parse_types_from_source(
source_py, file_name_py, platform_py, existing_types_py, options_py,