Skip to content

Commit

Permalink
use CAN_NULL for 3.11a7 and above
Browse files Browse the repository at this point in the history
  • Loading branch information
mmckerns committed May 2, 2022
1 parent dc34710 commit 6cafbf1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dill/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ def nestedglobals(func, recurse=True):
if func is None: return list()
import sys
from .temp import capture
IS_311a7 = sys.hexversion == 51052711 #FIXME: for odd behavior in 3.11a7
CAN_NULL = sys.hexversion >= 51052711 #NULL may be prepended >= 3.11a7
names = set()
with capture('stdout') as out:
dis.dis(func) #XXX: dis.dis(None) disassembles last traceback
for line in out.getvalue().splitlines():
if '_GLOBAL' in line:
name = line.split('(')[-1].split(')')[0]
if IS_311a7:
if CAN_NULL:
names.add(name.replace('NULL + ', ''))
else:
names.add(name)
Expand Down

0 comments on commit 6cafbf1

Please sign in to comment.