summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.circleci/config.yml2
-rw-r--r--CHANGELOG.md2
-rw-r--r--lib/pry/exceptions.rb6
-rw-r--r--lib/pry/pry_class.rb7
4 files changed, 15 insertions, 2 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 3ba24dc5..7a7a0876 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -131,7 +131,7 @@ jobs:
- <<: *unit
"ruby-2.7":
docker:
- - image: circleci/ruby:2.7.0-preview1
+ - image: circleci/ruby:2.7.0
working_directory: ~/pry
steps:
- <<: *repo_restore_cache
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 56e73401..8372abc2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -94,6 +94,8 @@
are set, Pry no longer uses traditional files like `~/.pryrc` &
`~/.pry_history`. Instead, the env variable paths are loaded first
([#2056](https://github.com/pry/pry/pull/2056))
+* Fixed the `$SAFE will become a normal global variable in Ruby 3.0` warning on
+ Ruby 2.7 ([#2107](https://github.com/pry/pry/pull/2107))
### [v0.12.2][v0.12.2] (November 12, 2018)
diff --git a/lib/pry/exceptions.rb b/lib/pry/exceptions.rb
index eac1c009..ee31e6c4 100644
--- a/lib/pry/exceptions.rb
+++ b/lib/pry/exceptions.rb
@@ -27,7 +27,11 @@ class Pry
# Catches SecurityErrors if $SAFE is set
module TooSafeException
def self.===(exception)
- $SAFE > 0 && exception.is_a?(SecurityError)
+ if Pry::HAS_SAFE_LEVEL
+ $SAFE > 0 && exception.is_a?(SecurityError)
+ else
+ exception.is_a?(SecurityError)
+ end
end
end
diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb
index 414c6a5a..80dda807 100644
--- a/lib/pry/pry_class.rb
+++ b/lib/pry/pry_class.rb
@@ -6,6 +6,13 @@ require 'pathname'
class Pry
LOCAL_RC_FILE = "./.pryrc".freeze
+ # @return [Boolean] true if this Ruby supports safe levels and tainting,
+ # to guard against using deprecated or unsupported features
+ HAS_SAFE_LEVEL = (
+ RUBY_ENGINE == 'ruby' &&
+ Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7')
+ )
+
class << self
extend Pry::Forwardable
attr_accessor :custom_completions