Issue #16829: IDLE printing no longer fails if there are spaces or other
special characters in the file path.
diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py
index ec50eb2..9fe0701 100644
--- a/Lib/idlelib/IOBinding.py
+++ b/Lib/idlelib/IOBinding.py
@@ -1,5 +1,6 @@
 import os
 import types
+import shlex
 import sys
 import codecs
 import tempfile
@@ -458,7 +459,7 @@
         else: #no printing for this platform
             printPlatform = False
         if printPlatform:  #we can try to print for this platform
-            command = command % filename
+            command = command % shlex.quote(filename)
             pipe = os.popen(command, "r")
             # things can get ugly on NT if there is no printer available.
             output = pipe.read().strip()
diff --git a/Misc/NEWS b/Misc/NEWS
index d777817..1e4dea2 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -147,6 +147,9 @@
 Library
 -------
 
+- Issue #16829: IDLE printing no longer fails if there are spaces or other
+  special characters in the file path.
+
 - Issue #16900: Issue a ResourceWarning when an ssl socket is left unclosed.
 
 - Issue #13899: \A, \Z, and \B now correctly match the A, Z, and B literals