Skip to content

Commit 511dd2f

Browse files
committed
Use a gensym to represent failed imports where possible
unpythonic.syntax.astcompat already used this, so this is just to make the other modules consistent with it.
1 parent 5deaae4 commit 511dd2f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

unpythonic/mathseq.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class _NoSuchType:
5050
try:
5151
from mpmath import mpf, almosteq as mpf_almosteq
5252
except ImportError:
53+
# Can't use a gensym here since `mpf` must be a unique *type*.
5354
mpf = type(_NoSuchType())
5455
mpf_almosteq = None
5556

unpythonic/syntax/astcompat.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# -*- coding: utf-8 -*-
22
"""Conditionally import AST node types only supported by Python 3.5+ or 3.6+."""
33

4-
_NoSuchNodeType = object()
4+
from ..symbol import gensym
5+
6+
_NoSuchNodeType = gensym("_NoSuchNodeType")
57

68
try: # Python 3.5+
79
from ast import AsyncFor, AsyncFunctionDef, AsyncWith, Await, MatMult

0 commit comments

Comments
 (0)