mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Merge upstream from ruby/psych
* https://github.com/ruby/psych/pull/379 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
70a385a4f6
commit
631086b784
1 changed files with 24 additions and 9 deletions
|
@ -270,7 +270,7 @@ module Psych
|
||||||
#
|
#
|
||||||
def self.load yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: false, symbolize_names: false
|
def self.load yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: false, symbolize_names: false
|
||||||
if legacy_filename != NOT_GIVEN
|
if legacy_filename != NOT_GIVEN
|
||||||
warn 'warning: Passing filename with the 2nd argument of Psych.load is deprecated. Use keyword argument like Psych.load(yaml, filename: ...) instead.'
|
warn_with_uplevel 'Passing filename with the 2nd argument of Psych.load is deprecated. Use keyword argument like Psych.load(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
|
||||||
filename = legacy_filename
|
filename = legacy_filename
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -327,22 +327,22 @@ module Psych
|
||||||
#
|
#
|
||||||
def self.safe_load yaml, legacy_permitted_classes = NOT_GIVEN, legacy_permitted_symbols = NOT_GIVEN, legacy_aliases = NOT_GIVEN, legacy_filename = NOT_GIVEN, permitted_classes: [], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false
|
def self.safe_load yaml, legacy_permitted_classes = NOT_GIVEN, legacy_permitted_symbols = NOT_GIVEN, legacy_aliases = NOT_GIVEN, legacy_filename = NOT_GIVEN, permitted_classes: [], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false
|
||||||
if legacy_permitted_classes != NOT_GIVEN
|
if legacy_permitted_classes != NOT_GIVEN
|
||||||
warn 'warning: Passing permitted_classes with the 2nd argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, permitted_classes: ...) instead.'
|
warn_with_uplevel 'Passing permitted_classes with the 2nd argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, permitted_classes: ...) instead.', uplevel: 1 if $VERBOSE
|
||||||
permitted_classes = legacy_permitted_classes
|
permitted_classes = legacy_permitted_classes
|
||||||
end
|
end
|
||||||
|
|
||||||
if legacy_permitted_symbols != NOT_GIVEN
|
if legacy_permitted_symbols != NOT_GIVEN
|
||||||
warn 'warning: Passing permitted_symbols with the 3rd argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, permitted_symbols: ...) instead.'
|
warn_with_uplevel 'Passing permitted_symbols with the 3rd argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, permitted_symbols: ...) instead.', uplevel: 1 if $VERBOSE
|
||||||
permitted_symbols = legacy_permitted_symbols
|
permitted_symbols = legacy_permitted_symbols
|
||||||
end
|
end
|
||||||
|
|
||||||
if legacy_aliases != NOT_GIVEN
|
if legacy_aliases != NOT_GIVEN
|
||||||
warn 'warning: Passing aliases with the 4th argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, aliases: ...) instead.'
|
warn_with_uplevel 'Passing aliases with the 4th argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, aliases: ...) instead.', uplevel: 1 if $VERBOSE
|
||||||
aliases = legacy_aliases
|
aliases = legacy_aliases
|
||||||
end
|
end
|
||||||
|
|
||||||
if legacy_filename != NOT_GIVEN
|
if legacy_filename != NOT_GIVEN
|
||||||
warn 'warning: Passing filename with the 5th argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, filename: ...) instead.'
|
warn_with_uplevel 'Passing filename with the 5th argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
|
||||||
filename = legacy_filename
|
filename = legacy_filename
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ module Psych
|
||||||
# See Psych::Nodes for more information about YAML AST.
|
# See Psych::Nodes for more information about YAML AST.
|
||||||
def self.parse yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: NOT_GIVEN
|
def self.parse yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: NOT_GIVEN
|
||||||
if legacy_filename != NOT_GIVEN
|
if legacy_filename != NOT_GIVEN
|
||||||
warn 'warning: Passing filename with the 2nd argument of Psych.parse is deprecated. Use keyword argument like Psych.parse(yaml, filename: ...) instead.'
|
warn_with_uplevel 'Passing filename with the 2nd argument of Psych.parse is deprecated. Use keyword argument like Psych.parse(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
|
||||||
filename = legacy_filename
|
filename = legacy_filename
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ module Psych
|
||||||
end
|
end
|
||||||
|
|
||||||
if fallback != NOT_GIVEN
|
if fallback != NOT_GIVEN
|
||||||
warn 'warning: Passing the `fallback` keyword argument of Psych.parse is deprecated.'
|
warn_with_uplevel 'Passing the `fallback` keyword argument of Psych.parse is deprecated.', uplevel: 1 if $VERBOSE
|
||||||
fallback
|
fallback
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
|
@ -447,7 +447,7 @@ module Psych
|
||||||
# See Psych::Nodes for more information about YAML AST.
|
# See Psych::Nodes for more information about YAML AST.
|
||||||
def self.parse_stream yaml, legacy_filename = NOT_GIVEN, filename: nil, &block
|
def self.parse_stream yaml, legacy_filename = NOT_GIVEN, filename: nil, &block
|
||||||
if legacy_filename != NOT_GIVEN
|
if legacy_filename != NOT_GIVEN
|
||||||
warn 'warning: Passing filename with the 2nd argument of Psych.parse_stream is deprecated. Use keyword argument like Psych.parse_stream(yaml, filename: ...) instead.'
|
warn_with_uplevel 'Passing filename with the 2nd argument of Psych.parse_stream is deprecated. Use keyword argument like Psych.parse_stream(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
|
||||||
filename = legacy_filename
|
filename = legacy_filename
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -553,7 +553,7 @@ module Psych
|
||||||
#
|
#
|
||||||
def self.load_stream yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: []
|
def self.load_stream yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: []
|
||||||
if legacy_filename != NOT_GIVEN
|
if legacy_filename != NOT_GIVEN
|
||||||
warn 'warning: Passing filename with the 2nd argument of Psych.load_stream is deprecated. Use keyword argument like Psych.load_stream(yaml, filename: ...) instead.'
|
warn_with_uplevel 'Passing filename with the 2nd argument of Psych.load_stream is deprecated. Use keyword argument like Psych.load_stream(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
|
||||||
filename = legacy_filename
|
filename = legacy_filename
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -617,6 +617,21 @@ module Psych
|
||||||
end
|
end
|
||||||
private_class_method :symbolize_names!
|
private_class_method :symbolize_names!
|
||||||
|
|
||||||
|
# Workaround for emulating `warn '...', uplevel: 1` in Ruby 2.4 or lower.
|
||||||
|
def self.warn_with_uplevel(message, uplevel: 1)
|
||||||
|
at = parse_caller(caller[uplevel]).join(':')
|
||||||
|
warn "#{at}: #{message}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.parse_caller(at)
|
||||||
|
if /^(.+?):(\d+)(?::in `.*')?/ =~ at
|
||||||
|
file = $1
|
||||||
|
line = $2.to_i
|
||||||
|
[file, line]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
private_class_method :warn_with_uplevel, :parse_caller
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
attr_accessor :load_tags
|
attr_accessor :load_tags
|
||||||
attr_accessor :dump_tags
|
attr_accessor :dump_tags
|
||||||
|
|
Loading…
Add table
Reference in a new issue