Description: Upstream_a3c9e284b46abf558c51d0af7a997609333bc7a2
 Fix code generation with escaped braces in f-strings #125
 .
 astor (0.7.1-2) unstable; urgency=medium
 .
   * Merge upstream c72349f3153134d5cb0161add9f4ed4b75d0a7c4 fixing
     conversion of stdlib on Python 3.6+ (unittest failing).
Author: Adam Cecile <acecile@le-vert.net>

---
Origin: upstream, https://github.com/berkerpeksag/astor/commit/a3c9e284b46abf558c51d0af7a997609333bc7a2
Bug: https://github.com/berkerpeksag/astor/commit/a3c9e284b46abf558c51d0af7a997609333bc7a2
Forwarded: not-needed
Reviewed-By: Upstream
Last-Update: 2019-04-23

--- astor-0.7.1.orig/astor/code_gen.py
+++ astor-0.7.1/astor/code_gen.py
@@ -564,7 +564,8 @@ class SourceGenerator(ExplicitNodeVisito
             def recurse(node):
                 for value in node.values:
                     if isinstance(value, ast.Str):
-                        self.write(value.s)
+                        # Double up braces to escape them.
+                        self.write(value.s.replace('{', '{{').replace('}', '}}'))
                     elif isinstance(value, ast.FormattedValue):
                         with self.delimit('{}'):
                             self.visit(value.value)
--- astor-0.7.1.orig/docs/changelog.rst
+++ astor-0.7.1/docs/changelog.rst
@@ -13,7 +13,11 @@ New features
 Bug fixes
 ~~~~~~~~~
 
-*
+* Fixed code generation with escaped braces in f-strings.
+  (Reported by Felix Yan in `Issue 124`_ and fixed by Kodi Arfer in `PR 125`_.)
+
+.. _`Issue 124`: https://github.com/berkerpeksag/astor/issues/124
+.. _`PR 125`: https://github.com/berkerpeksag/astor/pull/125
 
 0.7.1 - 2018-07-06
 ------------------
--- astor-0.7.1.orig/tests/test_code_gen.py
+++ astor-0.7.1/tests/test_code_gen.py
@@ -522,6 +522,16 @@ class CodegenTestCase(unittest.TestCase,
         '''
         self.assertSrcRoundtripsGtVer(source, (3, 6))
 
+    def test_fstring_escaped_braces(self):
+        source = '''
+        x = f'{{hello world}}'
+        '''
+        self.assertSrcRoundtripsGtVer(source, (3, 6))
+        source = '''
+        x = f'{f.name}={{self.{f.name}!r}}'
+        '''
+        self.assertSrcRoundtripsGtVer(source, (3, 6))
+
     def test_docstring_function(self):
         source = '''
         def f(arg):
